0

It is an old question but I don't find the answer to my situation.

my code is a simple test code

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
url="http://news.163.com/"
chrome_options = Options()
# specify headless mode
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('–headless')
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument("start-maximized")
chrome_options.add_argument("disable-infobars")
browser = webdriver.Chrome(options=chrome_options)
browser.set_page_load_timeout(300)
browser.set_script_timeout(300)
browser.get(url)
title=browser.find_elements_by_xpath('//div[@id="js_top_news"]/h2/a')
print(title[0].get_attribute('innerHTML'))
browser.quit()
driver.quit()

And I have added all the arguments in the options. And ps -aux |grep google-chrome and kill all the process in my wsl. Google Chrome 100.0.4896.88 with chrome-driver 100.0.4896.60 and they are in the same dir added in the environment path.

Oli
  • 9,766
  • 5
  • 25
  • 46
Er g Ch
  • 21
  • 7

3 Answers3

0

I would try using the updated version of the driver. Otherwise upgrade or downgrade your version to see if any of those work. This error is generally due to incompatibility

diana18
  • 110
  • 7
  • Thankyou, actually I can start with normal user. It seems to be problem bettween wsl1-chromedriver and windows-chromedriver.exe. – Er g Ch Apr 15 '22 at 02:59
0

Google Chrome 100.0.4896.88 and chrome-driver 100.0.4896.60 are perfectly in sync.

However as per the documentation:

A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. Please configure your environment to run Chrome as a regular user instead.


Solution

Remove the following arguments:

  • --no-sandbox
  • --disable-gpu
  • --disable-dev-shm-usage
  • disable-infobars

and execute your tests as non-root user (non-administrator) user.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
0

In wsl1, people can not use a linux version of chrome. so just use windows version chrome.exe and chromdriver.exe. And my problem solved by simply mv chromdriver.exe chromdriver,because selenium can only identify chromdriver without '.exe'

Er g Ch
  • 21
  • 7