org.openqa.selenium.InvalidCookieDomainException: Document is cookie-averse using Selenium and WebDriver

后端 未结 3 1152
轻奢々
轻奢々 2020-11-27 08:25

I\'m trying to push cookies to selenium firefox webdriver stored from previous session, but I got error:

org.openqa.selenium.InvalidCookieDomainException: Do         


        
3条回答
  •  生来不讨喜
    2020-11-27 09:05

    I guess your situation is you set cookie with driver.manage.addCookie(....) before you get the url with driver.get('http://mydomain').

    Cookie can be only add to the request with same domain.
    When webdriver init, it's request url is `data:` so you cannot add cookie to it.
    So first make a request to your url then add cookie, then request you url again.
    

提交回复
热议问题