当我把我的代码放在理论上看起来应该工作时,我无法让铬运行,我甚至遵循了教程,但我不断得到同样的错误消息。这是我放的代码:from selenium import webdriver#chromedriver varible with exact location to where its savedchromedriver = "/home/jackmiller/Downloads/chromedriver"#varible of drive to run open up the chrome driver which is located#on my machine as chromedriver varible chromedriverdriver = webdriver.Chrome(chromedriver)#open this websitedriver.get('https://youtube.com')当我在终端中运行代码时,这是它返回的内容:Traceback (most recent call last): File "automation.py", line 8, in <module> driver = webdriver.Chrome(chromedriver) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__ desired_capabilities=desired_capabilities) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__ self.start_session(capabilities, browser_profile) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace)selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)它根本没有打开铬
2 回答
牧羊人nacy
TA贡献1862条经验 获得超7个赞
你试过吗: options.add_argument(“--远程调试端口=9222”)
从此错误报告:https://github.com/SeleniumHQ/selenium/issues/6049
解决方法是指定远程调试端口作为ChromeOptions的参数,例如:options.add_argument(“-远程调试端口= 9222”),如果您在容器中运行,请将驱动程序设置为无外设,如sops.headless = True,否则使用类似pyvirtualdisplay之类的东西作为屏幕截图。
添加回答
举报
0/150
提交
取消