pythonseleniumcookiessession-cookieschrome-options

how can I test a remember me feature using selenium python


how can I write a test case validation for a remember me button as selenium every time opens a new instance of the browser with no cookies. I heard ChromeOptions class can store cookies in a private file. I tried searching for the argument and found- "user-data-dir=/path/"

how can I use this path back into my next test case in order to validate it?


Solution

  • Add this code in your second loop

    options = webdriver.ChromeOptions() 
    options.add_argument("user-data-dir=C:\\Users\\YOUR_USERNAME_HERE\\AppData\\Local\\Google\\Chrome\\User Data\\")
    
    

    You may or may not then also need to re-instantiate the driver

    driver = webdriver.Chrome(PATH, options=options)
    

    and do the GET request

     driver.get("http://127.0.0.1:8000/route_that_requires_remember_me")