Skip to content

Commit 8d99d4c

Browse files
chore: Start adding XCUITest driver options (#1551)
1 parent 4d944ae commit 8d99d4c

8 files changed

+368
-7
lines changed

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

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
package io.appium.java_client.ios.options;
1818

19+
import io.appium.java_client.ios.options.app.SupportsAppInstallStrategyOption;
20+
import io.appium.java_client.ios.options.app.SupportsAppPushTimeoutOption;
21+
import io.appium.java_client.ios.options.app.SupportsBundleIdOption;
22+
import io.appium.java_client.ios.options.app.SupportsLocalizableStringsDirOption;
23+
import io.appium.java_client.ios.options.general.SupportsIncludeDeviceCapsToSessionInfoOption;
24+
import io.appium.java_client.ios.options.general.SupportsResetLocationServiceOption;
1925
import io.appium.java_client.remote.AutomationName;
2026
import io.appium.java_client.remote.MobilePlatform;
2127
import io.appium.java_client.remote.options.BaseOptions;
@@ -31,12 +37,34 @@
3137
import io.appium.java_client.remote.options.SupportsUdidOption;
3238
import org.openqa.selenium.Capabilities;
3339

40+
/**
41+
* https://github.com/appium/appium-xcuitest-driver#capabilities
42+
*/
3443
public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
35-
SupportsAppOption<XCUITestOptions>, SupportsAutoWebViewOption<XCUITestOptions>,
36-
SupportsClearSystemFilesOption<XCUITestOptions>, SupportsDeviceNameOption<XCUITestOptions>,
37-
SupportsEnablePerformanceLoggingOption<XCUITestOptions>, SupportsLanguageOption<XCUITestOptions>,
38-
SupportsLocaleOption<XCUITestOptions>, SupportsOrientationOption<XCUITestOptions>,
39-
SupportsOtherAppsOption<XCUITestOptions>, SupportsUdidOption<XCUITestOptions> {
44+
// General options: https://github.com/appium/appium-xcuitest-driver#general
45+
SupportsDeviceNameOption<XCUITestOptions>,
46+
SupportsUdidOption<XCUITestOptions>,
47+
SupportsIncludeDeviceCapsToSessionInfoOption<XCUITestOptions>,
48+
SupportsResetLocationServiceOption<XCUITestOptions>,
49+
// Localization Options
50+
SupportsLocalizableStringsDirOption<XCUITestOptions>,
51+
SupportsLanguageOption<XCUITestOptions>,
52+
SupportsLocaleOption<XCUITestOptions>,
53+
// App Options: https://github.com/appium/appium-xcuitest-driver#app
54+
SupportsAppOption<XCUITestOptions>,
55+
SupportsBundleIdOption<XCUITestOptions>,
56+
SupportsOtherAppsOption<XCUITestOptions>,
57+
SupportsAppPushTimeoutOption<XCUITestOptions>,
58+
SupportsAppInstallStrategyOption<XCUITestOptions>,
59+
// TODO: WebDriverAgent options: https://github.com/appium/appium-xcuitest-driver#webdriveragent
60+
// TODO: Simulator options: https://github.com/appium/appium-xcuitest-driver#simulator
61+
SupportsOrientationOption<XCUITestOptions>,
62+
// TODO: Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
63+
SupportsAutoWebViewOption<XCUITestOptions>,
64+
// TODO: Other options: https://github.com/appium/appium-xcuitest-driver#other
65+
SupportsClearSystemFilesOption<XCUITestOptions>,
66+
SupportsEnablePerformanceLoggingOption<XCUITestOptions> {
67+
4068
public XCUITestOptions() {
4169
setCommonOptions();
4270
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.app;
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 SupportsAppInstallStrategyOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String APP_INSTALL_STRATEGY_OPTION = "appInstallStrategy";
28+
29+
/**
30+
* Select application installation strategy for real devices. The following
31+
* strategies are supported:
32+
*
33+
* serial (default) - pushes app files to the device in a sequential order;
34+
* this is the least performant strategy, although the most reliable;
35+
*
36+
* parallel - pushes app files simultaneously; this is usually the
37+
* most performant strategy, but sometimes could not be very stable;
38+
*
39+
* ios-deploy - tells the driver to use a third-party tool ios-deploy to
40+
* install the app; obviously the tool must be installed separately
41+
* first and must be present in PATH before it could be used.
42+
*
43+
* @param strategy App installation strategy.
44+
* @return self instance for chaining.
45+
*/
46+
default T setAppInstallStrategy(String strategy) {
47+
return amend(APP_INSTALL_STRATEGY_OPTION, strategy);
48+
}
49+
50+
/**
51+
* Get the app install strategy.
52+
*
53+
* @return App installation strategy.
54+
*/
55+
default Optional<String> getAppInstallStrategy() {
56+
return Optional.ofNullable((String) getCapability(APP_INSTALL_STRATEGY_OPTION));
57+
}
58+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.app;
18+
19+
import io.appium.java_client.internal.CapabilityHelpers;
20+
import io.appium.java_client.remote.options.BaseOptions;
21+
import io.appium.java_client.remote.options.CanSetCapability;
22+
import org.openqa.selenium.Capabilities;
23+
24+
import java.time.Duration;
25+
import java.util.Optional;
26+
27+
public interface SupportsAppPushTimeoutOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String APP_PUSH_TIMEOUT_OPTION = "appPushTimeout";
30+
31+
/**
32+
* The timeout for application upload.
33+
* Works for real devices only. The default value is 30000ms.
34+
*
35+
* @param timeout App push timeout.
36+
* @return self instance for chaining.
37+
*/
38+
default T setAppPushTimeout(Duration timeout) {
39+
return amend(APP_PUSH_TIMEOUT_OPTION, timeout.toMillis());
40+
}
41+
42+
/**
43+
* Get maximum timeout for application upload.
44+
*
45+
* @return Timeout value.
46+
*/
47+
default Optional<Duration> getAppPushTimeout() {
48+
return Optional.ofNullable(
49+
CapabilityHelpers.toDuration(getCapability(APP_PUSH_TIMEOUT_OPTION))
50+
);
51+
}
52+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.app;
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 SupportsBundleIdOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String BUNDLE_ID_OPTION = "bundleId";
28+
29+
/**
30+
* Bundle identifier of the app under test, for example com.mycompany.myapp.
31+
* The capability value is calculated automatically if app is provided.
32+
* If neither app nor bundleId capability is provided then XCUITest driver
33+
* starts from the Home screen.
34+
*
35+
* @param identifier App identifier.
36+
* @return self instance for chaining.
37+
*/
38+
default T setBundleId(String identifier) {
39+
return amend(BUNDLE_ID_OPTION, identifier);
40+
}
41+
42+
/**
43+
* Get the app bundle identifier.
44+
*
45+
* @return Identifier value.
46+
*/
47+
default Optional<String> getBundleId() {
48+
return Optional.ofNullable((String) getCapability(BUNDLE_ID_OPTION));
49+
}
50+
}
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.app;
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 SupportsLocalizableStringsDirOption<T extends BaseOptions<T>> extends
26+
Capabilities, CanSetCapability<T> {
27+
String LOCALIZABLE_STRINGS_DIR_OPTION = "localizableStringsDir";
28+
29+
/**
30+
* Where to look for localizable strings in the application bundle.
31+
* Defaults to en.lproj.
32+
*
33+
* @param folder The resource folder name where the main locale strings are stored.
34+
* @return self instance for chaining.
35+
*/
36+
default T setLocalizableStringsDir(String folder) {
37+
return amend(LOCALIZABLE_STRINGS_DIR_OPTION, folder);
38+
}
39+
40+
/**
41+
* Get the resource folder name where the main locale strings are stored.
42+
*
43+
* @return Folder name.
44+
*/
45+
default Optional<String> getLocalizableStringsDir() {
46+
return Optional.ofNullable((String) getCapability(LOCALIZABLE_STRINGS_DIR_OPTION));
47+
}
48+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.general;
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 SupportsIncludeDeviceCapsToSessionInfoOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String INCLUDE_DEVICE_CAPS_TO_SESSION_INFO_OPTION = "includeDeviceCapsToSessionInfo";
30+
31+
/**
32+
* Whether to include screen information as the result of Get Session Capabilities.
33+
* It includes pixelRatio, statBarHeight and viewportRect, but
34+
* it causes an extra API call to WDA which may increase the response time.
35+
* Defaults to true.
36+
*
37+
* @param value Whether to include screen information as the result of Get Session Capabilities.
38+
* @return self instance for chaining.
39+
*/
40+
default T setIncludeDeviceCapsToSessionInfo(boolean value) {
41+
return amend(INCLUDE_DEVICE_CAPS_TO_SESSION_INFO_OPTION, value);
42+
}
43+
44+
/**
45+
* Get whether to include screen information as the result of Get Session Capabilities.
46+
*
47+
* @return True or false.
48+
*/
49+
default Optional<Boolean> doesIncludeDeviceCapsToSessionInfo() {
50+
return Optional.ofNullable(toSafeBoolean(getCapability(INCLUDE_DEVICE_CAPS_TO_SESSION_INFO_OPTION)));
51+
}
52+
}
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.general;
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 SupportsResetLocationServiceOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String RESET_LOCATION_SERVICE_OPTION = "resetLocationService";
30+
31+
/**
32+
* Set to reset the location service in the session deletion on real device.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T resetLocationService() {
37+
return amend(RESET_LOCATION_SERVICE_OPTION, true);
38+
}
39+
40+
/**
41+
* Whether reset the location service in the session deletion on real device.
42+
* Defaults to false.
43+
*
44+
* @param value Whether to reset the location service in the session deletion on real device.
45+
* @return self instance for chaining.
46+
*/
47+
default T setResetLocationService(boolean value) {
48+
return amend(RESET_LOCATION_SERVICE_OPTION, value);
49+
}
50+
51+
/**
52+
* Get whether to reset the location service in the session deletion on real device.
53+
*
54+
* @return True or false.
55+
*/
56+
default Optional<Boolean> doesResetLocationService() {
57+
return Optional.ofNullable(toSafeBoolean(getCapability(RESET_LOCATION_SERVICE_OPTION)));
58+
}
59+
}

0 commit comments

Comments
 (0)