阅读这里的答案让我明白,我需要连接到Selenium Java服务器,因为HTMLUnit是用java实现的。我真的不明白这意味着什么,如果有人会指出我的方向正确,我将不胜感激。如何在python中用selenium设置HTMLUnit驱动程序?
0
A
回答
0
使用低于2.52的硒罐子落入内置在硒
from selenium import webdriver
driver = webdriver.Remote(
desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
driver.get('https://stackoverflow.com/')
以上2.53,你必须下载HTMLdriver
分别
欲了解更多信息,请访问该Link
0
HtmlUnitDriver像其他浏览器像FirefoxDriver,ChromeDriver等。
你可以找到官方https://code.google.com/p/selenium/wiki/HtmlUnitDriver
在进入程序之前,您应该已经准备好了安装程序。如果你还没有完成安装程序,然后不用担心使用下载和安装
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class HtmlDemoProgram1 {
public static void main(String[] args) throws InterruptedException {
// Declaring and initialize HtmlUnitWebDriver
WebDriver driver = new HtmlUnitDriver();
// open facebook webpage
driver.get("http://www.facebook.com");
}}
默认情况下,JavaScript在HTMLUnitDriver禁用,因此您必须启用它,而写剧本。
两种方式启用JavaScript HTMLUnitDriver
第一 - setJavascriptEnabled方法来真正
WebDriver driver = new HtmlUnitDriver();
driver.setJavascriptEnabled(true);
WebDriver driver = new HtmlUnitDriver();
driver.setJavascriptEnabled(true);
二线当初始化浏览器本身就可以启用。
HtmlUnitDriver driver = new HtmlUnitDriver(true);
欲了解更多信息,请参阅here
相关问题
- 1. 如何通过Python绑定使用Selenium的HtmlUnit驱动程序?
- 2. Selenium远程驱动程序与HtmlUnit驱动程序问题
- 3. 如何使用Python绑定在Selenium webdriver中加载HtmlUnit驱动程序?
- 4. Java Selenium Htmlunit驱动程序Javascript错误
- 5. Selenium:如何在Firefox上设置移动模式驱动程序
- 6. JMeter jp @ gc - HtmlUnit驱动程序配置
- 7. Python - Selenium - 壁虎驱动程序+扩展
- 8. 配置Selenium +无头驱动程序+ maven
- 9. 无头浏览器自动化 - 使用Selenium和htmlunit驱动程序
- 10. 如何使用JDBC驱动程序在Hive中设置FetchSize 0.13.0
- 11. 如何在Selenium中编写通用Web驱动程序等待
- 12. Htmlunit驱动程序有Javascript的问题
- 13. 如何使用Node.js Selenium Chrome驱动程序设置文件下载目录
- 14. 如何使用Python中的Selenium驱动程序在Facebook上发送消息
- 15. selenium safari驱动程序System.NotImplementedException
- 16. Selenium Web驱动程序
- 17. 如何在Selenium中使用Mozilla Marionette Web驱动程序时禁用Web驱动程序例外
- 18. 如何在Windows WDM驱动程序中设置系统时间?
- 19. 如何在PySide中设置QMYSQL驱动程序?
- 20. 如何设置DB2 ODBC驱动程序区域设置?
- 21. 我如何在jenkins中安装selenium chrome驱动程序?
- 22. 如何在Selenium网络驱动程序中按Ctrl +]
- 23. 如何在Selenium Web驱动程序中获取userAgent信息
- 24. 用uv4l raspicam驱动程序设置SimpleCV
- 25. Selenium 3.0壁虎驱动程序和木偶驱动程序
- 26. Selenium eclipse配置Webdriver 2和Selenium Java客户端驱动程序
- 27. 如何模拟Firefox 9的HtmlUnit驱动程序?
- 28. Chrome驱动程序如何工作,但Firefox,PhantomJS和HTMLUnit没有?
- 29. 如何使用Selenium启动Safari Web驱动程序?
- 30. 如何使用Selenium ::远程::驱动程序Perl软件包