这就是我想要使用WebDriver执行的操作.
问题是当我关闭驱动程序并重新打开它时,我没有登录.
我的代码看起来像这样 -
WebDriver myD = null;
myD = new FirefoxDriver();
String URL = "https://www.eurostylelighting.com/protected/account/signin?ReturnUrl=%2f";
myD.navigate().to(URL);
myD.findElement(By.cssSelector("input#txtEmailorRewards")).sendKeys("abc@yahoo.com");
myD.findElement(By.cssSelector("input#txtPassword")).sendKeys("abc");
myD.findElement(By.xpath(".//*[@id='accountSignIn']/dl[4]/dd/label/span")).click();
Set<Cookie> cookies = myD.manage().getCookies();
myD.close();
myD= new FirefoxDriver();
myD.navigate().to(URL);
for(Cookie getCookie:cookies)
myD.manage().addCookie(getCookie);
Run Code Online (Sandbox Code Playgroud)