I'm new to Java and Selenium and have this issue where I need to reuse the browser session.
I've searched around, but could not find a good solution for that. Is there a way to reuse Firefox session in Selenium with Java?
I'm new to Java and Selenium and have this issue where I need to reuse the browser session.
I've searched around, but could not find a good solution for that. Is there a way to reuse Firefox session in Selenium with Java?
You have two options:
Save your cookies and retrieve them at each creation of the driver
driver = new FirefoxDriver();
for(Cookie cookie : allCookies)
{
driver.manage().addCookie(cookie);
}
Save your browser profile locally and then load it
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
File profileDirectory = new File("c://mach//lib//prof");
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(capabilities);