Limitation of HTMLUnit driver for headless testing

南楼画角 提交于 2019-12-08 08:09:44

问题


Can I perform following functions using HTML Unit Driver headless browser automation?

  1. Is it possible to take snapshot?
  2. Can click any hyperlink ?
  3. Possible to handle pop-ups?

Please help

I am planning to do automation using HTMLUnit driver


回答1:


Yes, You can perform all operations as per of your all 3 point using headless browser. Don't use HTMLUnit as it have many configuration issue.

PhamtomJS was another approach for headless browser but PhantomJs is having bug these days because of poorly maintenance of it.

You can use chromedriver itself for headless jobs.

You just need to pass one option in chromedriver as below:-

chromeOptions.addArguments("--headless");

Full code will appear like this :-

System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.co.in/");

Hope it will help you :)



来源:https://stackoverflow.com/questions/45790062/limitation-of-htmlunit-driver-for-headless-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!