1

In my Python / Selenium script I need to reuse the authentication cookies, which were set during my normal interaction. I need that in order to avoid numerous two-factor authentication prompts, which come up during "anonymized" selenium browser session. This is my simple code:

   def test(self):
        # Instantiate Chrome Browser Command
        driver = webdriver.Chrome(executable_path="/Users/myname/dev/python/drivers/chromedriver")
        # Open the provided URL
        driver.get("https://example.com")
        search_field = driver.find_element_by_xpath('//input[@id="search-white-labels-table"]')
        # search_field.clear()
        search_field.send_keys('my_search_string')

Is there any way I can configure the webdriver to use all available cookies, so the previous authentication established during my prior interaction is reatained and my selenium browser is not being prompted for additional authentication?

Eugene Goldberg
  • 14,286
  • 20
  • 94
  • 167
  • https://stackoverflow.com/questions/45417335/python-use-cookie-to-login-with-selenium and https://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver – vitaliis Apr 08 '21 at 02:55
  • I personally save them to file and read from there, after tests I delete this file. – vitaliis Apr 08 '21 at 02:56

0 Answers0