我已经安装了 firefox 14 并在机器上安装了 firefox portable version 25.0.1,我在其中运行网站测试。
由于我正在测试的站点的限制,我无法在 firefox 14 安装上运行我的测试。我也无法升级 firefox 14 安装。
所以我正在寻找一个解决方案,我可以使用这个可移植 firefox 版本而不是已安装的 firefox 14 版本。
我应该如何强制 selenium 使用这个便携版本而不是安装版本?如果有人可以指导我阅读一些描述性文章/博客,那就太好了。
我的代码是这样的:-
* 变量 *
${SELENIUM_HUB} remote_url=http://127.0.0.1:4444/wd/hub
${BROWSER} firefox D:\\Firefox Portable\\FirefoxPortable\\firefox.exe
${CLIENT_URL} https://abcd.aline.local
Open Browser ${CLIENT_URL} ${BROWSER} ${SELENIUM_HUB}
将路径指定为 D:/Firefox Portable/FirefoxPortable/firefox.exe 不起作用,因为“/”已被删除。有什么想法吗?
PS:使用的语言是python
最佳答案
在实例化 Firefox 网络驱动程序时,您可以使用作为 firefox_binary 参数传递的 FirefoxBinary 类指定所需的 firefox 二进制文件的路径。
和
确保二进制文件的路径是正确的,例如:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
firefox_binary = FirefoxBinary("D:\\Firefox Portable\\FirefoxPortable\\firefox.exe")
driver = webdriver.Firefox(firefox_binary=firefox_binary)
使用 robotframework 类似:
${firefox_binary}= Evaluate sys.modules['selenium.webdriver.firefox.firefox_binary'].FirefoxBinary("D:\\Firefox Portable\\FirefoxPortable\\firefox.exe") sys, selenium.webdriver.firefox_binary
Create Webdriver Firefox firefox_binary=${firefox_binary}
可能有用。
关于python - 强制 selenium 使用可移植 firefox 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22289969/