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
处理方案:
到场这几行代码就能够处理。
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 的题目
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运用系列题目集的细致内容,更多请关注ki4网别的相干文章!