-
-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change the default behaviour of useNewWDA capability #456
Conversation
109210d
to
062036b
Compare
Sure. I have some real device stuff I need to do today, so I'll take a whirl. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work well in local tests. One remark about short-circuiting.
lib/driver.js
Outdated
this.logEvent('wdaStartFailed'); | ||
if (this.isRealDevice() && launchRetriesCount > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume you want to not retry if there is an xcodebuild failure on a real device?
This will not do that. Any error thrown here will trigger a retry at the retryInterval
level (on line 427). It would be better to check for real device before the retryInterval
, and adjust the startupRetries
accordingly.
const startupRetries = this.isRealDevice() ? 1 : (this.opts.wdaStartupRetries || WDA_STARTUP_RETRIES);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might not be a good idea to implicitly override user-supplied option.
How about this one?
const startupRetries = this.opts.wdaStartupRetries || (this.isRealDevice() ? 1 : WDA_STARTUP_RETRIES);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Yeah, that would work. Since the number varies, it should probably be logged, as well.
lib/driver.js
Outdated
@@ -434,7 +461,13 @@ class XCUITestDriver extends BaseDriver { | |||
}); | |||
this.logEvent('wdaSessionStarted'); | |||
} catch (err) { | |||
return await quitAndUninstall(`Unable to start WebDriverAgent session: ${err.message}`); | |||
let errorMsg = `Unable to start WebDriverAgent sesssion because of xcodebuild failure: ${err.message}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor into a function call to handle the error, so it's not repeated here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error messages are different for both cases. I separated them intentionally for a case when it is necessary to add any other helpful message details to help user to fix his problem for the particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will be really useful!
README.md
Outdated
@@ -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. 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`| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably don't want to refer to appium versions in the xcuitest repo, maybe refer to the xcuitest version? unless the default is set in appium and not here. which might be the case, hmm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to driver version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see a change
lib/driver.js
Outdated
await quitAndUninstall(`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 += ` Make sure you follow the tutorial at https://github.com/appium/appium-xcuitest-driver/blob/master/docs/real-device-config.md. ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting looks goofy here, maybe because the lines are too long (we try to stick to 80 chars when possible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n/m saw the change. one more comment.
README.md
Outdated
@@ -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. 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`| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see a change
lib/driver.js
Outdated
await quitAndUninstall(`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 += ` Make sure you follow the tutorial at ` + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's now quite a bit of duplication with this error message; maybe make it a global constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I only extract the tutorial URL into a constant? I want to keep message texts separated, since it might be necessary to tune them in the future for launch session and wait for status cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine with me if we think we will likely want to do that
Published in |
This PR tries to address real device issues like facebookarchive/WebDriverAgent#507 by keeping WDA session running for as long as possible and reuse it every time the new session is created instead of recompiling/redeploying WDA. Also, it should significantly shorten the duration of driver initialisation stage between multiple test cases.
@imurchie Could you please assist with testing, since it is necessary to significantly change our automation framework to test these changes on Simulator and (especially) on real device? Thanks in advance.