|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.selenium.chrome.ChromeOptions
public class ChromeOptions
Class to manage options specific to ChromeDriver
.
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:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
RemoteWebDriver driver = new RemoteWebDriver(
new URL("http://localhost:4444/wd/hub"), capabilities);
Field Summary | |
---|---|
static String |
CAPABILITY
Key used to store a set of ChromeOptions in a DesiredCapabilities
object. |
Constructor Summary | |
---|---|
ChromeOptions()
|
Method Summary | |
---|---|
void |
addArguments(List<String> arguments)
Adds additional command line arguments to be used when starting Chrome. |
void |
addArguments(String... arguments)
|
void |
addExtensions(File... paths)
|
void |
addExtensions(List<File> paths)
Adds a new Chrome extension to install on browser startup. |
void |
setBinary(File path)
Sets the path to the Chrome executable. |
org.json.JSONObject |
toJson()
Converts this instance to its JSON representation. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CAPABILITY
DesiredCapabilities
object.
Constructor Detail |
---|
public ChromeOptions()
Method Detail |
---|
public void setBinary(File path)
path
- Path to Chrome executable.public void addArguments(String... arguments)
arguments
- The arguments to use when starting Chrome.addArguments(java.util.List)
public void addArguments(List<String> arguments)
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 delimitted with an "=": "foo=bar".
arguments
- The arguments to use when starting Chrome.public void addExtensions(File... paths)
paths
- Paths to the extensions to install.addExtensions(java.util.List)
public void addExtensions(List<File> paths)
paths
- Paths to the extensions to install.public org.json.JSONObject toJson() throws IOException, org.json.JSONException
IOException
- If an error occurs while reading the
extension files
from disk.
org.json.JSONException
- If an error occurs while encoding these options as
JSON.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |