I am running some java tests for a web application with Webdriver on Firefox, trying to verify the functionality of a "Keep me logged in" button. Each time a new browser is launched, it is done so with a new profile. Is there a way to instruct it to open the new browser 开发者_开发知识库with the same profile as before, the one that logged in and pressed on "keep me logged in"? I'm sorry if the question doesn't make sense, I'm still a bit new at this.
Thanks,
Ragnar
This isn't currently possible. WebDriver will use a fresh profile every time you launch the browser (although you can use an existing profile as a model). You can file a feature request in the Selenium tracker
You can use FirefoxProfile
with an existing profile:
FirefoxProfile profile = new FirefoxProfile(path to profile dir);
WebDriver driver = new FirefoxDriver(profile);
You can not do that with obtaining a new WebDriver instance. but you can do that with JavaScript as below
((JavascriptExecutor)webDriver).executeScript("window.open('"+ConfigLocator.getTargetServer()+"', '_blank');");
First of all, like Jarib said, it is possible to use an existing profile as a model. It means no specific data like favorites, history, homepage will be really loaded. But there is a possibility to set some special sytem properties to driver.
webdriver.reap_profile
Should be “true” if temporary files and profiles should not be deleted
System.setProperty("webdriver.reap_profile", "true");
Most probably there is a possibility to use that kind of solution in your situation too.
精彩评论