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?
2 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.
Comments
Thats because selenium server starts new profile for browser everytime, so your saved cookies and bookmarks do not exist on this profile.
First create a profile, for firefox it is given here
then bundle this profile to your selenium server like this
SeleniumServer server = new SeleniumServer(); RemoteControlConfiguration rcc = new RemoteControlConfiguration(); //rcc.setPort(4444); File newFirefoxProfileTemplate = new File(ReadConFile.readcoFile("fiefoxProfilePath")); rcc.setFirefoxProfileTemplate(newFirefoxProfileTemplate); server = new SeleniumServer(rcc); server.start(); DefaultSelenium selenium = new DefaultSelenium("localhost", 4444, "*chrome",ReadConFile.readcoFile("serverName")); to know your firefoxTemplate click here