python - ChromeDriver 可执行文件需要在路径中可用

标签 python selenium selenium-webdriver selenium-chromedriver

我正在使用 selenium webdriver python 与 unittest 框架绑定(bind)。当我重复测试时,我的测试开始失败。我的套件中有大约 100 个测试用例。

循环三遍后,出现以下错误消息

Traceback (most recent call last):          
File "TestPlan.py", line 26, in setUp  
self.driver=self.OpenBrowser(self.configDic['BrowserOption='])
File "D:\AutoTest-Selenium\Controller.py", line 85, in OpenBrowser
File "C:\Python27\lib\selenium\webdriver\chrome\webdriver.py", line 59, in __init__   
WebDriverException: Message: 'ChromeDriver executable needs to be available in the path.  
Please download from http://chromedriver.storage.googleapis.com/index.html               
and read up at http://code.google.com/p/selenium/wiki/ChromeDriver'  

我的setUp类和tearDown方法如下:

def setUp(self):            
    self.driver=self.OpenBrowser(self.configDic['BrowserOption=']) 

def tearDown(self): 
    self.driver.quit()     

我还在任务管理器中发现了一些 Chromedriver 进程。这就是出现错误消息的原因吗?我一直注意在使用它们后关闭每个网络驱动程序实例。对于这种情况有什么解决方法吗?

谢谢大家的帮助。

最佳答案

在 Ubuntu 12.04 和 Ubuntu 14.04 上出现“ChromeDriver 可执行文件需要在路径中可用。”错误。

这样解决:

sudo -i
wget http://chromedriver.storage.googleapis.com/2.15/chromedriver_linux64.zip
unzip chromedriver_linux64.zip -d /usr/local/bin
chmod 755 /usr/local/bin/chromedriver

关于python - ChromeDriver 可执行文件需要在路径中可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26477603/

相关文章:

python - 在 Kivy 中创建一个表单来填充数据库

python - 在指定条件下对子列表中包含的值求和

python - 将原始字符串应用于函数返回值

python - 使用 Selenium 和 BeautifulSoup 通过提供表 ID Python3.7 不会返回特定表(返回空数组)

python - 在基于 Python 文本的 GUI (TUI) 中输入

Python Selenium - 尝试按类名查找元素时出错

python - Selenium:退出Python脚本而不关闭浏览器

python-3.x - 强制 docker 容器中的 SeleniumHQ 关闭所有浏览器 session

selenium - NoSuchElementException,Selenium 无法定位元素

webdriver - 使用 selenium web 驱动程序时如何在测试执行后保持浏览器打开