Skip to content

Commit 255671d

Browse files
authored
feat: add webviewAtomWaitTimeout to control timeout for the atom execution (#2335)
* retry with reconnection * recovery with reconnection * add webviewAtomWaitTimeout * fix lint * >0 * correct docs * rever the retry * remove blank lines * use a ternary op
1 parent 7080c2d commit 255671d

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

docs/reference/capabilities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ about capabilities, refer to the [Appium documentation](https://appium.io/docs/e
126126
|`appium:safariWebInspectorMaxFrameLength`| The maximum size in bytes of a single data frame for the Web Inspector. Too high values could introduce slowness and/or memory leaks. Too low values could introduce possible buffer overflow exceptions. Defaults to 20MB (`20*1024*1024`) |`1024`, `100*1024*1024` |
127127
|`appium:additionalWebviewBundleIds`|Array (or JSON array) of possible bundle identifiers for webviews. This is sometimes necessary if the Web Inspector is found to be returning a modified bundle identifier for the app. If the value includes `*`, XCUITest driver will return all available webview contexts on the device. Defaults to `[]`|`["io.appium.modifiedId', 'ABCDEF"]`, `["*"]`|
128128
|`appium:webviewConnectTimeout`|The time to wait, in `ms`, for the initial presence of webviews in MobileSafari or hybrid apps. Defaults to `0`|`5000`|
129+
|`appium:webviewAtomWaitTimeout`|The time to wait, in `ms`, for each atom execution timeout of webviews in MobileSafari or hybrid apps. Defaults to `120000`. If the value was zero or less, the timeout keeps the default value. |`20000`|
129130
|`appium:safariIgnoreWebHostnames`| Provide a list of hostnames (comma-separated) that the Safari automation tools should ignore. This is to provide a workaround to prevent a webkit bug where the web context is unintentionally changed to a 3rd party website and the test gets stuck. The common culprits are search engines (yahoo, bing, google) and `about:blank` |`'www.yahoo.com, www.bing.com, www.google.com, about:blank'`|
130131
|`appium:nativeWebTap`| Enable native, non-javascript-based taps being in web context mode. Defaults to `false`. Warning: sometimes the preciseness of native taps could be broken, because there is no reliable way to map web element coordinates to native ones. | `true` |
131132
|`appium:nativeWebTapStrict`| Enabling this capability would skip the additional logic that tries to match web view elements to native ones by using their textual descriptions. Depending on the actual web view content this algorithm might sometimes be not very reliable and will slow down each click as we anyway fallback to the usual coordinates transformation flow if it fails. It is advised to enable strict tap if you use [mobile: calibrateWebToRealCoordinatesTranslation](./execute-methods.md#mobile-calibratewebtorealcoordinatestranslation) extension. Only applicable if `nativeWebTap` is enabled. `false` by default | `true` |

lib/commands/web.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,12 @@ const extensions = {
773773
async waitForAtom(promise) {
774774
const timer = new timing.Timer().start();
775775

776+
const atomWaitTimeoutMs = _.isNumber(this.opts.webviewAtomWaitTimeout) && this.opts.webviewAtomWaitTimeout > 0
777+
? this.opts.webviewAtomWaitTimeout
778+
: ATOM_WAIT_TIMEOUT_MS;
776779
// need to check for alert while the atom is being executed.
777780
// so notify ourselves when it happens
778-
const timedAtomPromise = B.resolve(promise).timeout(ATOM_WAIT_TIMEOUT_MS);
781+
const timedAtomPromise = B.resolve(promise).timeout(atomWaitTimeoutMs);
779782
const handlePromiseError = async (p) => {
780783
try {
781784
return await p;

lib/desired-caps.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ const desiredCapConstraints = /** @type {const} */ ({
306306
webviewConnectTimeout: {
307307
isNumber: true,
308308
},
309+
webviewAtomWaitTimeout: {
310+
isNumber: true,
311+
},
309312
iosSimulatorLogsPredicate: {
310313
isString: true,
311314
},

0 commit comments

Comments
 (0)