Skip to content

Commit

Permalink
feat: Add WebDriverAgent-related options of XCUITest driver (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Oct 27, 2021
1 parent 523d643 commit 29797ce
Show file tree
Hide file tree
Showing 23 changed files with 1,126 additions and 8 deletions.
Expand Up @@ -50,7 +50,7 @@
import io.appium.java_client.android.options.avd.SupportsAvdOption;
import io.appium.java_client.android.options.avd.SupportsAvdReadyTimeoutOption;
import io.appium.java_client.android.options.avd.SupportsGpsEnabledOption;
import io.appium.java_client.android.options.avd.SupportsIsHeadlessOption;
import io.appium.java_client.remote.options.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;
Expand Down
Expand Up @@ -22,6 +22,25 @@
import io.appium.java_client.ios.options.app.SupportsLocalizableStringsDirOption;
import io.appium.java_client.ios.options.general.SupportsIncludeDeviceCapsToSessionInfoOption;
import io.appium.java_client.ios.options.general.SupportsResetLocationServiceOption;
import io.appium.java_client.ios.options.simulator.SupportsCalendarAccessAuthorizedOption;
import io.appium.java_client.ios.options.simulator.SupportsCalendarFormatOption;
import io.appium.java_client.ios.options.simulator.SupportsConnectHardwareKeyboardOption;
import io.appium.java_client.ios.options.simulator.SupportsCustomSslCertOption;
import io.appium.java_client.ios.options.simulator.SupportsEnforceFreshSimulatorCreationOption;
import io.appium.java_client.ios.options.simulator.SupportsForceSimulatorSoftwareKeyboardPresenceOption;
import io.appium.java_client.ios.options.simulator.SupportsIosSimulatorLogsPredicateOption;
import io.appium.java_client.ios.options.simulator.SupportsKeepKeyChainsOption;
import io.appium.java_client.ios.options.simulator.SupportsKeychainsExcludePatternsOption;
import io.appium.java_client.ios.options.simulator.SupportsPermissionsOption;
import io.appium.java_client.ios.options.simulator.SupportsReduceMotionOption;
import io.appium.java_client.ios.options.simulator.SupportsScaleFactorOption;
import io.appium.java_client.ios.options.simulator.SupportsShutdownOtherSimulatorsOption;
import io.appium.java_client.ios.options.simulator.SupportsSimulatorDevicesSetPathOption;
import io.appium.java_client.ios.options.simulator.SupportsSimulatorPasteboardAutomaticSyncOption;
import io.appium.java_client.ios.options.simulator.SupportsSimulatorStartupTimeoutOption;
import io.appium.java_client.ios.options.simulator.SupportsSimulatorTracePointerOption;
import io.appium.java_client.ios.options.simulator.SupportsSimulatorWindowCenterOption;
import io.appium.java_client.ios.options.simulator.SupportsWebkitResponseTimeoutOption;
import io.appium.java_client.ios.options.wda.SupportsAllowProvisioningDeviceRegistrationOption;
import io.appium.java_client.ios.options.wda.SupportsAutoAcceptAlertsOption;
import io.appium.java_client.ios.options.wda.SupportsAutoDismissAlertsOption;
Expand Down Expand Up @@ -63,6 +82,7 @@
import io.appium.java_client.remote.options.SupportsClearSystemFilesOption;
import io.appium.java_client.remote.options.SupportsDeviceNameOption;
import io.appium.java_client.remote.options.SupportsEnablePerformanceLoggingOption;
import io.appium.java_client.remote.options.SupportsIsHeadlessOption;
import io.appium.java_client.remote.options.SupportsLanguageOption;
import io.appium.java_client.remote.options.SupportsLocaleOption;
import io.appium.java_client.remote.options.SupportsOrientationOption;
Expand Down Expand Up @@ -123,8 +143,28 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
SupportsShouldTerminateAppOption<XCUITestOptions>,
SupportsForceAppLaunchOption<XCUITestOptions>,
SupportsUseNativeCachingStrategyOption<XCUITestOptions>,
// TODO: Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
// Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
SupportsOrientationOption<XCUITestOptions>,
SupportsScaleFactorOption<XCUITestOptions>,
SupportsConnectHardwareKeyboardOption<XCUITestOptions>,
SupportsForceSimulatorSoftwareKeyboardPresenceOption<XCUITestOptions>,
SupportsCalendarAccessAuthorizedOption<XCUITestOptions>,
SupportsCalendarFormatOption<XCUITestOptions>,
SupportsIsHeadlessOption<XCUITestOptions>,
SupportsSimulatorWindowCenterOption<XCUITestOptions>,
SupportsSimulatorStartupTimeoutOption<XCUITestOptions>,
SupportsSimulatorTracePointerOption<XCUITestOptions>,
SupportsShutdownOtherSimulatorsOption<XCUITestOptions>,
SupportsEnforceFreshSimulatorCreationOption<XCUITestOptions>,
SupportsKeepKeyChainsOption<XCUITestOptions>,
SupportsKeychainsExcludePatternsOption<XCUITestOptions>,
SupportsReduceMotionOption<XCUITestOptions>,
SupportsPermissionsOption<XCUITestOptions>,
SupportsIosSimulatorLogsPredicateOption<XCUITestOptions>,
SupportsSimulatorPasteboardAutomaticSyncOption<XCUITestOptions>,
SupportsSimulatorDevicesSetPathOption<XCUITestOptions>,
SupportsCustomSslCertOption<XCUITestOptions>,
SupportsWebkitResponseTimeoutOption<XCUITestOptions>,
// TODO: Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
SupportsAutoWebViewOption<XCUITestOptions>,
// TODO: Other options: https://github.com/appium/appium-xcuitest-driver#other
Expand Down
@@ -0,0 +1,5 @@
package io.appium.java_client.ios.options.simulator;

public enum PasteboardSyncState {
ON, OFF, SYSTEM
}
@@ -0,0 +1,61 @@
/*
* 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.ios.options.simulator;

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;

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

public interface SupportsCalendarAccessAuthorizedOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CALENDAR_ACCESS_AUTHORIZED_OPTION = "calendarAccessAuthorized";

/**
* Enable calendar access on IOS Simulator.
*
* @return self instance for chaining.
*/
default T calendarAccessAuthorized() {
return amend(CALENDAR_ACCESS_AUTHORIZED_OPTION, true);
}

/**
* Set this to true if you want to enable calendar access on IOS Simulator
* with given bundleId. Set to false, if you want to disable calendar access
* on IOS Simulator with given bundleId. If not set, the calendar
* authorization status will not be set.
*
* @param value Whether to enable calendar access on IOS Simulator.
* @return self instance for chaining.
*/
default T setCalendarAccessAuthorized(boolean value) {
return amend(CALENDAR_ACCESS_AUTHORIZED_OPTION, value);
}

/**
* Get whether to enable calendar access on IOS Simulator.
*
* @return True or false.
*/
default Optional<Boolean> doesCalendarAccessAuthorized() {
return Optional.ofNullable(toSafeBoolean(getCapability(CALENDAR_ACCESS_AUTHORIZED_OPTION)));
}
}
@@ -0,0 +1,47 @@
/*
* 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.ios.options.simulator;

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 SupportsCalendarFormatOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CALENDAR_FORMAT_OPTION = "calendarFormat";

/**
* Set calendar format for the iOS Simulator.
*
* @param format Calendar format to set for the iOS Simulator.
* @return self instance for chaining.
*/
default T setCalendarFormat(String format) {
return amend(CALENDAR_FORMAT_OPTION, format);
}

/**
* Get calendar format to set for the iOS Simulator.
*
* @return Calendar format.
*/
default Optional<String> getCalendarFormat() {
return Optional.ofNullable((String) getCapability(CALENDAR_FORMAT_OPTION));
}
}
@@ -0,0 +1,63 @@
/*
* 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.ios.options.simulator;

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;

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

public interface SupportsConnectHardwareKeyboardOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CONNECT_HARDWARE_KEYBOARD_OPTION = "connectHardwareKeyboard";

/**
* Enforce connecting of hardware keyboard to Simulator.
*
* @return self instance for chaining.
*/
default T connectHardwareKeyboard() {
return amend(CONNECT_HARDWARE_KEYBOARD_OPTION, true);
}

/**
* Set this option to true in order to enable hardware keyboard in Simulator.
* The preference works only when Appium launches a simulator instance with
* this value. It is set to false by default, because this helps to workaround
* some XCTest bugs. connectHardwareKeyboard: true makes
* forceSimulatorSoftwareKeyboardPresence: false if no explicit value is set
* for forceSimulatorSoftwareKeyboardPresence capability since Appium 1.22.0.
*
* @param value Whether to connect hardware keyboard to Simulator.
* @return self instance for chaining.
*/
default T setConnectHardwareKeyboard(boolean value) {
return amend(CONNECT_HARDWARE_KEYBOARD_OPTION, value);
}

/**
* Get whether to connect hardware keyboard to Simulator.
*
* @return True or false.
*/
default Optional<Boolean> doesConnectHardwareKeyboard() {
return Optional.ofNullable(toSafeBoolean(getCapability(CONNECT_HARDWARE_KEYBOARD_OPTION)));
}
}
@@ -0,0 +1,48 @@
/*
* 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.ios.options.simulator;

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 SupportsCustomSslCertOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String CUSTOM_SSLCERT_OPTION = "customSSLCert";

/**
* Adds a root SSL certificate to IOS Simulator.
* The certificate content must be provided in PEM format.
*
* @param cert Certificate content in PEM format.
* @return self instance for chaining.
*/
default T setCustomSSLCert(String cert) {
return amend(CUSTOM_SSLCERT_OPTION, cert);
}

/**
* Get the SSL certificate content.
*
* @return Certificate content.
*/
default Optional<String> setCustomSSLCert() {
return Optional.ofNullable((String) getCapability(CUSTOM_SSLCERT_OPTION));
}
}
@@ -0,0 +1,59 @@
/*
* 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.ios.options.simulator;

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;

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

public interface SupportsEnforceFreshSimulatorCreationOption<T extends BaseOptions<T>> extends
Capabilities, CanSetCapability<T> {
String ENFORCE_FRESH_SIMULATOR_CREATION_OPTION = "enforceFreshSimulatorCreation";

/**
* Enforce creation of a new simulator for each new test session.
*
* @return self instance for chaining.
*/
default T enforceFreshSimulatorCreation() {
return amend(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION, true);
}

/**
* Creates a new simulator in session creation and deletes it in session deletion.
* Defaults to false.
*
* @param value Whether to create a new simulator for each new test session.
* @return self instance for chaining.
*/
default T setEnforceFreshSimulatorCreation(boolean value) {
return amend(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION, value);
}

/**
* Get whether to create a new simulator for each new test session.
*
* @return True or false.
*/
default Optional<Boolean> doesEnforceFreshSimulatorCreation() {
return Optional.ofNullable(toSafeBoolean(getCapability(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION)));
}
}

0 comments on commit 29797ce

Please sign in to comment.