'Python selenium saving a user setting to bypass device selection screen on chrome

Using selenium to navigate a web-site that requires a login and 2 factor authentication.

After logging in, if I'm using selenium, the web-site will bring up a screen for 'device selection', (i.e. laptop, desktop, phone).

If I log in without selenium, just using my chrome browser manually, I don't get this selection screen (unless I use a new device).

I thought perhaps this might be solved by saving and loading cookies, so I tried:

cookies_dict = driver.get_cookies()
pickle.dump(cookies_dict, open('cookies.p', 'wb'))

which I ran one time after logging in and completing the device selection screen then:

cookies_dict = pickle.load(open('cookies.p', 'rb'))
for cookie in cookies_dict:
      driver.add_cookie(cookie)

To run every time after logging in with selenium. I don't get any errors, but the device selection screen keeps coming up.

Is there anywhere else I could be looking to have the web-site recognize my selections from previous visits?

Apologies if question is vague. Amateur programmer, and I don't know what I don't know here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source