Reputation: 1
I have following scenario to automate :
I can automate first 3 steps. But when I open browser again in step 4, a new session is started and my user sees log in page. I believe the web driver browser is in incognito mode. So session cookie is not stored.
Is there any way to automate this scenario using selenium web driver?
Upvotes: 0
Views: 1439
Reputation: 688
You have to quit the webdriver before launching the saved url.
At 3rd step write driver.quit();
and at 4th step write:
driver.get("<saved_url>");
Upvotes: 0
Reputation: 190
It's because every time when you invoke browser, selenium opens a new browser profile..so your cookies will be lost..
You can inject cookies for the second time..
Cookie ck = new Cookie("name", "value");
driver.manage().addCookie(ck);
Or you can use same browser profile for driver..
FirefoxBinary binary = new FirefoxBinary();
File firefoxProfileFolder = new File("/Users/xxx/work/xxx/selenium/src/test/resources/firefoxprofile");
FirefoxProfile profile = new FirefoxProfile(firefoxProfileFolder);
webDriver driver= new FirefoxDriver(binary, profile);
Upvotes: 1