我正在尝试使用以下代码设置cookies
WebDriver driver=new FirefoxDriver();
driver.get("https://mail.google.com");
driver.findElement(By.id("Email")).sendKeys("example@gmail.com");
driver.findElement(By.id("next")).click();
Thread.sleep(3000);
driver.findElement(By.id("Passwd")).sendKeys("example999");
driver.findElement(By.id("signIn")).click();
Thread.sleep(3000);
Set<Cookie> cookies=driver.manage().getCookies();
driver.quit();
driver=new FirefoxDriver();
for(Cookie a:cookies){
driver.manage().addCookie(a);
}
driver.get("https://mail.google.com");它抛出的错误如下:
org.openqa.selenium.InvalidCookieDomainException:
You may only set cookies for the current domain
Command duration or timeout: 55 millisecondshttps://stackoverflow.com/questions/38100323
复制相似问题