1

Based off the answer here I am trying to get Chrome to run headless in my script.

The snippet of code below is inside of a function called login() that logs into our ERP system:

if headless == True:
    options = Options()
    options.headless = True
    #Load webdriver
    driver = webdriver.Chrome(options=options, executable_path=r'C:/Users/d.kelly/Desktop/Python/chromedriver_win32/chromedriver.exe')
if headless == False:
    driver = webdriver.Chrome('C:/Users/d.kelly/Desktop/Python/chromedriver_win32/chromedriver.exe')
window_before_login = driver.window_handles[0]
### Removed Code Block that fills out login form and clicks 'Login' button ###
# Switch to new window ERP (PLEX)  launches and close original blank one no longer needed.
window_before_login = driver.window_handles[0]
window_title = driver.title
driver.switch_to.window(window_before_login)
driver.close()
driver.switch_to.window(driver.window_handles[0])

When I call my function like so:

login(headless=False)

It throws no errors and my entire script executes just fine.

When I call my function like this:

def login(headless=True)

I get the following errors:

DevTools listening on ws://127.0.0.1:57567/devtools/browser/69f9e357-dccf-4e38-8d6b-78030462379a
[0204/072436.206:INFO:CONSOLE(6)] "Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead.", source: https://test.plexonline.com/modules/systemadministration/login/index.aspx? (6)
[0204/072437.699:INFO:CONSOLE(6)] "Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead.", source: https://test.plexonline.com/Modules/SystemAdministration/Login/Index.aspx (6)
[0204/072437.722:INFO:CONSOLE(1)] "Scripts may close only the windows that were opened by it.", source:  (1)
[0204/072441.162:INFO:CONSOLE(751)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: https://test.plexonline.com/Modules/scripts/ajax.js (751)

I am using Chrome Version 79.0.3945.130 (Official Build) (64-bit), Selenium 3.141.0, and Python 3.7.4.

Any ideas what I am doing wrong? Thank you!

Programming_Learner_DK
  • 1,509
  • 4
  • 23
  • 49

0 Answers0