Home Xvfb Selenium headless Chrome on Linux in Python
Reply: 0

Xvfb Selenium headless Chrome on Linux in Python

user2155
1#
user2155 Published in May 25, 2018, 11:13 am

I'm trying to run chrome headless with selenium in Python. I tried xvfb-run -a python3 message.py And i get this error:

Traceback (most recent call last):
  File "message.py", line 388, in <module>
    initialize()
  File "message.py", line 54, in initialize
    driver = webdriver.Chrome(chrome_options = chrome_options)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
    desired_capabilities=desired_capabilities)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.33.506178 (69ae10f91723897591ef1a3b465aa5d35011eb5e),platform=Linux 3.13.0-96-generic x86)

And initialize():

   chrome_options = webdriver.ChromeOptions()
   chrome_options.add_argument("--headless")
   chrome_options.add_argument("--no-sandbox")
   chrome_options.add_argument("--verbose")
   chrome_options.add_argument("--log-path=chrome.log")
   chrome_options.add_argument("window-size=1200x600")
   chrome_options.add_argument("user-data-dir=\\")
   driver = webdriver.Chrome(chrome_options = chrome_options)
   driver.get('http://google.com')

I'm using Python 3.5 and chromedriver 2.33.506178 for Linux32 (Ubuntu as Server without Desktop) I tested the same code on my other pc with linux mint, all works fine.

Hope you can help me :)

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.366438 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO