Python and Selenium
The School Information System (an application which manages a database which contains relevant information about faculty, staff, and students which also helps with communications, grade-book management, and other kinds of functions) we use handles new user passwords in a really shitty fashion. It gives each new user the same default password.
You can’t change this password through any kind of batch or global process, but you can, as admin, go to each user in the web interface and click a “Reset Password” button.
I didn’t see much of a problem with parents, because which parents are going to know that other parents are going to have the same password?
Students, however, are another issue altogether. I can totally see two students confiding in one another and discovering that their passwords are the same. I can also imagine them putting two-and-two together and attempting to log in as other students, setting their own passwords, and performing all kinds of shenanigans.
I decided we could get a staff member or two together and handle the issue by each tackling a grade per day in a process of cutting and pasting from an excel spreadsheet I made for usernames and passwords for students.
We started doing it, and I thought, oh no… there must be a better way. So I looked online and found some software which would help automate the process. It was fully functional for a trial period of 30 days. So, it worked.
But afterwards I was thinking, wait a minute… I used to program. There has to be a way to do this programmatically that isn’t too difficult.
I did a lot of googling and found various entries in stackexchange that I found more or less helpful. I looked at python and mechanize. I saw suggestions about using urllib and urllib2.
But then I found a gem: selenium.
Python and selenium are awesome. Selenium hijacks a browser of your choice and can get information via a very large number of query functions. It can also send clicks and keystrokes to various buttons, fields, etc. in the web-browser.
So, setting up a test program which would log in to the website and log out was a snap. It took me around a minute to inspect objects and write the functions for them.
I have yet to add functions to read in a csv file and loop logging in, changing passwords, and logging out, but that part is trivial.
I have to say, though, that if I need to do any repetitive form-filling processes over the web in the future, I have a simple means by which to do so.
Here is the code for those who may be curious, to find out how simple it is:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
elem = driver.find_element_by_name("UserName")
elem2 = driver.find_element_by_name("Password")