Merge pull request #4861 from Kuniwak/add-android-to-webdriver

selenium-webdriver: Added options for Android
This commit is contained in:
Basarat Ali Syed
2015-07-14 13:49:34 +10:00
2 changed files with 130 additions and 3 deletions
+12 -3
View File
@@ -14,11 +14,19 @@ function TestChromeOptions() {
options = options.addArguments("a", "b", "c");
options = options.addExtensions("a", "b", "c");
options = options.excludeSwitches("a", "b", "c");
options = options.detachDriver(true);
options = options.setChromeBinaryPath("path");
options = options.setChromeLogFile("logfile");
options = options.setLocalState("state");
options = options.androidActivity("com.example.Activity");
options = options.androidDeviceSerial("emulator-5554");
options = options.androidChrome();
options = options.androidPackage("com.android.chrome");
options = options.androidProcess("com.android.chrome");
options = options.androidUseRunningApp(true);
options = options.setLoggingPrefs(new webdriver.logging.Preferences());
options = options.setPerfLoggingPrefs({enableNetwork: true, enablePage: true, enableTimeline: true, tracingCategories: "category", bufferUsageReportingInterval: 1000});
options = options.setProxy({ proxyType: "proxyType" });
options = options.setUserPreferences("preferences");
var capabilities: webdriver.Capabilities = options.toCapabilities();
@@ -31,13 +39,14 @@ function TestServiceBuilder() {
builder = new chrome.ServiceBuilder("exe");
var anything: any = builder.build();
builder = builder.enableVerboseLogging();
builder = builder.usingPort(8080);
builder = builder.setAdbPort(5037);
builder = builder.loggingTo("path");
builder = builder.enableVerboseLogging();
builder = builder.setNumHttpThreads(5);
builder = builder.setUrlBasePath("path");
builder = builder.setStdio("config");
builder = builder.setStdio(["A", "B"]);
builder = builder.setUrlBasePath("path");
builder = builder.usingPort(8080);
builder = builder.withEnvironment({ "A": "a", "B": "b" });
}
+118
View File
@@ -33,6 +33,14 @@ declare module chrome {
prefs?: any;
}
interface IPerfLoggingPrefs {
enableNetwork: boolean;
enablePage: boolean;
enableTimeline: boolean;
tracingCategories: string;
bufferUsageReportingInterval: number;
}
/**
* Class for managing ChromeDriver specific options.
*/
@@ -62,6 +70,16 @@ declare module chrome {
addArguments(...var_args: string[]): Options;
/**
* List of Chrome command line switches to exclude that ChromeDriver by default
* passes when starting Chrome. Do not prefix switches with "--".
*
* @param {...(string|!Array<string>)} var_args The switches to exclude.
* @return {!Options} A self reference.
*/
excludeSwitches(...var_args: string[]): Options;
/**
* Add additional extensions to install when launching Chrome. Each extension
* should be specified as the path to the packed CRX file, or a Buffer for an
@@ -114,6 +132,32 @@ declare module chrome {
*/
setLoggingPrefs(prefs: webdriver.logging.Preferences): Options;
/**
* Sets the performance logging preferences. Options include:
*
* - `enableNetwork`: Whether or not to collect events from Network domain.
* - `enablePage`: Whether or not to collect events from Page domain.
* - `enableTimeline`: Whether or not to collect events from Timeline domain.
* Note: when tracing is enabled, Timeline domain is implicitly disabled,
* unless `enableTimeline` is explicitly set to true.
* - `tracingCategories`: A comma-separated string of Chrome tracing categories
* for which trace events should be collected. An unspecified or empty
* string disables tracing.
* - `bufferUsageReportingInterval`: The requested number of milliseconds
* between DevTools trace buffer usage events. For example, if 1000, then
* once per second, DevTools will report how full the trace buffer is. If a
* report indicates the buffer usage is 100%, a warning will be issued.
*
* @param {{enableNetwork: boolean,
* enablePage: boolean,
* enableTimeline: boolean,
* tracingCategories: string,
* bufferUsageReportingInterval: number}} prefs The performance
* logging preferences.
* @return {!Options} A self reference.
*/
setPerfLoggingPrefs(prefs: IPerfLoggingPrefs): Options;
/**
* Sets preferences for the "Local State" file in Chrome's user data
@@ -124,6 +168,69 @@ declare module chrome {
setLocalState(state: any): Options;
/**
* Sets the name of the activity hosting a Chrome-based Android WebView. This
* option must be set to connect to an [Android WebView](
* https://sites.google.com/a/chromium.org/chromedriver/getting-started/getting-started---android)
*
* @param {string} name The activity name.
* @return {!Options} A self reference.
*/
androidActivity(name: string): Options;
/**
* Sets the device serial number to connect to via ADB. If not specified, the
* ChromeDriver will select an unused device at random. An error will be
* returned if all devices already have active sessions.
*
* @param {string} serial The device serial number to connect to.
* @return {!Options} A self reference.
*/
androidDeviceSerial(serial: string): Options;
/**
* Configures the ChromeDriver to launch Chrome on Android via adb. This
* function is shorthand for
* {@link #androidPackage options.androidPackage('com.android.chrome')}.
* @return {!Options} A self reference.
*/
androidChrome(): Options;
/**
* Sets the package name of the Chrome or WebView app.
*
* @param {?string} pkg The package to connect to, or `null` to disable Android
* and switch back to using desktop Chrome.
* @return {!Options} A self reference.
*/
androidPackage(pkg: string): Options;
/**
* Sets the process name of the Activity hosting the WebView (as given by `ps`).
* If not specified, the process name is assumed to be the same as
* {@link #androidPackage}.
*
* @param {string} processName The main activity name.
* @return {!Options} A self reference.
*/
androidProcess(processName: string): Options;
/**
* Sets whether to connect to an already-running instead of the specified
* {@linkplain #androidProcess app} instead of launching the app with a clean
* data directory.
*
* @param {boolean} useRunning Whether to connect to a running instance.
* @return {!Options} A self reference.
*/
androidUseRunningApp(useRunning: boolean): Options;
/**
* Sets the path to Chrome's log file. This path should exist on the machine
* that will launch Chrome.
@@ -189,6 +296,17 @@ declare module chrome {
usingPort(port: number): ServiceBuilder;
/**
* Sets which port adb is listening to. _The ChromeDriver will connect to adb
* if an {@linkplain Options#androidPackage Android session} is requested, but
* adb **must** be started beforehand._
*
* @param {number} port Which port adb is running on.
* @return {!ServiceBuilder} A self reference.
*/
setAdbPort(port: number): ServiceBuilder;
/**
* Sets the path of the log file the driver should log to. If a log file is
* not specified, the driver will log to stderr.