5

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?

1
  • 1
    Not sure if I understood your question right. But you could use "type" method to type username and password, Commented Apr 7, 2011 at 8:25

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

Comments

5

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.