Limitation of HTMLUnit driver for headless testing

2019-06-07 16:26发布

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条回答
Lonely孤独者°
2楼-- · 2019-06-07 16:51

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 :)

查看更多
登录 后发表回答