Ошибка Selenium Chromedriver add cookie — invalid domain error

https://stackoverflow.com/questions/41559510/selenium-chromedriver-add-cookie-invalid-domain-error

The solution is: First visit the home page of the website whose cookies you are trying to add.

# first visit home page
    url = "https://www.website.com"
    driver.get(url)

    # add cookies from pickled-txt or a txt file
    cookies = pickle.load(open("cookies.pkl", "rb"))
    for cookie in cookies:
        driver.add_cookie(cookie)

    # visit again and you shall see your account logged in
    url = "https://www.website.com"
    driver.get(url)

 

The reason is:

  1. Selenium webdriver init with default url data:.
  2. add_cookie require current url is under the domain pattern of cookie.
  3. data: will not match any cookie domain

So, you get invalid cookie domain error.

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии