Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Selenium to login to sites that require username and password?

I am developing an automated test scripts using selenium api with python. But when i run the script from selenium rc its goes to the login page. How will I be able to put in my username and password on that page as it does not contain any sessions or cookies?

like image 418
Himanshu Avatar asked Apr 07 '11 06:04

Himanshu


1 Answers

Here's the suggestion that was made to me by Adam Goucher on the Selenium IRC channel ( irc://irc.freenode.net/selenium ):

Take advantage of the situation of a completely clean browser cache/cookie history. Code your test to do the login.

However, instead of hard-coding into your code a username and password, keep a deliberately non-source-code-revisioned configuration file with the username and password locally on the client with the username and password stored there, and have your Selenium client code retrieve the username and password from there when the Selenium code executes.

like image 163
Philip Schlesinger Avatar answered Sep 26 '22 08:09

Philip Schlesinger