Class ChromiumOptions<T extends ChromiumOptions>

  • All Implemented Interfaces:
    java.io.Serializable, org.openqa.selenium.Capabilities

    public class ChromiumOptions<T extends ChromiumOptions>
    extends org.openqa.selenium.remote.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/wd/hub"),
         new ChromeOptions());
     
    Since:
    Since chromedriver v17.0.963.0
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ChromiumOptions​(java.lang.String capabilityType, java.lang.String browserType, java.lang.String capability)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T addArguments​(java.lang.String... arguments)  
      T addArguments​(java.util.List<java.lang.String> arguments)
      Adds additional command line arguments to be used when starting Chrome.
      T addEncodedExtensions​(java.lang.String... encoded)  
      T addEncodedExtensions​(java.util.List<java.lang.String> encoded)
      Adds a new Chrome extension to install on browser startup.
      T addExtensions​(java.io.File... paths)  
      T addExtensions​(java.util.List<java.io.File> paths)
      Adds a new Chrome extension to install on browser startup.
      protected int amendHashCode()  
      java.util.Map<java.lang.String,​java.lang.Object> asMap()  
      boolean equals​(java.lang.Object arg0)  
      java.lang.Object getCapability​(java.lang.String arg0)  
      java.util.Set<java.lang.String> getCapabilityNames()  
      org.openqa.selenium.Platform getPlatform()  
      int hashCode()  
      T merge​(org.openqa.selenium.Capabilities extraCapabilities)  
      T setBinary​(java.io.File path)
      Sets the path to the Chrome executable.
      T setBinary​(java.lang.String path)
      Sets the path to the Chrome executable.
      T setExperimentalOption​(java.lang.String name, java.lang.Object value)
      Sets an experimental option.
      T setHeadless​(boolean headless)  
      java.util.Map<java.lang.String,​java.lang.Object> toJson()  
      java.lang.String toString()  
      • Methods inherited from class org.openqa.selenium.remote.AbstractDriverOptions

        setAcceptInsecureCerts, setPageLoadStrategy, setProxy, setStrictFileInteractability, setUnhandledPromptBehaviour
      • Methods inherited from class org.openqa.selenium.MutableCapabilities

        setCapability, setCapability, setCapability, setCapability
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.openqa.selenium.Capabilities

        getBrowserName, getVersion, is
    • Constructor Detail

      • ChromiumOptions

        public ChromiumOptions​(java.lang.String capabilityType,
                               java.lang.String browserType,
                               java.lang.String capability)
    • Method Detail

      • merge

        public T merge​(org.openqa.selenium.Capabilities extraCapabilities)
        Specified by:
        merge in interface org.openqa.selenium.Capabilities
        Overrides:
        merge in class org.openqa.selenium.MutableCapabilities
      • setBinary

        public T setBinary​(java.io.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​(java.lang.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​(java.lang.String... arguments)
        Parameters:
        arguments - The arguments to use when starting Chrome.
        See Also:
        addArguments(List)
      • addArguments

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

        Each argument may contain an option "--" 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​(java.io.File... paths)
        Parameters:
        paths - Paths to the extensions to install.
        See Also:
        addExtensions(List)
      • addExtensions

        public T addExtensions​(java.util.List<java.io.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​(java.lang.String... encoded)
        Parameters:
        encoded - Base64 encoded data of the extensions to install.
        See Also:
        addEncodedExtensions(List)
      • addEncodedExtensions

        public T addEncodedExtensions​(java.util.List<java.lang.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.
      • setExperimentalOption

        public T setExperimentalOption​(java.lang.String name,
                                       java.lang.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.
      • setHeadless

        public T setHeadless​(boolean headless)
      • amendHashCode

        protected int amendHashCode()
      • asMap

        public java.util.Map<java.lang.String,​java.lang.Object> asMap()
        Specified by:
        asMap in interface org.openqa.selenium.Capabilities
      • getPlatform

        public org.openqa.selenium.Platform getPlatform()
        Specified by:
        getPlatform in interface org.openqa.selenium.Capabilities
      • getCapability

        public java.lang.Object getCapability​(java.lang.String arg0)
        Specified by:
        getCapability in interface org.openqa.selenium.Capabilities
      • getCapabilityNames

        public java.util.Set<java.lang.String> getCapabilityNames()
        Specified by:
        getCapabilityNames in interface org.openqa.selenium.Capabilities
      • toJson

        public java.util.Map<java.lang.String,​java.lang.Object> toJson()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object arg0)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object