3

I recently asked here about a problem I had with headless chrome, someone marked it as duplicate, but the duplicate thread didn't solve my problem either. However I've noticed what is causing the error, I haven't found a way to fix it yet though.

The code below doesn't work when I use options.add_argument("user-data-dir=selenium"). As soon as I comment it out, it works immediately. However I really need to use a cookies folder because the login doesn't only require name/password, but identification from my bank (No this is not bank automation, it uses the same authorization though).

options = Options()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
options.add_argument("--disable-gpu")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--no-sandbox")
options.add_argument('--headless')
print ("Arguments loaded")

options.add_argument("user-data-dir=selenium")

browser = webdriver.Chrome(executable_path=r'C:\Users\REDACTED\Desktop\REDACTED\browser\chromedriver.exe', options=options)
browser.get('https://REDACTED')
print ("Headless Chrome Initialized")

The error I get is that it can't login. This is normal when I dont have this selenium data dir, as the page required identification from my bank, it doesn't require this identification when I use the cookies from selenium data dir.

Xetra
  • 73
  • 1
  • 8

2 Answers2

0

it missing -- it should be

options.add_argument("--user-data-dir=selenium")

or maybe you want to select profile selenium

options.add_argument('--profile-directory=selenium')
ewwink
  • 18,382
  • 2
  • 44
  • 54
0

add following args fix my issue

options.add_argument("--remote-debugging-port=9222")