我正在通过 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/