Skip to content

Commit 0a12636

Browse files
feat: Add web view options for XCUITest driver (#1557)
1 parent da8fde2 commit 0a12636

21 files changed

+1175
-2
lines changed

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

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@
7474
import io.appium.java_client.ios.options.wda.SupportsWdaStartupRetryIntervalOption;
7575
import io.appium.java_client.ios.options.wda.SupportsWebDriverAgentUrlOption;
7676
import io.appium.java_client.ios.options.wda.SupportsXcodeCertificateOptions;
77+
import io.appium.java_client.ios.options.webview.SupportsAbsoluteWebLocationsOption;
78+
import io.appium.java_client.ios.options.webview.SupportsAdditionalWebviewBundleIdsOption;
79+
import io.appium.java_client.ios.options.webview.SupportsEnableAsyncExecuteFromHttpsOption;
80+
import io.appium.java_client.ios.options.webview.SupportsFullContextListOption;
81+
import io.appium.java_client.ios.options.webview.SupportsIncludeSafariInWebviewsOption;
82+
import io.appium.java_client.ios.options.webview.SupportsNativeWebTapOption;
83+
import io.appium.java_client.ios.options.webview.SupportsNativeWebTapStrictOption;
84+
import io.appium.java_client.ios.options.webview.SupportsSafariAllowPopupsOption;
85+
import io.appium.java_client.ios.options.webview.SupportsSafariGarbageCollectOption;
86+
import io.appium.java_client.ios.options.webview.SupportsSafariIgnoreFraudWarningOption;
87+
import io.appium.java_client.ios.options.webview.SupportsSafariIgnoreWebHostnamesOption;
88+
import io.appium.java_client.ios.options.webview.SupportsSafariInitialUrlOption;
89+
import io.appium.java_client.ios.options.webview.SupportsSafariLogAllCommunicationHexDumpOption;
90+
import io.appium.java_client.ios.options.webview.SupportsSafariLogAllCommunicationOption;
91+
import io.appium.java_client.ios.options.webview.SupportsSafariOpenLinksInBackgroundOption;
92+
import io.appium.java_client.ios.options.webview.SupportsSafariSocketChunkSizeOption;
93+
import io.appium.java_client.ios.options.webview.SupportsSafariWebInspectorMaxFrameLengthOption;
94+
import io.appium.java_client.ios.options.webview.SupportsWebviewConnectRetriesOption;
95+
import io.appium.java_client.ios.options.webview.SupportsWebviewConnectTimeoutOption;
7796
import io.appium.java_client.remote.AutomationName;
7897
import io.appium.java_client.remote.MobilePlatform;
7998
import io.appium.java_client.remote.options.BaseOptions;
@@ -164,9 +183,28 @@ public class XCUITestOptions extends BaseOptions<XCUITestOptions> implements
164183
SupportsSimulatorPasteboardAutomaticSyncOption<XCUITestOptions>,
165184
SupportsSimulatorDevicesSetPathOption<XCUITestOptions>,
166185
SupportsCustomSslCertOption<XCUITestOptions>,
167-
SupportsWebkitResponseTimeoutOption<XCUITestOptions>,
168-
// TODO: Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
186+
// Web context options: https://github.com/appium/appium-xcuitest-driver#web-context
169187
SupportsAutoWebViewOption<XCUITestOptions>,
188+
SupportsAbsoluteWebLocationsOption<XCUITestOptions>,
189+
SupportsSafariGarbageCollectOption<XCUITestOptions>,
190+
SupportsIncludeSafariInWebviewsOption<XCUITestOptions>,
191+
SupportsSafariLogAllCommunicationOption<XCUITestOptions>,
192+
SupportsSafariLogAllCommunicationHexDumpOption<XCUITestOptions>,
193+
SupportsSafariSocketChunkSizeOption<XCUITestOptions>,
194+
SupportsSafariWebInspectorMaxFrameLengthOption<XCUITestOptions>,
195+
SupportsAdditionalWebviewBundleIdsOption<XCUITestOptions>,
196+
SupportsWebviewConnectTimeoutOption<XCUITestOptions>,
197+
SupportsSafariIgnoreWebHostnamesOption<XCUITestOptions>,
198+
SupportsNativeWebTapOption<XCUITestOptions>,
199+
SupportsNativeWebTapStrictOption<XCUITestOptions>,
200+
SupportsSafariInitialUrlOption<XCUITestOptions>,
201+
SupportsSafariAllowPopupsOption<XCUITestOptions>,
202+
SupportsSafariIgnoreFraudWarningOption<XCUITestOptions>,
203+
SupportsSafariOpenLinksInBackgroundOption<XCUITestOptions>,
204+
SupportsWebviewConnectRetriesOption<XCUITestOptions>,
205+
SupportsWebkitResponseTimeoutOption<XCUITestOptions>,
206+
SupportsEnableAsyncExecuteFromHttpsOption<XCUITestOptions>,
207+
SupportsFullContextListOption<XCUITestOptions>,
170208
// TODO: Other options: https://github.com/appium/appium-xcuitest-driver#other
171209
SupportsClearSystemFilesOption<XCUITestOptions>,
172210
SupportsEnablePerformanceLoggingOption<XCUITestOptions> {
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.webview;
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 SupportsAbsoluteWebLocationsOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String ABSOLUTE_WEB_LOCATIONS_OPTION = "absoluteWebLocations";
30+
31+
/**
32+
* Enforces Get Element Location to return coordinates
33+
* relative to the page origin for web view elements.
34+
*
35+
* @return self instance for chaining.
36+
*/
37+
default T absoluteWebLocations() {
38+
return amend(ABSOLUTE_WEB_LOCATIONS_OPTION, true);
39+
}
40+
41+
/**
42+
* This capability will direct the Get Element Location command, when used
43+
* within webviews, to return coordinates which are relative to the origin of
44+
* the page, rather than relative to the current scroll offset. This capability
45+
* has no effect outside of webviews. Default false.
46+
*
47+
* @param value Whether to return coordinates relative to the page origin for web view elements.
48+
* @return self instance for chaining.
49+
*/
50+
default T setAbsoluteWebLocations(boolean value) {
51+
return amend(ABSOLUTE_WEB_LOCATIONS_OPTION, value);
52+
}
53+
54+
/**
55+
* Get whether Get Element Location returns coordinates
56+
* relative to the page origin for web view elements.
57+
*
58+
* @return True or false.
59+
*/
60+
default Optional<Boolean> doesAbsoluteWebLocations() {
61+
return Optional.ofNullable(toSafeBoolean(getCapability(ABSOLUTE_WEB_LOCATIONS_OPTION)));
62+
}
63+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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.webview;
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.List;
24+
import java.util.Optional;
25+
26+
public interface SupportsAdditionalWebviewBundleIdsOption<T extends BaseOptions<T>> extends
27+
Capabilities, CanSetCapability<T> {
28+
String ADDITIONAL_WEBVIEW_BUNDLE_IDS_OPTION = "additionalWebviewBundleIds";
29+
30+
/**
31+
* Array of possible bundle identifiers for webviews. This is sometimes
32+
* necessary if the Web Inspector is found to be returning a modified
33+
* bundle identifier for the app. Defaults to [].
34+
*
35+
* @param identifiers Identifiers list.
36+
* @return self instance for chaining.
37+
*/
38+
default T setAdditionalWebviewBundleIds(List<String> identifiers) {
39+
return amend(ADDITIONAL_WEBVIEW_BUNDLE_IDS_OPTION, identifiers);
40+
}
41+
42+
/**
43+
* Get the array of possible bundle identifiers for webviews.
44+
*
45+
* @return Identifier list.
46+
*/
47+
default Optional<List<String>> getAdditionalWebviewBundleIds() {
48+
//noinspection unchecked
49+
return Optional.ofNullable(
50+
(List<String>) getCapability(ADDITIONAL_WEBVIEW_BUNDLE_IDS_OPTION)
51+
);
52+
}
53+
}
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.webview;
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 SupportsEnableAsyncExecuteFromHttpsOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String ENABLE_ASYNC_EXECUTE_FROM_HTTPS_OPTION = "enableAsyncExecuteFromHttps";
30+
31+
/**
32+
* Enforces to allow simulators to execute async JavaScript on pages using HTTPS.
33+
*
34+
* @return self instance for chaining.
35+
*/
36+
default T enableAsyncExecuteFromHttps() {
37+
return amend(ENABLE_ASYNC_EXECUTE_FROM_HTTPS_OPTION, true);
38+
}
39+
40+
/**
41+
* Capability to allow simulators to execute asynchronous JavaScript
42+
* on pages using HTTPS. Defaults to false.
43+
*
44+
* @param value Whether to allow simulators to execute async JavaScript on pages using HTTPS.
45+
* @return self instance for chaining.
46+
*/
47+
default T setEnableAsyncExecuteFromHttps(boolean value) {
48+
return amend(ENABLE_ASYNC_EXECUTE_FROM_HTTPS_OPTION, value);
49+
}
50+
51+
/**
52+
* Get whether to allow simulators to execute async JavaScript on pages using HTTPS.
53+
*
54+
* @return True or false.
55+
*/
56+
default Optional<Boolean> doesEnableAsyncExecuteFromHttps() {
57+
return Optional.ofNullable(toSafeBoolean(getCapability(ENABLE_ASYNC_EXECUTE_FROM_HTTPS_OPTION)));
58+
}
59+
}
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.webview;
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 SupportsFullContextListOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String FULL_CONTEXT_LIST_OPTION = "fullContextList";
30+
31+
/**
32+
* Enforces to return the detailed information on contexts for the get available
33+
* context command.
34+
*
35+
* @return self instance for chaining.
36+
*/
37+
default T fullContextList() {
38+
return amend(FULL_CONTEXT_LIST_OPTION, true);
39+
}
40+
41+
/**
42+
* Sets to return the detailed information on contexts for the get available
43+
* context command. If this capability is enabled, then each item in the returned
44+
* contexts list would additionally include WebView title, full URL and the bundle
45+
* identifier. Defaults to false.
46+
*
47+
* @param value Whether to return the detailed info on available context command.
48+
* @return self instance for chaining.
49+
*/
50+
default T setFullContextList(boolean value) {
51+
return amend(FULL_CONTEXT_LIST_OPTION, value);
52+
}
53+
54+
/**
55+
* Get whether to return the detailed information on contexts for the get available
56+
* context command.
57+
*
58+
* @return True or false.
59+
*/
60+
default Optional<Boolean> doesFullContextList() {
61+
return Optional.ofNullable(toSafeBoolean(getCapability(FULL_CONTEXT_LIST_OPTION)));
62+
}
63+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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.webview;
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 SupportsIncludeSafariInWebviewsOption<T extends BaseOptions<T>> extends
28+
Capabilities, CanSetCapability<T> {
29+
String INCLUDE_SAFARI_IN_WEBVIEWS_OPTION = "includeSafariInWebviews";
30+
31+
/**
32+
* Enforces Safari web views to be added to the list of contexts available
33+
* during a native/webview app test.
34+
*
35+
* @return self instance for chaining.
36+
*/
37+
default T includeSafariInWebviews() {
38+
return amend(INCLUDE_SAFARI_IN_WEBVIEWS_OPTION, true);
39+
}
40+
41+
/**
42+
* Add Safari web contexts to the list of contexts available during a
43+
* native/webview app test. This is useful if the test opens Safari and
44+
* needs to be able to interact with it. Defaults to false.
45+
*
46+
* @param value Whether to add Safari to the list of contexts available during a native/webview app test.
47+
* @return self instance for chaining.
48+
*/
49+
default T setIncludeSafariInWebviews(boolean value) {
50+
return amend(INCLUDE_SAFARI_IN_WEBVIEWS_OPTION, value);
51+
}
52+
53+
/**
54+
* Get whether to add Safari web views to the list of contexts available
55+
* during a native/webview app test.
56+
*
57+
* @return True or false.
58+
*/
59+
default Optional<Boolean> doesIncludeSafariInWebviews() {
60+
return Optional.ofNullable(toSafeBoolean(getCapability(INCLUDE_SAFARI_IN_WEBVIEWS_OPTION)));
61+
}
62+
}

0 commit comments

Comments
 (0)