Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Chrome Options when using WebDriverManager?

I'm using Web driver manager to setup chrome driver. When setting up the driver I want to add some chrome options? How can I do it when using web driver manager?

I checked the WebDriverManager API but couldn't find any clue..

like image 474
S Chathuranga Jayasinghe Avatar asked Mar 17 '26 07:03

S Chathuranga Jayasinghe


1 Answers

As of WebDriverManager 5.x you can instantiate the webDriver directly via the WebDriverManager builder with additional capabilities this way (in java) :

WebDriver driver;
//...
ChromeOptions chromeOptions = new ChromeOptions();  

chromeOptions.addArguments("--headless");  

//...  

//chromeOptions.addArguments(<another-option>);  

//...  

driver = WebDriverManager.chromedriver().capabilities(chromeOptions).create();

The capabilities method take a Capabilities as param.
Lucky we are, ChromeOptions implements the Capabilities interface.

like image 136
Philippe Simo Avatar answered Mar 18 '26 21:03

Philippe Simo



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!