python - 如何通过 Python 绑定(bind)将 HtmlUnit 驱动程序与 Selenium 结合使用?

标签 python selenium webdriver

我正在通过 Python 绑定(bind)使用 WebDriver located on Google's site .根据文档 here ,它支持四种浏览器:Chrome、IE、Firefox和HtmlUnit。我可以使用 from selenium.firefox.webdriver import WebDriver 导入 Firefox 驱动程序,使用 from selenium.chrome.webdriver import WebDriver 导入 Chrome 驱动程序。

没有可比较的 HtmlUnit 模块。如何导入 HtmlUnit 驱动程序?

最佳答案

我在 https://stackoverflow.com/a/5518175/125170 找到了答案

As of the 2.0b3 release of the python client you can create an HTMLUnit webdriver via a remote connection like so:

from selenium import webdriver
driver = webdriver.Remote(
  desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
driver.get('http://www.google.com')

You can also use the HTMLUNITWITHJS capability item for a browser with Javascript support.

Note that you need to run the Selenium Java server for this to work, since HTMLUnit is implemented on the Java side.

关于python - 如何通过 Python 绑定(bind)将 HtmlUnit 驱动程序与 Selenium 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4081724/

相关文章:

python - 在 Python 中检测 kwarg 覆盖

python - For循环不打印项目

javascript - 如何使用 Seleniumv3 和 Python3 单击 X 图标关闭 iframe

java - 页面对象模型 Selenium,将等待添加到测试类中

python - 使用 selenium webdriver 作为基类 python

selenium - 有时 xpath 不工作,但有时相同的 xpath 在运行自动化时工作

python - 在 mac 上安装 Python/PyGame

python - Selenium Firefox 驱动程序从主机文件读取

javascript - 等待多个元素在 selenium webdriver JavaScript 绑定(bind)中可见

python - 使用 Fabric 从 Python 中在远程服务器上执行代码