开发者

How do you reuse cookies between SeleniumRC sessions?

I'd like to run Selenium-RC and have it remember the cookies saved from the last time it was r开发者_Go百科un. Is this possible?


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 this

After doing this, manually open browser for this profile and save your cookies, bookmarks , certificates(very helpful for https).


It's usually a bad idea to start a test with an existing browser profile, which is why RC starts with a clean one. But you can make it reuse a profile, by providing your own profile template, instead of the one baked into the JAR file. Check out the RC server's -firefoxProfileTemplate option for the details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜