WebDriverException:消息:服务chromedriver意外退出。状态代码为:127,在Ubuntu中使用ChromeDriver和Selenium

时间:2018-12-06 04:12:31

标签: python selenium google-chrome ubuntu selenium-chromedriver

这是我在执行代码时收到的错误:

var phoneRegex = /^(\+?( |-|\.)?\d{1,2}( |-|\.)?)?(\(?\d{3}\)?|\d{3})( |-|\.)?(\d{3}( |-|\.)?\d{4})$/gi;

function testPhoneNum(possibleNumber) {
  return phoneRegex.test(possibleNumber);
}

console.log(testPhoneNum('123-456-7890'))
console.log(testPhoneNum('heck no'))
  

文件   “ /usr/local/lib/python2.7/dist-packages/selenium/webdriver/chrome/webdriver.py”,   第73行,初始化       self.service.start()文件“ /usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py”,   第98行,开始时       self.assert_process_still_running()文件“ /usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py”,   第111行,在assert_process_still_running中       %(self.path,return_code)selenium.common.exceptions.WebDriverException:消息:服务   chromedriver意外退出。状态码为:127

2 个答案:

答案 0 :(得分:0)

driver = webdriver.Chrome() 尝试删除参数。可能是由于两个不同的Chrome驱动程序。 如果仍然无法使用,请参考link 另外,使用python3进行编译。

答案 1 :(得分:-1)

此错误消息...

/home/zachary/.local/lib/python3.6/site-packages/selenium/webdriver/common/service.py in assert_process_still_running(self)
    109             raise WebDriverException(
    110                 'Service %s unexpectedly exited. Status code was: %s'
--> 111                 % (self.path, return_code)
    112             )
    113 

WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

...表示 ChromeDriver 尝试启动/产生新的 WebBrowser Chrome浏览器会话时发生了可疑错误。< / p>

def assert_process_still_running(self)方法中似乎发生了错误:

def assert_process_still_running(self):
    return_code = self.process.poll()
    if return_code is not None:
        raise WebDriverException(
            'Service %s unexpectedly exited. Status code was: %s'
            % (self.path, return_code)
        )

return_code(如return_code = self.process.poll())分配了一个值,该值不是 None 。这意味着系统中可能存在一个僵尸 ChromeDriver 进程

解决方案

  • 升级到当前水平Version 3.14.0
  • ChromeDriver 升级到当前的ChromeDriver v2.44级别。
  • Chrome 版本保持在 Chrome v69-71 级别之间。 (as per ChromeDriver v2.44 release notes
  • 通过您的 IDE
  • 清理您的项目工作区重建您的项目,并且仅具有必需的依赖项。
  • 进行系统重启
  • 执行您的@Test
  • 始终在driver.quit()方法内调用tearDown(){},以优雅地关闭和销毁 WebDriver Web Client 实例。
相关问题