From 1a14a13858a69c89a5e13e82318a67bae0878393 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Tue, 6 Aug 2024 08:56:19 +0200 Subject: [PATCH] fix: Do not try to set the default URL using the remote debugger on iOS 17+ --- lib/driver.js | 31 +++++++++++++++++++++++++------ package.json | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index 0880c501a..8468f1c84 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -650,22 +650,41 @@ export class XCUITestDriver extends BaseDriver { this.logEvent('orientationSet'); } + await this.prepareWebSession(); + } + + /** + * @returns {Promise} + */ + async prepareWebSession() { if (this.isSafari() || this.opts.autoWebview) { await this.activateRecentWebview(); } - if (this.isSafari()) { - if (shouldSetInitialSafariUrl(this.opts)) { + if (!this.isSafari()) { + return; + } + + if (shouldSetInitialSafariUrl(this.opts)) { + if (this.getCurrentUrl() === this.getDefaultUrl() + // On iOS 17+ we try to set the default URL via WDA using deeplinking + && !!this.opts.platformVersion && util.compareVersions(this.opts.platformVersion, '>=', '17.0') + ) { + this.log.info( + `Assuming the default URL '${this.getDefaultUrl()}' has been set at the browser startup` + ); + } else { this.log.info( `About to set the initial Safari URL to '${this.getCurrentUrl()}'.` + `Use 'safariInitialUrl' capability in order to customize it`, ); await this.setUrl(this.getCurrentUrl()); - } else { - const currentUrl = await this.getUrl(); - this.log.info(`Current URL: ${currentUrl}`); - this.setCurrentUrl(currentUrl); + return; } } + + const currentUrl = await this.getUrl(); + this.log.info(`Current URL: ${currentUrl}`); + this.setCurrentUrl(currentUrl); } /** diff --git a/package.json b/package.json index f10bfe738..965a2e3d3 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "appium-ios-device": "^2.5.4", "appium-ios-simulator": "^6.1.7", "appium-remote-debugger": "^12.0.1", - "appium-webdriveragent": "^8.7.8", + "appium-webdriveragent": "^8.8.0", "appium-xcode": "^5.1.4", "async-lock": "^1.4.0", "asyncbox": "^3.0.0",