这应该很简单,但我遗漏了一些东西 . 我只是想在firefox上运行一些selenium python测试,它在chrome中完美运行 .
问题只是试图让ff webdriver启动并运行!
我有以下代码,所有路径都是正确的:
import selenium
from selenium.webdriver.firefox import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('C:\\Program Files\\Mozilla Firefox\\firefox.exe')
profile = webdriver.FirefoxProfile()
geckopath = 'C:\source\web_deploy_tests\geckodriver.exe'
browser = selenium.webdriver.Firefox(
capabilities={},
executable_path=geckopath,
firefox_profile=profile,
firefox_binary=binary
)
browser.get("http://google.com")
我使用的是Python 3.6.2,selenium 3.6.0和geckodriver.exe的v0.19.0,而FF是v56.0.1 .
当我运行上面的代码时,firefox出现但只是在那里坐了大约30秒然后崩溃:
selenium.common.exceptions.WebDriverException:消息:无法加载配置文件 . 可能的firefox版本不匹配 . 您必须使用GeckoDriver代替Firefox 48 . 配置文件目录:C:\ Users \ ADMINI~1 \ AppData \ Local \ Temp \ 3 \ tmpkx5dau8h如果在FirefoxBinary构造函数中指定了log_file,请检查它是否有详细信息 .
我尝试过args的各种组合但是我失败了 .
有任何想法吗? TIA
1 回答
我通过传递DesiredCapabilities.FIREFOX来实现它
现在我至少可以打开浏览器窗口了!