Class ChromiumOptions<T extends ChromiumOptions<?>>

All Implemented Interfaces:
Serializable, Capabilities
Direct Known Subclasses:
ChromeOptions, EdgeOptions

public class ChromiumOptions<T extends ChromiumOptions<?>> extends AbstractDriverOptions<ChromiumOptions<?>>
Class to manage options specific to ChromiumDriver.

Example usage:


 ChromeOptions options = new ChromeOptions()
 options.addExtensions(new File("/path/to/extension.crx"))
 options.setBinary(new File("/path/to/chrome"));

 // For use with ChromeDriver:
 ChromeDriver driver = new ChromeDriver(options);

 // For use with RemoteWebDriver:
 RemoteWebDriver driver = new RemoteWebDriver(
     new URL("http://localhost:4444/"),
     new ChromeOptions());
 
Since:
Since chromedriver v17.0.963.0
See Also:
  • Constructor Details

    • ChromiumOptions

      public ChromiumOptions(String capabilityType, String browserType, String capability)
  • Method Details

    • setBinary

      public T setBinary(File path)
      Sets the path to the Chrome executable. This path should exist on the machine which will launch Chrome. The path should either be absolute or relative to the location of running ChromeDriver server.
      Parameters:
      path - Path to Chrome executable.
    • setBinary

      public T setBinary(String path)
      Sets the path to the Chrome executable. This path should exist on the machine which will launch Chrome. The path should either be absolute or relative to the location of running ChromeDriver server.
      Parameters:
      path - Path to Chrome executable.
    • addArguments

      public T addArguments(String... arguments)
      Parameters:
      arguments - The arguments to use when starting Chrome.
      See Also:
    • addArguments

      public T addArguments(List<String> arguments)
      Adds additional command line arguments to be used when starting Chrome. For example:
      
         options.addArguments(
             "load-extension=/path/to/unpacked_extension",
             "allow-outdated-plugins");
       

      Each argument may contain an optional "--" prefix: "--foo" or "foo". Arguments with an associated value should be delimited with an "=": "foo=bar".

      Parameters:
      arguments - The arguments to use when starting Chrome.
    • addExtensions

      public T addExtensions(File... paths)
      Parameters:
      paths - Paths to the extensions to install.
      See Also:
    • addExtensions

      public T addExtensions(List<File> paths)
      Adds a new Chrome extension to install on browser startup. Each path should specify a packed Chrome extension (CRX file).
      Parameters:
      paths - Paths to the extensions to install.
    • addEncodedExtensions

      public T addEncodedExtensions(String... encoded)
      Parameters:
      encoded - Base64 encoded data of the extensions to install.
      See Also:
    • addEncodedExtensions

      public T addEncodedExtensions(List<String> encoded)
      Adds a new Chrome extension to install on browser startup. Each string data should specify a Base64 encoded string of packed Chrome extension (CRX file).
      Parameters:
      encoded - Base64 encoded data of the extensions to install.
    • enableBiDi

      public T enableBiDi()
    • setExperimentalOption

      public T setExperimentalOption(String name, Object value)
      Sets an experimental option. Useful for new ChromeDriver options not yet exposed through the ChromiumOptions API.
      Parameters:
      name - Name of the experimental option.
      value - Value of the experimental option, which must be convertible to JSON.
    • setAndroidPackage

      public T setAndroidPackage(String androidPackage)
    • setAndroidActivity

      public T setAndroidActivity(String activity)
    • setAndroidDeviceSerialNumber

      public T setAndroidDeviceSerialNumber(String serial)
    • setUseRunningAndroidApp

      public T setUseRunningAndroidApp(boolean useIt)
    • setAndroidProcess

      public T setAndroidProcess(String processName)
      Process name of the Activity hosting the WebView (as given by ps). If not set, the process name is assumed to be the same as androidPackage.
    • getExtraCapabilityNames

      protected Set<String> getExtraCapabilityNames()
      Specified by:
      getExtraCapabilityNames in class AbstractDriverOptions<ChromiumOptions<?>>
    • getExtraCapability

      protected Object getExtraCapability(String capabilityName)
      Specified by:
      getExtraCapability in class AbstractDriverOptions<ChromiumOptions<?>>
    • mergeInPlace

      protected void mergeInPlace(Capabilities capabilities)
    • mergeInOptionsFromCaps

      protected void mergeInOptionsFromCaps(String capabilityName, Capabilities capabilities)