1

使用以下代码检查网站是否使用 selenium 和 python 在 opera 中加载:

def test_opera_compatability(self):
    driver = webdriver.Opera("functional_tests/operadriver")
    driver.get("https://www.google.com/")
    driver.quit()

它返回以下错误:

消息:“operadriver”可执行文件需要在 PATH 中。

chrome 的类似代码按预期工作,如下所示:

def test_chrome_compatability(self):
    driver = webdriver.Chrome('functional_tests/chromedriver')
    driver.get("https://www.google.com/")
    driver.quit()
4

1 回答 1

1

您可以使用Key executable_path传递operadriver二进制文件的绝对路径,如下所示:

def test_opera_compatability(self):
    driver = webdriver.Opera(executable_path='/path/to/functional_tests/operadriver')
    driver.get("https://www.google.com/")
    driver.quit()
于 2019-11-28T09:09:46.683 回答