Skip to content

Commit 29797ce

Browse files
feat: Add WebDriverAgent-related options of XCUITest driver (appium#1554)
1 parent 523d643 commit 29797ce

23 files changed

+1126
-8
lines changed

src/main/java/io/appium/java_client/android/options/UiAutomator2Options.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import io.appium.java_client.android.options.avd.SupportsAvdOption;
5151
import io.appium.java_client.android.options.avd.SupportsAvdReadyTimeoutOption;
5252
import io.appium.java_client.android.options.avd.SupportsGpsEnabledOption;
53-
import io.appium.java_client.android.options.avd.SupportsIsHeadlessOption;
53+
import io.appium.java_client.remote.options.SupportsIsHeadlessOption;
5454
import io.appium.java_client.android.options.avd.SupportsNetworkSpeedOption;
5555
import io.appium.java_client.android.options.context.SupportsAutoWebviewTimeoutOption;
5656
import io.appium.java_client.android.options.context.SupportsChromeLoggingPrefsOption;

src/main/java/io/appium/java_client/ios/options/XCUITestOptions.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@
2222
import io.appium.java_client.ios.options.app.SupportsLocalizableStringsDirOption;
2323
import io.appium.java_client.ios.options.general.SupportsIncludeDeviceCapsToSessionInfoOption;
2424
import io.appium.java_client.ios.options.general.SupportsResetLocationServiceOption;
25+
import io.appium.java_client.ios.options.simulator.SupportsCalendarAccessAuthorizedOption;
26+
import io.appium.java_client.ios.options.simulator.SupportsCalendarFormatOption;
27+
import io.appium.java_client.ios.options.simulator.SupportsConnectHardwareKeyboardOption;
28+
import io.appium.java_client.ios.options.simulator.SupportsCustomSslCertOption;
29+
import io.appium.java_client.ios.options.simulator.SupportsEnforceFreshSimulatorCreationOption;
30+
import io.appium.java_client.ios.options.simulator.SupportsForceSimulatorSoftwareKeyboardPresenceOption;
31+
import io.appium.java_client.ios.options.simulator.SupportsIosSimulatorLogsPredicateOption;
32+
import io.appium.java_client.ios.options.simulator.SupportsKeepKeyChainsOption;
33+
import io.appium.java_client.ios.options.simulator.SupportsKeychainsExcludePatternsOption;
34+
import io.appium.java_client.ios.options.simulator.SupportsPermissionsOption;
35+
import io.appium.java_client.ios.options.simulator.SupportsReduceMotionOption;
36+
import io.appium.java_client.ios.options.simulator.SupportsScaleFactorOption;
37+
import io.appium.java_client.ios.options.simulator.SupportsShutdownOtherSimulatorsOption;
38+
import io.appium.java_client.ios.options.simulator.SupportsSimulatorDevicesSetPathOption;
39+
import io.appium.java_client.ios.options.simulator.SupportsSimulatorPasteboardAutomaticSyncOption;
40+
import io.appium.java_client.ios.options.simulator.SupportsSimulatorStartupTimeoutOption;
41+
import io.appium.java_client.ios.options.simulator.SupportsSimulatorTracePointerOption;
42+
import io.appium.java_client.ios.options.simulator.SupportsSimulatorWindowCenterOption;
43+
import io.appium.java_client.ios.options.simulator.SupportsWebkitResponseTimeoutOption;
2544
import io.appium.java_client.ios.options.wda.SupportsAllowProvisioningDeviceRegistrationOption;
2645
import io.appium.java_client.ios.options.wda.SupportsAutoAcceptAlertsOption;
2746
import io.appium.java_client.ios.options.wda.SupportsAutoDismissAlertsOption;
@@ -63,6 +82,7 @@
6382
import io.appium.java_client.remote.options.SupportsClearSystemFilesOption;
6483
import io.appium.java_client.remote.options.SupportsDeviceNameOption;
6584
import io.appium.java_client.remote.options.SupportsEnablePerformanceLoggingOption;
85+
import io.appium.java_client.remote.options.SupportsIsHeadlessOption;
6686
import io.appium.java_client.remote.options.SupportsLanguageOption;
6787
import io.appium.java_client.remote.options.SupportsLocaleOption;
6888
import io.appium.java_client.remote.options.SupportsOrientationOption;
@@ -123,8 +143,28 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
123143
SupportsShouldTerminateAppOption<XCUITestOptions>,
124144
SupportsForceAppLaunchOption<XCUITestOptions>,
125145
SupportsUseNativeCachingStrategyOption<XCUITestOptions>,
126-
// TODO: Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
146+
// Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
127147
SupportsOrientationOption<XCUITestOptions>,
148+
SupportsScaleFactorOption<XCUITestOptions>,
149+
SupportsConnectHardwareKeyboardOption<XCUITestOptions>,
150+
SupportsForceSimulatorSoftwareKeyboardPresenceOption<XCUITestOptions>,
151+
SupportsCalendarAccessAuthorizedOption<XCUITestOptions>,
152+
SupportsCalendarFormatOption<XCUITestOptions>,
153+
SupportsIsHeadlessOption<XCUITestOptions>,
154+
SupportsSimulatorWindowCenterOption<XCUITestOptions>,
155+
SupportsSimulatorStartupTimeoutOption<XCUITestOptions>,
156+
SupportsSimulatorTracePointerOption<XCUITestOptions>,
157+
SupportsShutdownOtherSimulatorsOption<XCUITestOptions>,
158+
SupportsEnforceFreshSimulatorCreationOption<XCUITestOptions>,
159+
SupportsKeepKeyChainsOption<XCUITestOptions>,
160+
SupportsKeychainsExcludePatternsOption<XCUITestOptions>,
161+
SupportsReduceMotionOption<XCUITestOptions>,
162+
SupportsPermissionsOption<XCUITestOptions>,
163+
SupportsIosSimulatorLogsPredicateOption<XCUITestOptions>,
164+
SupportsSimulatorPasteboardAutomaticSyncOption<XCUITestOptions>,
165+
SupportsSimulatorDevicesSetPathOption<XCUITestOptions>,
166+
SupportsCustomSslCertOption<XCUITestOptions>,
167+
SupportsWebkitResponseTimeoutOption<XCUITestOptions>,
128168
// TODO: Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
129169
SupportsAutoWebViewOption<XCUITestOptions>,
130170
// TODO: Other options: https://github.com/appium/appium-xcuitest-driver#other
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.appium.java_client.ios.options.simulator;
2+
3+
public enum PasteboardSyncState {
4+
ON, OFF, SYSTEM
5+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.simulator;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;
26+
27+
public interface SupportsCalendarAccessAuthorizedOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String CALENDAR_ACCESS_AUTHORIZED_OPTION = "calendarAccessAuthorized";
30+
31+
/**
32+
* Enable calendar access on IOS Simulator.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T calendarAccessAuthorized() {
37+
return amend(CALENDAR_ACCESS_AUTHORIZED_OPTION, true);
38+
}
39+
40+
/**
41+
* Set this to true if you want to enable calendar access on IOS Simulator
42+
* with given bundleId. Set to false, if you want to disable calendar access
43+
* on IOS Simulator with given bundleId. If not set, the calendar
44+
* authorization status will not be set.
45+
*
46+
* @param value Whether to enable calendar access on IOS Simulator.
47+
* @return self instance for chaining.
48+
*/
49+
default T setCalendarAccessAuthorized(boolean value) {
50+
return amend(CALENDAR_ACCESS_AUTHORIZED_OPTION, value);
51+
}
52+
53+
/**
54+
* Get whether to enable calendar access on IOS Simulator.
55+
*
56+
* @return True or false.
57+
*/
58+
default Optional<Boolean> doesCalendarAccessAuthorized() {
59+
return Optional.ofNullable(toSafeBoolean(getCapability(CALENDAR_ACCESS_AUTHORIZED_OPTION)));
60+
}
61+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.simulator;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
public interface SupportsCalendarFormatOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String CALENDAR_FORMAT_OPTION = "calendarFormat";
28+
29+
/**
30+
* Set calendar format for the iOS Simulator.
31+
*
32+
* @param format Calendar format to set for the iOS Simulator.
33+
* @return self instance for chaining.
34+
*/
35+
default T setCalendarFormat(String format) {
36+
return amend(CALENDAR_FORMAT_OPTION, format);
37+
}
38+
39+
/**
40+
* Get calendar format to set for the iOS Simulator.
41+
*
42+
* @return Calendar format.
43+
*/
44+
default Optional<String> getCalendarFormat() {
45+
return Optional.ofNullable((String) getCapability(CALENDAR_FORMAT_OPTION));
46+
}
47+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.simulator;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;
26+
27+
public interface SupportsConnectHardwareKeyboardOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String CONNECT_HARDWARE_KEYBOARD_OPTION = "connectHardwareKeyboard";
30+
31+
/**
32+
* Enforce connecting of hardware keyboard to Simulator.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T connectHardwareKeyboard() {
37+
return amend(CONNECT_HARDWARE_KEYBOARD_OPTION, true);
38+
}
39+
40+
/**
41+
* Set this option to true in order to enable hardware keyboard in Simulator.
42+
* The preference works only when Appium launches a simulator instance with
43+
* this value. It is set to false by default, because this helps to workaround
44+
* some XCTest bugs. connectHardwareKeyboard: true makes
45+
* forceSimulatorSoftwareKeyboardPresence: false if no explicit value is set
46+
* for forceSimulatorSoftwareKeyboardPresence capability since Appium 1.22.0.
47+
*
48+
* @param value Whether to connect hardware keyboard to Simulator.
49+
* @return self instance for chaining.
50+
*/
51+
default T setConnectHardwareKeyboard(boolean value) {
52+
return amend(CONNECT_HARDWARE_KEYBOARD_OPTION, value);
53+
}
54+
55+
/**
56+
* Get whether to connect hardware keyboard to Simulator.
57+
*
58+
* @return True or false.
59+
*/
60+
default Optional<Boolean> doesConnectHardwareKeyboard() {
61+
return Optional.ofNullable(toSafeBoolean(getCapability(CONNECT_HARDWARE_KEYBOARD_OPTION)));
62+
}
63+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.simulator;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
public interface SupportsCustomSslCertOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String CUSTOM_SSLCERT_OPTION = "customSSLCert";
28+
29+
/**
30+
* Adds a root SSL certificate to IOS Simulator.
31+
* The certificate content must be provided in PEM format.
32+
*
33+
* @param cert Certificate content in PEM format.
34+
* @return self instance for chaining.
35+
*/
36+
default T setCustomSSLCert(String cert) {
37+
return amend(CUSTOM_SSLCERT_OPTION, cert);
38+
}
39+
40+
/**
41+
* Get the SSL certificate content.
42+
*
43+
* @return Certificate content.
44+
*/
45+
default Optional<String> setCustomSSLCert() {
46+
return Optional.ofNullable((String) getCapability(CUSTOM_SSLCERT_OPTION));
47+
}
48+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* See the NOTICE file distributed with this work for additional
5+
* information regarding copyright ownership.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.appium.java_client.ios.options.simulator;
18+
19+
import io.appium.java_client.remote.options.BaseOptions;
20+
import io.appium.java_client.remote.options.CanSetCapability;
21+
import org.openqa.selenium.Capabilities;
22+
23+
import java.util.Optional;
24+
25+
import static io.appium.java_client.internal.CapabilityHelpers.toSafeBoolean;
26+
27+
public interface SupportsEnforceFreshSimulatorCreationOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String ENFORCE_FRESH_SIMULATOR_CREATION_OPTION = "enforceFreshSimulatorCreation";
30+
31+
/**
32+
* Enforce creation of a new simulator for each new test session.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T enforceFreshSimulatorCreation() {
37+
return amend(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION, true);
38+
}
39+
40+
/**
41+
* Creates a new simulator in session creation and deletes it in session deletion.
42+
* Defaults to false.
43+
*
44+
* @param value Whether to create a new simulator for each new test session.
45+
* @return self instance for chaining.
46+
*/
47+
default T setEnforceFreshSimulatorCreation(boolean value) {
48+
return amend(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION, value);
49+
}
50+
51+
/**
52+
* Get whether to create a new simulator for each new test session.
53+
*
54+
* @return True or false.
55+
*/
56+
default Optional<Boolean> doesEnforceFreshSimulatorCreation() {
57+
return Optional.ofNullable(toSafeBoolean(getCapability(ENFORCE_FRESH_SIMULATOR_CREATION_OPTION)));
58+
}
59+
}

0 commit comments

Comments
 (0)