EASY PYTHON SELENIUM: Cannot get Chrome profile to work headless

Viewed 77

My Chrome profile and headless work when used independently. When I attempt to use them together, Selenium does not recognize my profile.

When I run without headless, the output is the default page of my Chrome profile:

https://www.google.com/

When I run with headless, the output is:

about:blank

My code:

options = Options()
options.add_argument("--headless")
options.add_argument('--disable-gpu')
options.add_argument('window-size=0x0')
options.add_argument("user-data-dir=C:\\Users\\zack\\Desktop\\chrome-dev-profile")
driver = webdriver.Chrome(executable_path=r'C:\\Program Files (x86)\\chromedriver.exe', chrome_options=options)

url = driver.current_url
print(url)

Just to be abundantly clear, the desired output for the code above is:

https://www.google.com/

I am getting no errors.

0 Answers
Related