web自动化测试(一)Selenium 3使用系列问题集


本文摘自php中文网,作者little bottle,侵删。

Selenium是一个用于Web应用程序测试的工具。Selenium测试直接运行在浏览器中,就像真正的用户在操作一样。本文主要讲述的是web测试中Selenium 3使用的问题集以及解决方案。

1. 无法启动FireFox--geckodriver

运行 driver=webdriver.Firefox()

运行报错:
Exception AttributeError: "'Service' object has no attribute 'process'" in <boun
d method Service.__del__ of <selenium.webdriver.firefox.service.Service object a
t 0x028940B0>> ignored

selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executabl needs to be in PATH.

解决方案:

下载https://github.com/mozilla/geckodriver/releases 最新版,把geckodriver.exe加到系统path路径下,即可解决此问题。

2. Firefox默认安装,但找不到启动路径

selenium.common.exceptions.WebDriverException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

解决方案:

加入这几行代码就可以解决。

1

2

3

4

5

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

 

# Create a new instance of the Firefox driver

binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe')

driver = webdriver.Firefox(firefox_binary=binary)

3. 无法启动IE 的问题

1

driver = webdriver.Ie()

selenium.common.exceptions.WebDriverException: Message: 'IEDriverServer.exe' executable needs to be in PATH. Please download from http://selenium-release.storage.googleapis.com/index.html and read up at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.ie.service.Service object at 0x0276B6F0>> ignored

解决方案:

这里下载驱动: http://selenium-release.storage.googleapis.com/index.html?path=3.0/,把IEDriverServer.exe放到系统path目录即可。

【推荐课程:Python视频课程】

以上就是web自动化测试(一)Selenium 3使用系列问题集的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python在函数中使用列表作为默认参数的介绍(代码示例)

Python能开发微信小程序么

Python绘制直方图及子图的方法分析(代码示例)

Python检验jarque-bera是否符合正态分布

apache怎么支持Python

Python如何将数字转化为字符串

Python中函数的全面总结(附实例)

Python什么时候出来的

Python excel使用xlutils类库实现追加写功能的方法

最有用的Python经典书籍推荐

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...