【发布时间】:2022-07-22 17:26:16
【问题描述】:
我正在尝试使用selenium 编写几个测试,但我看到了以下奇怪的行为。
当我像这样运行测试时:
from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.firefox.service import Service
options = FirefoxOptions()
service = Service()
brow = Firefox(service=service, options=options)
brow.execute("get", {'url': 'https://python.org'})
我得到了预期的结果,python.org 网站在 Firefox 浏览器中打开。
但如果我在 URL 中出错,我会收到以下错误:
from selenium.webdriver import Firefox, FirefoxOptions
from selenium.webdriver.firefox.service import Service
options = FirefoxOptions()
service = Service()
brow = Firefox(service=service, options=options)
brow.execute("get", {'url': 'qwerty'})
selenium.common.exceptions.InvalidArgumentException: Message: Malformed URL: URL constructor: qwerty is not a valid URL.
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:186:5
InvalidArgumentError@chrome://remote/content/shared/webdriver/Errors.jsm:315:5
GeckoDriver.prototype.navigateTo@chrome://remote/content/marionette/driver.js:804:11
我只是想了解为什么我在这里看到WebDriverError@chrome,而不是WebDriverError@firefox 或类似的东西。
这是一个错误,还是我做错了什么?
【问题讨论】:
-
大概就是selenium代码内部是怎么写的
标签: python python-3.x selenium selenium-webdriver firefox