Python+selenium运行出错‘Application‘ executable may have wrong permissions.
2022/1/30 22:04:34
本文主要是介绍Python+selenium运行出错‘Application‘ executable may have wrong permissions.,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
最近在学习Python的自动化测试,需要用到selenium,于是开始安装selenium,并简单运行
我的环境:
win7+chrome+Python2.7
安装selenium 很简单,直接pip install selenium,等待安装完成即可
然后通过网上学习需要为对应的浏览器安装驱动,而且驱动的版本要跟浏览器版本对应,浏览器驱动下载及版本对应请参考如下地址:
版本对应参照 http://blog.csdn.net/huilan_same/article/details/51896672
驱动下载镜像网站 http://npm.taobao.org/mirrors/chromedriver/
下载完成之后,将解压之后的chromedriver.exe放置浏览器安装目录,我的是C:\Program Files (x86)\Google\Chrome\Application,然后将这个目录添加到环境变量中,否则会出现如下错误:
WebDriverException: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
在运行脚本还是出现如上错误,网上百度,说是创建webdriver是需要将chromedriver.exe的路径传递进去,如下操作
driver = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application')
但是运行后又出现了新的错误,如下所示:
WebDriverException: 'Application' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
网上百度,发现没有跟我一样的,网上的都是‘webdriber’executable may have wrong permissions类似的,原因都是未加环境变量,但是我加了环境变量
再分析错误原话,翻译过来“可执行文件Application可能有错误的许可”,发现Application有问题啊,这是个目录,不是可执行文件啊,在回头看需要传递路径进webdriber的文章,发现需要传递的是驱动,而不仅仅是路径,加上驱动名后
driver = webdriver.Chrome('C:\Program Files (x86)\Google\Chrome\Application\chromedriver')
正常运行了
# coding = utf-8 from selenium import webdriver driver = webdriver.Chrome( 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver') driver.get( 'http://www.baidu.com') print driver.title driver.quit()
这篇关于Python+selenium运行出错‘Application‘ executable may have wrong permissions.的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python