-
Notifications
You must be signed in to change notification settings - Fork 395
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
feat: start wda process via Xctest in a real device #687
Conversation
Tested with appium/appium-xcuitest-driver#1609 |
updated |
lib/webdriveragent.js
Outdated
this.log.info('Launching WebDriverAgent on the device without xcodebuild'); | ||
this.xctestSessionForWDA = new Xctest(this.device.udid, this.bundleIdForXctest, null, {env: xctestEnv}); | ||
|
||
await this.xctestSessionForWDA.start(); |
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.
should we reset this.xctestSessionForWDA if this call or any call below throws an exception?
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.
Does reset means this.xctestSessionForWDA = null
for example? We can re-call .start
unless the target udid hasn't changed. The caller, in xcuitest driver, calls stop
in the case, so the this.xctestSessionForWDA.stop
will be called in such exception case
lib/constants.js
Outdated
@@ -1,6 +1,7 @@ | |||
import path from 'path'; | |||
|
|||
const WDA_RUNNER_BUNDLE_ID = 'com.facebook.WebDriverAgentRunner'; | |||
const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST = 'com.facebook.WebDriverAgentRunner.xctrunner'; |
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.
const WDA_RUNNER_BUNDLE_ID_FOR_XCTEST = `${WDA_RUNNER_BUNDLE_ID}.xctrunner`;
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.
not sure if we need a separate constant for it though if only the suffix differs
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.
Either is fine, I wanted to explicitly keep the xctrunner
as xctest bundle's bundle id
updated ✅ |
lib/webdriveragent.js
Outdated
@@ -59,6 +61,10 @@ class WebDriverAgent { | |||
|
|||
this.updatedWDABundleId = args.updatedWDABundleId; | |||
|
|||
this.usePreinstalledWDA = args.usePreinstalledWDA; | |||
this.preInstalledWDABundleId = args.preInstalledWDABundleId; |
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.
Do we need this capability in general? Can its value be calculated as ${updatedWDABundleId}.xctrunner
instead?
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.
Could be with additional a few changes. (At least needed to add if condition in a few places) I initially re-used the capability, but this PR itself does not update bundle id itself. So the naming could be confusing for the behavior.
So i defined a new capability to simplify the implementation and purpose at this time.
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.
my point is the less capabilities we have the better it is (easier to maintain)
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.
yea, understood this point as well. I like less if condition for this case, but then, 211a10f and appium/appium-xcuitest-driver@d2bfc15 help to work with updatedWDABundleId
. Then, ignoring xcodebuild instance itself might be safe (rather than adding if condition in xcodebuild instance to avoid unnecessary updatedWDABundleId
related procedure).
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.
Also, I addressed the WDA must have been a package built with over Xcode 12 in appium/appium-xcuitest-driver@d2bfc15 for safe to follow xctrunner
rule. (We do not need to take care the case lower version case with current our requirement, but for safe as this implementation's requirement.)
lib/webdriveragent.js
Outdated
// FIXME: maybe 'this.webDriverAgentUrl' also can ignore | ||
// the xcodebuild instance itself. | ||
if (this.usePreinstalledWDA) { | ||
this.xcodebuild = null; |
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.
do not return immediately here so that we may write something after this if/else clause in the future. (do not restrict the order)
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.
a ternary operator would probably be better readable here
lib/webdriveragent.js
Outdated
@@ -286,6 +308,25 @@ class WebDriverAgent { | |||
return await this.getStatus(); | |||
} | |||
|
|||
if (this.isRealDevice && this.usePreinstalledWDA) { |
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 think we should verify it in xcuitest driver if usePreinstalledWDA cap is set to true and a simulator is selected. In such case a validation error must be thrown
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 find the current method a bit to long. Perhaps, it makes sense to move this code block into a separate method?
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.
ah, it makes sense
## [4.14.0](v4.13.2...v4.14.0) (2023-05-02) ### Features * start wda process via Xctest in a real device ([#687](#687)) ([e1c0f83](e1c0f83))
🎉 This PR is included in version 4.14.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
For appium/appium-xcuitest-driver#1609 to start a WDA process via Xctest in appoum-ios-device. The XCUITest PR will introduce 2 capabilities,
usePreinstalledWDA
andpreInstalledWDABundleId
.preInstalledWDABundleId is to detect which bundle id is preinstalled wda the session want to start to.
usePreinstalledWDA is if a session uses XCTest sessions via appium-ios-device instead of xcodebuild to handle WDA.
One good thing in this aspect is this method can start a WDA process with free apple id account's one.
example capabilities:
I'll try to write test code as a followup pr.
Current CI failures are not related to this change. Maybe the host machine was slow?