selenium在命令行模式下能运行,在visual studio 2019开发环境下运行报错

1.浏览器版本和webdriver版本一致

img

img


2.已将Chrome安装路径添加至环境变量

img

img


3.webdriver和Chrome程序在同一目录下

img


4.在cmd下运行selenium正常驱动Chrome

img


5,同样的代码,但是在vs2019中就会报错(参数中添加禁用gpu加速也无效)

img

题主试试加--no-sandbox


from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
d = webdriver.Chrome('/home/PycharmProjects/chromedriver',chrome_options=chrome_options)
d.get('https://www.google.nl/')

https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is