Testing page login
I need to access some pages at work and then log in to report any problems. I was thinking of writing a program to do this.
First, I need to be able to access the pages, then I need to find the login form and submit the information. I am currently planning to print true / false for each test (accessibility and login) and then fill out the forms myself. I hope I can write something to automate this later.
I thought about using Ruby, although I haven't coded it yet, it looks like it would make things easier. I've worked the most with Java, although I have experience with C ++ and a bit of experience with C.
Any advice?
You can use Selenium IDE . It is a recording and playback tool for simple web tests that you can save as a Selenium RC test in any language you want. I hope this helps
a source to share
The urllib2 python module allows you to interact with an HTTP server. You can use urrlib2 to read the page to check the content. You can POST the urlencoded data and check the content.
Also, Python has a simple unittest library to help you structure your tests.
class TestForm( unittest.TestCase ):
def testFillInForm( self ):
data= urllib.urlencode( { field1="value", field2="value" } )
response= urllib2.urlopen( "http://localhost/path/to/form", data )
# check the response
if __name__ == "__main__":
unittest.main()
a source to share
If you want to do it this is Ruby, Mechanize Gem is perfect for this
require "mechanization"
agent = WWW :: MECHANIZE.new page = agent.get ('localhost / path / to / form')
login_form = page.forms.first #assuming the first form is the one we want
login_form.username = 'myusername'
login_form.password = 'mypassword'
page = agent.submit (login_form)
puts page.body # just to see the results `
a source to share