From 062036bf7d0b145cdefbd7db64c0341115e18fcc Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Sat, 17 Jun 2017 16:34:43 +0200 Subject: [PATCH 1/6] Try to reuse running WDA instance and tune WDA startup logic --- README.md | 4 +-- lib/driver.js | 75 ++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f896f36bc..945deb4e2 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ See [real device configuration documentation](docs/real-device-config.md). ### Known problems -After many failures on real devices, there can be a state where the device will no longer accept connections. To possibly remedy this, set the `useNewWDA` capability to `true`. +After many failures on real devices, there can be a state where the device will no longer accept connections. To possibly remedy this reboot the device. Read https://github.com/facebook/WebDriverAgent/issues/507 for more details. [Getting full control](https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/wda-custom-server.md) over WDA server might help to workaround the problem. #### Weird state @@ -134,7 +134,7 @@ Differences noted here |`usePrebuiltWDA`|Skips the build phase of running the WDA app. Building is then the responsibility of the user. Only works for Xcode 8+. Defaults to `false`.|e.g., `true`| |`preventWDAAttachments`|Sets read only permissions to Attachments subfolder of WebDriverAgent root inside Xcode's DerivedData. This is necessary to prevent XCTest framework from creating tons of unnecessary screenshots and logs, which are impossible to turn off using programming interfaces provided by Apple.|Setting the capability to `true` will set Posix permissions of the folder to `555` and `false` will reset them back to `755`. `true` by default| |`webDriverAgentUrl`|If provided, Appium will connect to an existing WebDriverAgent instance at this URL instead of starting a new one.|e.g., `http://localhost:8100`| -|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. This can provide stability in some situations. Defaults to `false`.|e.g., `true`| +|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. This can provide stability in some situations when the app runs on Simulator. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`| |`wdaLaunchTimeout`|Time, in ms, to wait for WebDriverAgewnt to be pingable. Defaults to 60000ms.|e.g., `30000`| |`wdaConnectionTimeout`|Timeout, in ms, for waiting for a response from WebDriverAgent. Defaults to 240000ms.|e.g., `1000`| |`resetOnSessionStartOnly`|Whether to perform reset on test session finish (`false`) or not (`true`). Keeping this variable set to `true` and Simulator running (the default behaviour since version 1.6.4) may significantly shorten the duratiuon of test session initialization.|Either `true` or `false`. Defaults to `true`| diff --git a/lib/driver.js b/lib/driver.js index c423cf1a8..d17cea68c 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -17,6 +17,7 @@ import { detectUdid, getAndCheckXcodeVersion, getAndCheckIosSdkVersion, clearSystemFiles, translateDeviceName } from './utils'; import { getConnectedDevices, runRealDeviceReset, installToRealDevice, getRealDeviceObj } from './real-device-management'; +import { NoSessionProxy } from "./wda/no-session-proxy"; import B from 'bluebird'; import { version } from '../../package.json'; // eslint-disable-line import/no-unresolved @@ -383,32 +384,59 @@ class XCUITestDriver extends BaseDriver { } async startWda (sessionId, realDevice) { - let startupRetries = this.opts.wdaStartupRetries || WDA_STARTUP_RETRIES; - let startupRetryInterval = this.opts.wdaStartupRetryInterval || WDA_STARTUP_RETRY_INTERVAL; - await retryInterval(startupRetries, startupRetryInterval, async () => { - this.logEvent('wdaStartAttempted'); - this.wda = new WebDriverAgent(this.xcodeVersion, this.opts); + this.wda = new WebDriverAgent(this.xcodeVersion, this.opts); - if (this.opts.useNewWDA) { - log.debug(`Capability 'useNewWDA' set, so uninstalling WDA before proceeding`); - await this.wda.uninstall(); - this.logEvent('wdaUninstalled'); + if (this.opts.useNewWDA) { + log.debug(`Capability 'useNewWDA' set to true, so uninstalling WDA before proceeding`); + await this.wda.quit(); + await this.wda.uninstall(); + this.logEvent('wdaUninstalled'); + } else if (!util.hasValue(this.wda.webDriverAgentUrl)) { + log.debug(`Capability 'useNewWDA' set to false, so trying to reuse currently running WDA instance at ${this.wda.url}...`); + const noSessionProxy = new NoSessionProxy({ + server: this.wda.url.hostname, + port: this.wda.url.port, + base: '', + timeout: 3000, + }); + try { + const status = await noSessionProxy.command('/status', 'GET'); + if (!status) { + throw new Error(`WDA response to /status command should be defined.`); + } + log.debug(`Detected WDA listening at ${this.wda.url}. Setting WDA endpoint to ${this.wda.url}`); + this.wda.webDriverAgentUrl = this.wda.url; + } catch (err) { + log.debug(`WDA is not listening at ${this.wda.url}. Rebuilding...`); } + } - // local helper for the two places we need to uninstall wda and re-start it - let quitAndUninstall = async (msg) => { - log.debug(msg); - log.debug('Quitting and uninstalling WebDriverAgent, then retrying'); - await this.wda.quit(); - await this.wda.uninstall(); - throw new Error(msg); - }; + // local helper for the two places we need to uninstall wda and re-start it + const quitAndUninstall = async (msg) => { + log.debug(msg); + log.debug('Quitting and uninstalling WebDriverAgent, then retrying'); + await this.wda.quit(); + await this.wda.uninstall(); + throw new Error(msg); + }; + const startupRetries = this.opts.wdaStartupRetries || WDA_STARTUP_RETRIES; + const startupRetryInterval = this.opts.wdaStartupRetryInterval || WDA_STARTUP_RETRY_INTERVAL; + let launchRetriesCount = 0; + let sessionStartupRetriesCount = 0; + await retryInterval(startupRetries, startupRetryInterval, async () => { + this.logEvent('wdaStartAttempted'); let wdaStatus = null; try { wdaStatus = await this.wda.launch(sessionId, realDevice); } catch (err) { + launchRetriesCount++; this.logEvent('wdaStartFailed'); + if (this.isRealDevice() && launchRetriesCount > 1) { + throw new Error(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}. ` + + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Sometimes rebooting the device helps as well.`); + } await quitAndUninstall(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`); } @@ -434,7 +462,13 @@ class XCUITestDriver extends BaseDriver { }); this.logEvent('wdaSessionStarted'); } catch (err) { - return await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`); + sessionStartupRetriesCount++; + if (this.isRealDevice() && sessionStartupRetriesCount > 1) { + throw new Error(`Unable to start WebDriverAgent session: ${err.message}. ` + + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Sometimes rebooting the device helps as well.`); + } + await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`); } this.opts.preventWDAAttachments = !util.hasValue(this.opts.preventWDAAttachments) || this.opts.preventWDAAttachments; @@ -530,7 +564,9 @@ class XCUITestDriver extends BaseDriver { log.debug(`Unable to DELETE session on WDA: '${err.message}'. Continuing shutdown.`); } } - await this.wda.quit(); + if (!this.wda.webDriverAgentUrl && this.opts.useNewWDA) { + await this.wda.quit(); + } } } @@ -807,6 +843,7 @@ class XCUITestDriver extends BaseDriver { // `resetOnSessionStartOnly` should be set to true by default this.opts.resetOnSessionStartOnly = !util.hasValue(this.opts.resetOnSessionStartOnly) || this.opts.resetOnSessionStartOnly; + this.opts.useNewWDA = util.hasValue(this.opts.useNewWDA) ? this.opts.useNewWDA : false; // finally, return true since the superclass check passed, as did this return true; From c254f4386647ce1980ace7c901dce44f885a8400 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Mon, 19 Jun 2017 10:28:56 +0200 Subject: [PATCH 2/6] Add more detailed issue description --- README.md | 2 +- lib/driver.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 945deb4e2..8ad065ecc 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Differences noted here |`usePrebuiltWDA`|Skips the build phase of running the WDA app. Building is then the responsibility of the user. Only works for Xcode 8+. Defaults to `false`.|e.g., `true`| |`preventWDAAttachments`|Sets read only permissions to Attachments subfolder of WebDriverAgent root inside Xcode's DerivedData. This is necessary to prevent XCTest framework from creating tons of unnecessary screenshots and logs, which are impossible to turn off using programming interfaces provided by Apple.|Setting the capability to `true` will set Posix permissions of the folder to `555` and `false` will reset them back to `755`. `true` by default| |`webDriverAgentUrl`|If provided, Appium will connect to an existing WebDriverAgent instance at this URL instead of starting a new one.|e.g., `http://localhost:8100`| -|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. This can provide stability in some situations when the app runs on Simulator. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`| +|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. Set it to `true` if you want to apply different startup options for WebDriverAgent for each session. Although, it is only guaranteed to work stable on Simulator. Real devices require WebDriverAgent client to run for as long as possible without reinstall/restart to avoid issues like https://github.com/facebook/WebDriverAgent/issues/507. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`| |`wdaLaunchTimeout`|Time, in ms, to wait for WebDriverAgewnt to be pingable. Defaults to 60000ms.|e.g., `30000`| |`wdaConnectionTimeout`|Timeout, in ms, for waiting for a response from WebDriverAgent. Defaults to 240000ms.|e.g., `1000`| |`resetOnSessionStartOnly`|Whether to perform reset on test session finish (`false`) or not (`true`). Keeping this variable set to `true` and Simulator running (the default behaviour since version 1.6.4) may significantly shorten the duratiuon of test session initialization.|Either `true` or `false`. Defaults to `true`| diff --git a/lib/driver.js b/lib/driver.js index d17cea68c..399e1a399 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -435,7 +435,7 @@ class XCUITestDriver extends BaseDriver { if (this.isRealDevice() && launchRetriesCount > 1) { throw new Error(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}. ` + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Sometimes rebooting the device helps as well.`); + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`); } await quitAndUninstall(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`); } @@ -466,7 +466,7 @@ class XCUITestDriver extends BaseDriver { if (this.isRealDevice() && sessionStartupRetriesCount > 1) { throw new Error(`Unable to start WebDriverAgent session: ${err.message}. ` + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Sometimes rebooting the device helps as well.`); + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`); } await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`); } From 698a79d81fa5a7287315d8773775ab9f3740d302 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Tue, 20 Jun 2017 20:23:49 +0200 Subject: [PATCH 3/6] Tune retries count --- lib/driver.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index 399e1a399..be57da3fb 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -23,7 +23,8 @@ import { version } from '../../package.json'; // eslint-disable-line import/no-u const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari'; -const WDA_STARTUP_RETRIES = 2; +const WDA_SIM_STARTUP_RETRIES = 2; +const WDA_REAL_DEV_STARTUP_RETRIES = 1; const DEFAULT_TIMEOUT_KEY = 'default'; const WDA_STARTUP_RETRY_INTERVAL = 10000; const DEFAULT_SETTINGS = { @@ -420,24 +421,22 @@ class XCUITestDriver extends BaseDriver { throw new Error(msg); }; - const startupRetries = this.opts.wdaStartupRetries || WDA_STARTUP_RETRIES; + const startupRetries = this.opts.wdaStartupRetries || (this.isRealDevice() ? WDA_REAL_DEV_STARTUP_RETRIES : WDA_SIM_STARTUP_RETRIES); const startupRetryInterval = this.opts.wdaStartupRetryInterval || WDA_STARTUP_RETRY_INTERVAL; - let launchRetriesCount = 0; - let sessionStartupRetriesCount = 0; await retryInterval(startupRetries, startupRetryInterval, async () => { this.logEvent('wdaStartAttempted'); let wdaStatus = null; try { wdaStatus = await this.wda.launch(sessionId, realDevice); } catch (err) { - launchRetriesCount++; this.logEvent('wdaStartFailed'); - if (this.isRealDevice() && launchRetriesCount > 1) { - throw new Error(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}. ` + - `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`); + let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`; + if (this.isRealDevice()) { + errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}. ` + + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; } - await quitAndUninstall(`Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`); + await quitAndUninstall(errorMsg); } this.proxyReqRes = this.wda.proxyReqRes.bind(this.wda); @@ -462,13 +461,13 @@ class XCUITestDriver extends BaseDriver { }); this.logEvent('wdaSessionStarted'); } catch (err) { - sessionStartupRetriesCount++; - if (this.isRealDevice() && sessionStartupRetriesCount > 1) { - throw new Error(`Unable to start WebDriverAgent session: ${err.message}. ` + - `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`); + let errorMsg = `Unable to start WebDriverAgent sesssion because of xcodebuild failure: ${err.message}`; + if (this.isRealDevice()) { + errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: ${err.message}. ` + + `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; } - await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`); + await quitAndUninstall(errorMsg); } this.opts.preventWDAAttachments = !util.hasValue(this.opts.preventWDAAttachments) || this.opts.preventWDAAttachments; From 9cfcc166e70f3579793c0f14f82c7f5502966de9 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Tue, 20 Jun 2017 20:41:20 +0200 Subject: [PATCH 4/6] Avoid error message duplication --- lib/driver.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index be57da3fb..f7f7f6d8b 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -430,11 +430,10 @@ class XCUITestDriver extends BaseDriver { wdaStatus = await this.wda.launch(sessionId, realDevice); } catch (err) { this.logEvent('wdaStartFailed'); - let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}`; + let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: ${err.message}. ` + - `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; + errorMsg += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; } await quitAndUninstall(errorMsg); } @@ -461,11 +460,10 @@ class XCUITestDriver extends BaseDriver { }); this.logEvent('wdaSessionStarted'); } catch (err) { - let errorMsg = `Unable to start WebDriverAgent sesssion because of xcodebuild failure: ${err.message}`; + let errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: ${err.message}. ` + - `Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; + errorMsg += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; } await quitAndUninstall(errorMsg); } From b60f57febb5a42a19235949b21f59302084adc83 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 21 Jun 2017 17:27:13 +0200 Subject: [PATCH 5/6] Tune max line lengths --- README.md | 2 +- lib/driver.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8ad065ecc..4f471674f 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ Differences noted here |`usePrebuiltWDA`|Skips the build phase of running the WDA app. Building is then the responsibility of the user. Only works for Xcode 8+. Defaults to `false`.|e.g., `true`| |`preventWDAAttachments`|Sets read only permissions to Attachments subfolder of WebDriverAgent root inside Xcode's DerivedData. This is necessary to prevent XCTest framework from creating tons of unnecessary screenshots and logs, which are impossible to turn off using programming interfaces provided by Apple.|Setting the capability to `true` will set Posix permissions of the folder to `555` and `false` will reset them back to `755`. `true` by default| |`webDriverAgentUrl`|If provided, Appium will connect to an existing WebDriverAgent instance at this URL instead of starting a new one.|e.g., `http://localhost:8100`| -|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. Set it to `true` if you want to apply different startup options for WebDriverAgent for each session. Although, it is only guaranteed to work stable on Simulator. Real devices require WebDriverAgent client to run for as long as possible without reinstall/restart to avoid issues like https://github.com/facebook/WebDriverAgent/issues/507. The `false` value (the default behaviour since Appium 1.6.6) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to Appium 1.6.6.|e.g., `true`| +|`useNewWDA`|If `true`, forces uninstall of any existing WebDriverAgent app on device. Set it to `true` if you want to apply different startup options for WebDriverAgent for each session. Although, it is only guaranteed to work stable on Simulator. Real devices require WebDriverAgent client to run for as long as possible without reinstall/restart to avoid issues like https://github.com/facebook/WebDriverAgent/issues/507. The `false` value (the default behaviour since driver version 2.35.0) will try to detect currently running WDA listener executed by previous testing session(s) and reuse it if possible, which is highly recommended for real device testing and to speed up suites of multiple tests in general. A new WDA session will be triggered at the default URL (http://localhost:8100) if WDA is not listening and `webDriverAgentUrl` capability is not set. The negative/unset value of `useNewWDA` capability has no effect prior to xcuitest driver version 2.35.0.|e.g., `true`| |`wdaLaunchTimeout`|Time, in ms, to wait for WebDriverAgewnt to be pingable. Defaults to 60000ms.|e.g., `30000`| |`wdaConnectionTimeout`|Timeout, in ms, for waiting for a response from WebDriverAgent. Defaults to 240000ms.|e.g., `1000`| |`resetOnSessionStartOnly`|Whether to perform reset on test session finish (`false`) or not (`true`). Keeping this variable set to `true` and Simulator running (the default behaviour since version 1.6.4) may significantly shorten the duratiuon of test session initialization.|Either `true` or `false`. Defaults to `true`| diff --git a/lib/driver.js b/lib/driver.js index f7f7f6d8b..c5274a7d0 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -432,8 +432,10 @@ class XCUITestDriver extends BaseDriver { this.logEvent('wdaStartFailed'); let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; + errorMsg += ` Make sure you follow the tutorial at ` + + `https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed ` + + `and reboot the device.`; } await quitAndUninstall(errorMsg); } @@ -462,8 +464,10 @@ class XCUITestDriver extends BaseDriver { } catch (err) { let errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + - `Try to remove the WebDriverAgentRunner application from the device if it is installed and reboot the device.`; + errorMsg += ` Make sure you follow the tutorial at ` + + `https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + `Try to remove the WebDriverAgentRunner application from the device if it is installed ` + + `and reboot the device.`; } await quitAndUninstall(errorMsg); } From 0c9a16ca600a991262bedb2fc3e1a2634deb7a00 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Wed, 21 Jun 2017 17:46:01 +0200 Subject: [PATCH 6/6] Keep real device tutorial URL in a separate constant --- lib/driver.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/driver.js b/lib/driver.js index c5274a7d0..7353317ca 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -25,6 +25,7 @@ import { version } from '../../package.json'; // eslint-disable-line import/no-u const SAFARI_BUNDLE_ID = 'com.apple.mobilesafari'; const WDA_SIM_STARTUP_RETRIES = 2; const WDA_REAL_DEV_STARTUP_RETRIES = 1; +const WDA_REAL_DEV_TUTORIAL_URL = 'https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md'; const DEFAULT_TIMEOUT_KEY = 'default'; const WDA_STARTUP_RETRY_INTERVAL = 10000; const DEFAULT_SETTINGS = { @@ -432,8 +433,7 @@ class XCUITestDriver extends BaseDriver { this.logEvent('wdaStartFailed'); let errorMsg = `Unable to launch WebDriverAgent because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg += ` Make sure you follow the tutorial at ` + - `https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + errorMsg += ` Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}. ` + `Try to remove the WebDriverAgentRunner application from the device if it is installed ` + `and reboot the device.`; } @@ -464,8 +464,7 @@ class XCUITestDriver extends BaseDriver { } catch (err) { let errorMsg = `Unable to start WebDriverAgent session because of xcodebuild failure: "${err.message}".`; if (this.isRealDevice()) { - errorMsg += ` Make sure you follow the tutorial at ` + - `https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + + errorMsg += ` Make sure you follow the tutorial at ${WDA_REAL_DEV_TUTORIAL_URL}. ` + `Try to remove the WebDriverAgentRunner application from the device if it is installed ` + `and reboot the device.`; }