'Can we run selenium in our current account logged- in browser?

Can we run selenium in our current account logged in browser ?

Basically if i try logging into google using selenium , its says browser insecure.

i am trying to make a amazon cart auto checkout as a school project

so if i try in my existing browser , my amazon id is already registered and i dont have to sign in again . but if i use amazon login in selenium its asking for signin and 2fa is being sent to my mail id, how to i skip this step and directly go to the logged in page??

please help



Solution 1:[1]

You can't use your non-chrome driver browser (aka regular chrome browser). Selenium only works with chrome-drivers. One way remain signed in is to specify a profile in options so that every-time the driver initiates, it loads your cookies and history.

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument("--user-data-dir=Amazon")

driver = webdriver.Chrome(options=chrome_options)

From the code above, chrome_options.add_argument("--user-data-dir=Amazon") will create a profile 'Amazon' if not already there, and save cookies and history there.

enter image description here

The next time you run the driver it will load it from 'Amazon'.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 BillyZee