Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Headless WebAutomation using Selenium

I have been using Selenium webdriver for a long time for automation stuffs. The PhantomJS driver(which is now deprecated) was an awesome way to do headless automation as well as you don't need to match the driver version with the browser as in the case of chromedriver and chrome browser. I know that chromedriver and firefox drivers both can be used with headless feature enabled but the problem is that the drivers of both of them needs to be consistently upgraded and match the current browser version of the os. Please help me.

Also I would love to hear if there any other way I can do headless web automation without any dependecies(standalone).

The programming languages related to my question are: 1. Python 2. C# 3. VB.net 4. Java

If anyone has any idea or any way in any of the four languages or any other language than them, then please leave your anser.

like image 302
Gautam Kumar Giri Avatar asked Apr 15 '26 06:04

Gautam Kumar Giri


1 Answers

As you mentioned

  • yes, Chrome and Firefox browsers have headless mode.
  • you need to update versions it is also yes

But you can eliminate that issue by using web-driver manager. Because of this Even you don't need to download chromedriver.exe manually.

WebDriverManager.chromedriver().setup();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("disable-gpu");
ChromeDriver driver = new ChromeDriver(chromeOptions);
  

Web driver manager dependency

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.6.2</version>
</dependency>

Git Hub Link https://github.com/bonigarcia/webdrivermanager

like image 177
Devdun Avatar answered Apr 17 '26 19:04

Devdun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!