python selenium 远程 webdriver safari 驱动程序

标签 python selenium safari webdriver

我有这个带有 RemoteWebDriver 的 safari java 代码(我需要它,因为我在不同的系统中测试了几个浏览器,如 safari、ff,即 chrome ......使用 Selenium 2):

Selenium sel = new DefaultSelenium(host, 4444, "*safari", baseURL);
CommandExecutor executor = new SeleneseCommandExecutor(sel);
DesiredCapabilities dc = new DesiredCapabilities();
WebDriver browser = new RemoteWebDriver(executor, dc);

我知道在 Python 中第一行和最后一行是:

self.selenium = selenium(host, 4444, "*safariproxy", baseURL)
...
self.driver = webdriver.Remote(desired_capabilities = dc, command_executor = executor)

但仍然无法将中间的 java 代码重写为 Python。有谁能够帮助我?

可能有另一种方法可以在 Python 中创建与 safari 的 webdriver 远程连接?我需要 webdriver,而不是 Selenium 1。

提前致谢。

最佳答案

正确安装 Safari 驱动程序 ( http://code.google.com/p/selenium/wiki/SafariDriver ) 后,您应该能够执行以下操作以使其正常工作(我已设法使其在 2.24.1 上正常工作):

dc = {‘browserName’: ‘safari’}
self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=dc)

关于python selenium 远程 webdriver safari 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7950980/

相关文章:

javascript - 选择窗口无法选择子窗口

javascript - 了解 Selenium 中executeAsyncScript 的用法

javascript - $(窗口)打开。 ('load' ) 函数适用于 Firefox,但不适用于 Safari/iOS 或 Chrome?

python边缘列表到邻接矩阵

python - 在python中拼接二值图像

python - tkinter.TclError : unknown option 错误

selenium - 按下按钮加载评论

css - SVG 在 Mac Safari 中不可见

HTML CSS 在 Safari 中不起作用

python - 无法将 Django 查询集转换为列表