4. How to specify `ChromeOptions`? (Or any other Options) - Rafal-Laskowski/Metalloid-WebDriver-Pool GitHub Wiki

Metalloid-WebDriver-Pool will create an instance for each test. But what if you have additional options that Metalloid did not cover with properties? What if you want to create ChromeOptions (or any other) and run your tests with those?

Let's use ChromeOptions as an example.

ChromeOptions options = new ChromeOptions();
options.setHeadless(true);

How to tell Metalloid-WebDriver-Pool to use this class?

First Option

Use WebDriverPool.registerOptions(options); method before test starts

Second Option

Implement Options<T> interface like this:

package com.java.options;
public class HeadlessChromeOptions implements Options<ChromeOptions> {
    
    @Override
    public ChromeOptions getOptions() {
        ChromeOptions options = new ChromeOptions();
        options.setHeadless(true);
        return options;
    }
}

Now, provide a path to this class so Metalloid-WebDriver-Pool can instantiate it and create the Browser instance with desired options. Simply set chrome.options property to com.java.options.HeadlessChromeOptions

and that's it!