閱讀這裏的答案讓我明白,我需要連接到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. 將Firefox驅動程序的Selenium測試移植到HTMLUnit驅動程序
- 7. Selenium:如何使用網絡驅動程序設置硒
- 8. 在python中,selenium模塊。如何使用Firefox驅動程序
- 9. JMeter jp @ gc - HtmlUnit驅動程序配置
- 10. 如何在spark中設置驅動程序的python版本?
- 11. 如何設置Selenium Grid 2的Chrome驅動程序(Perl綁定)?
- 12. 在Selenium中爲Chrome驅動程序設置代理
- 13. Selenium HTMLUNIT Python滾動頁面
- 14. python selenium webdriver safari驅動程序
- 15. Python - Selenium - 壁虎驅動程序+擴展
- 16. 配置Selenium +無頭驅動程序+ maven
- 17. 無頭瀏覽器自動化 - 使用Selenium和htmlunit驅動程序
- 18. 如何使用JDBC驅動程序在Hive中設置FetchSize 0.13.0
- 19. sendKeys()在Selenium網絡驅動程序中
- 20. 如何在Selenium中編寫通用Web驅動程序等待
- 21. Htmlunit驅動程序有Javascript的問題
- 22. 如何在MongoDB C#驅動程序中動態設置屬性
- 23. 如何使用Node.js Selenium Chrome驅動程序設置文件下載目錄
- 24. 如何使用Python中的Selenium驅動程序在Facebook上發送消息
- 25. 如何在selenium Web驅動程序中自動化SOAP UI
- 26. Selenium Web驅動程序
- 27. selenium safari驅動程序System.NotImplementedException
- 28. Selenium網絡驅動程序
- 29. Selenium :: Remote ::驅動程序或WWW :: Selenium
- 30. 在Docker中設置cassandra驅動程序(python)