Selenium web automated testing---bypass login via cookie

For the login page verification code problem, there are the following solutions

(1) Comment out the verification code function in the test environment

(2) Use universal code

(3) Use cookies to bypass login (but you need to manually log in once to obtain cookie information, and cookie information is time-effective)

(4) Before running the code each time, manually log in once

This article mainly explains how to bypass login through cookies:

(1) First manually log in to get the cookieList, record the cookieList value, and comment out the expiration date field

         driver.get_cookies()

(2) Clear all cookies obtained by visiting the default webpage

         driver.delete_all_cookies()

(3) Add the cookieList obtained by login to the cookie

         for cookie in cookieList:

               driver.add_cookie(cookie)

(4) Refresh the page

         driver.refresh()

 

 

 

Guess you like

Origin blog.csdn.net/qq_19982677/article/details/107430615