0

Im working on small project and im logging there in to quizlet. The problem is that when I run my program without any chrome driver options there is no problem it works perfectly fine. But where I add my arguments the quizlet won't let me login.
Those are my arguments:

CHROME_PATH = r'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
CHROMEDRIVER_PATH = r"C:\Program Files (x86)\Python38-32\chromedriver.exe"
WINDOW_SIZE = "3840,2160"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--window-size=%s" % WINDOW_SIZE)
chrome_options.binary_location = CHROME_PATH

driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH, options=chrome_options)

as you can see i get an error:
here is a picture of error

when i edit this line:
driver = webdriver.Chrome(executable_path=CHROMEDRIVER_PATH)
it works perfectly but i don't want to see the window.
I looks like '--headless' argument triggers safety features of the webside.
This is so weird. Any sugestions?

SIlvester
  • 15
  • 5

2 Answers2

4
options = webdriver.ChromeOptions()
#options.headless = True
options.add_argument("--window-size=1920,1080")
options.add_argument("--headless")
options.add_argument("--disable-gpu")
options.add_argument(
    "user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
browser = webdriver.Chrome(options=options)

Try using user agent , as headless uses a different useragent than normal

PDHide
  • 18,113
  • 2
  • 31
  • 46
0

I believe this is a bug with Chromedriver, see the link below for an explanation from the Selenium team.

https://github.com/SeleniumHQ/selenium/issues/8967

I would monitor the Chromedriver bug tracker for any updates on the Headless mode bugs, see link below: https://bugs.chromium.org/p/chromedriver/issues/list

Sorry for the non help...

Ryan Burch
  • 500
  • 4
  • 11