Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,34 @@
import io.appium.java_client.android.options.avd.SupportsGpsEnabledOption;
import io.appium.java_client.android.options.avd.SupportsIsHeadlessOption;
import io.appium.java_client.android.options.avd.SupportsNetworkSpeedOption;
import io.appium.java_client.android.options.context.SupportsAutoWebviewTimeoutOption;
import io.appium.java_client.android.options.context.SupportsChromeLoggingPrefsOption;
import io.appium.java_client.android.options.context.SupportsChromeOptionsOption;
import io.appium.java_client.android.options.context.SupportsChromedriverArgsOption;
import io.appium.java_client.android.options.context.SupportsChromedriverChromeMappingFileOption;
import io.appium.java_client.android.options.context.SupportsChromedriverDisableBuildCheckOption;
import io.appium.java_client.android.options.context.SupportsChromedriverExecutableDirOption;
import io.appium.java_client.android.options.context.SupportsChromedriverExecutableOption;
import io.appium.java_client.android.options.context.SupportsChromedriverPortOption;
import io.appium.java_client.android.options.context.SupportsChromedriverPortsOption;
import io.appium.java_client.android.options.context.SupportsChromedriverUseSystemExecutableOption;
import io.appium.java_client.android.options.context.SupportsEnsureWebviewsHavePagesOption;
import io.appium.java_client.android.options.context.SupportsExtractChromeAndroidPackageFromContextNameOption;
import io.appium.java_client.android.options.context.SupportsNativeWebScreenshotOption;
import io.appium.java_client.android.options.context.SupportsRecreateChromeDriverSessionsOption;
import io.appium.java_client.android.options.context.SupportsShowChromedriverLogOption;
import io.appium.java_client.android.options.context.SupportsWebviewDevtoolsPortOption;
import io.appium.java_client.android.options.localization.SupportsLocaleScriptOption;
import io.appium.java_client.android.options.locking.SupportsSkipUnlockOption;
import io.appium.java_client.android.options.locking.SupportsUnlockKeyOption;
import io.appium.java_client.android.options.locking.SupportsUnlockStrategyOption;
import io.appium.java_client.android.options.locking.SupportsUnlockSuccessTimeoutOption;
import io.appium.java_client.android.options.locking.SupportsUnlockTypeOption;
import io.appium.java_client.android.options.mjpeg.SupportsMjpegScreenshotUrlOption;
import io.appium.java_client.android.options.mjpeg.SupportsMjpegServerPortOption;
import io.appium.java_client.android.options.other.SupportsDisableSuppressAccessibilityServiceOption;
import io.appium.java_client.android.options.other.SupportsSkipLogCaptureOption;
import io.appium.java_client.android.options.other.SupportsUserProfileOption;
import io.appium.java_client.android.options.server.SupportsDisableWindowAnimationOption;
import io.appium.java_client.android.options.server.SupportsSkipDeviceInitializationOption;
import io.appium.java_client.android.options.server.SupportsSkipServerInstallationOption;
Expand Down Expand Up @@ -81,12 +108,6 @@
* https://github.com/appium/appium-uiautomator2-driver#capabilities
*/
public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implements
// TODO: Device locking options: https://github.com/appium/appium-uiautomator2-driver#device-locking
// TODO: MJPEG options: https://github.com/appium/appium-uiautomator2-driver#mjpeg
// TODO: Web Context options: https://github.com/appium/appium-uiautomator2-driver#web-context
// TODO: Other options: https://github.com/appium/appium-uiautomator2-driver#other
// TODO: Shared options
SupportsAutoWebViewOption<UiAutomator2Options>,
// General options: https://github.com/appium/appium-uiautomator2-driver#general
SupportsDeviceNameOption<UiAutomator2Options>,
SupportsUdidOption<UiAutomator2Options>,
Expand Down Expand Up @@ -148,7 +169,39 @@ public class UiAutomator2Options extends BaseOptions<UiAutomator2Options> implem
SupportsIsHeadlessOption<UiAutomator2Options>,
// App signing options: https://github.com/appium/appium-uiautomator2-driver#app-signing
SupportsKeystoreOptions<UiAutomator2Options>,
SupportsNoSignOption<UiAutomator2Options> {
SupportsNoSignOption<UiAutomator2Options>,
// Device locking options: https://github.com/appium/appium-uiautomator2-driver#device-locking
SupportsSkipUnlockOption<UiAutomator2Options>,
SupportsUnlockTypeOption<UiAutomator2Options>,
SupportsUnlockKeyOption<UiAutomator2Options>,
SupportsUnlockStrategyOption<UiAutomator2Options>,
SupportsUnlockSuccessTimeoutOption<UiAutomator2Options>,
// MJPEG options: https://github.com/appium/appium-uiautomator2-driver#mjpeg
SupportsMjpegServerPortOption<UiAutomator2Options>,
SupportsMjpegScreenshotUrlOption<UiAutomator2Options>,
// Web Context options: https://github.com/appium/appium-uiautomator2-driver#web-context
SupportsAutoWebViewOption<UiAutomator2Options>,
SupportsWebviewDevtoolsPortOption<UiAutomator2Options>,
SupportsEnsureWebviewsHavePagesOption<UiAutomator2Options>,
SupportsChromedriverPortOption<UiAutomator2Options>,
SupportsChromedriverPortsOption<UiAutomator2Options>,
SupportsChromedriverArgsOption<UiAutomator2Options>,
SupportsChromedriverExecutableOption<UiAutomator2Options>,
SupportsChromedriverExecutableDirOption<UiAutomator2Options>,
SupportsChromedriverChromeMappingFileOption<UiAutomator2Options>,
SupportsChromedriverUseSystemExecutableOption<UiAutomator2Options>,
SupportsChromedriverDisableBuildCheckOption<UiAutomator2Options>,
SupportsAutoWebviewTimeoutOption<UiAutomator2Options>,
SupportsRecreateChromeDriverSessionsOption<UiAutomator2Options>,
SupportsNativeWebScreenshotOption<UiAutomator2Options>,
SupportsExtractChromeAndroidPackageFromContextNameOption<UiAutomator2Options>,
SupportsShowChromedriverLogOption<UiAutomator2Options>,
SupportsChromeOptionsOption<UiAutomator2Options>,
SupportsChromeLoggingPrefsOption<UiAutomator2Options>,
// Other options: https://github.com/appium/appium-uiautomator2-driver#other
SupportsDisableSuppressAccessibilityServiceOption<UiAutomator2Options>,
SupportsUserProfileOption<UiAutomator2Options>,
SupportsSkipLogCaptureOption<UiAutomator2Options> {
public UiAutomator2Options() {
setCommonOptions();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android.options.context;

import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.CanSetCapability;
import org.openqa.selenium.Capabilities;

import java.time.Duration;
import java.util.Optional;

import static io.appium.java_client.internal.CapabilityHelpers.toDuration;

public interface SupportsAutoWebviewTimeoutOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String AUTO_WEBVIEW_TIMEOUT_OPTION = "autoWebviewTimeout";

/**
* Set the maximum timeout to wait until a web view is
* available if autoWebview capability is set to true. 2000 ms by default.
*
* @param timeout Timeout value.
* @return self instance for chaining.
*/
default T setAutoWebviewTimeout(Duration timeout) {
return amend(AUTO_WEBVIEW_TIMEOUT_OPTION, timeout.toMillis());
}

/**
* Get the timeout to wait until a web view is available.
*
* @return The timeout value.
*/
default Optional<Duration> getAutoWebviewTimeout() {
return Optional.ofNullable(
toDuration(getCapability(AUTO_WEBVIEW_TIMEOUT_OPTION))
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android.options.context;

import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.CanSetCapability;
import org.openqa.selenium.Capabilities;

import java.util.Map;
import java.util.Optional;

public interface SupportsChromeLoggingPrefsOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CHROME_LOGGING_PREFS_OPTION = "chromeLoggingPrefs";

/**
* Chrome logging preferences mapping. Basically the same as
* [goog:loggingPrefs](https://newbedev.com/
* getting-console-log-output-from-chrome-with-selenium-python-api-bindings).
* It is set to {"browser": "ALL"} by default.
*
* @param opts Chrome logging preferences.
* @return self instance for chaining.
*/
default T setChromeLoggingPrefs(Map<String, Object> opts) {
return amend(CHROME_LOGGING_PREFS_OPTION, opts);
}

/**
* Get chrome logging preferences.
*
* @return Chrome logging preferences.
*/
default Optional<Map<String, Object>> getChromeLoggingPrefs() {
//noinspection unchecked
return Optional.ofNullable((Map<String, Object>) getCapability(CHROME_LOGGING_PREFS_OPTION));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android.options.context;

import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.CanSetCapability;
import org.openqa.selenium.Capabilities;

import java.util.Map;
import java.util.Optional;

public interface SupportsChromeOptionsOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CHROME_OPTIONS_OPTION = "chromeOptions";

/**
* A mapping, that allows to customize chromedriver options.
* See https://chromedriver.chromium.org/capabilities for the list
* of available entries.
*
* @param opts Chrome options.
* @return self instance for chaining.
*/
default T setChromeOptions(Map<String, Object> opts) {
return amend(CHROME_OPTIONS_OPTION, opts);
}

/**
* Get chrome options.
*
* @return Chrome options.
*/
default Optional<Map<String, Object>> getChromeOptions() {
//noinspection unchecked
return Optional.ofNullable((Map<String, Object>) getCapability(CHROME_OPTIONS_OPTION));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android.options.context;

import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.CanSetCapability;
import org.openqa.selenium.Capabilities;

import java.util.List;
import java.util.Optional;

public interface SupportsChromedriverArgsOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CHROMEDRIVER_ARGS_OPTION = "chromedriverArgs";

/**
* Array of chromedriver [command line
* arguments](http://www.assertselenium.com/java/list-of-chrome-driver-command-line-arguments/).
* Note, that not all command line arguments that are available for the desktop
* browser are also available for the mobile one.
*
* @param args Chromedriver command line arguments.
* @return self instance for chaining.
*/
default T setChromedriverArgs(List<String> args) {
return amend(CHROMEDRIVER_ARGS_OPTION, args);
}

/**
* Get the array of chromedriver CLI arguments.
*
* @return Arguments list.
*/
default Optional<List<String>> getChromedriverArgs() {
//noinspection unchecked
return Optional.ofNullable((List<String>) getCapability(CHROMEDRIVER_ARGS_OPTION));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.appium.java_client.android.options.context;

import io.appium.java_client.remote.options.BaseOptions;
import io.appium.java_client.remote.options.CanSetCapability;
import org.openqa.selenium.Capabilities;

import java.util.Optional;

public interface SupportsChromedriverChromeMappingFileOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CHROMEDRIVER_CHROME_MAPPING_FILE_OPTION = "chromedriverChromeMappingFile";

/**
* Full path to the chromedrivers mapping file. This file is used to statically
* map webview/browser versions to the chromedriver versions that are capable
* of automating them. Read [Automatic Chromedriver Discovery](https://github.com/
* appium/appium/blob/master/docs/en/writing-running-appium/web/
* chromedriver.md#automatic-discovery-of-compatible-chromedriver)
* article for more details.
*
* @param path Path to chromedrivers mapping file.
* @return self instance for chaining.
*/
default T setChromedriverChromeMappingFile(String path) {
return amend(CHROMEDRIVER_CHROME_MAPPING_FILE_OPTION, path);
}

/**
* Get full path to the chromedrivers mapping file is located.
*
* @return Path to chromedrivers mapping file.
*/
default Optional<String> getChromedriverChromeMappingFile() {
return Optional.ofNullable((String) getCapability(CHROMEDRIVER_CHROME_MAPPING_FILE_OPTION));
}
}
Loading