-
-
Notifications
You must be signed in to change notification settings - Fork 424
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
fix: uninstall wda with '.xctrunner' suffix for real device #1052
Conversation
lib/wda/webdriveragent.js
Outdated
* | ||
* @param {string} updatedWDABundleId The bundle id which will be uninstalled | ||
*/ | ||
async uninstall (updatedWDABundleId = WDA_RUNNER_BUNDLE_ID) { |
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.
Isn't updatedWDABundleId
already sent in as an argument to the constructor? Why not just save that as an instance variable and use it?
lib/wda/webdriveragent.js
Outdated
} else { | ||
// On simulator, the bundle id should be 'com.facebook.WebDriverAgentRunner.xctrunner' | ||
// even if 'updatedWDABundleId' was given | ||
const bundle_id = `${this.realDevice ? updatedWDABundleId : WDA_RUNNER_BUNDLE_ID}${WDA_XCTRUNNER_SUFFIX}`; |
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 probably keep with camel case for variable names. I personally would also prefer the conditional to figure out the bundle id, then a single call to removeApp
.
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.
bundleId
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.
true
lib/wda/webdriveragent.js
Outdated
try { | ||
await this.device.removeApp(WDA_BUNDLE_ID); | ||
if (this.xcodeVersion.major < 11) { |
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 be that xcode version is unknown for real devices
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...
Let me check again...
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.xcodeVersion
had Xcode version on a real device.
The value might be undefined if this.opts.webDriverAgentUrl
was also provided in createSession
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.
The value might be undefined if this.opts.webDriverAgentUrl was also provided in createSession
exactly
lib/wda/webdriveragent.js
Outdated
* @param {string} updatedWDABundleId The bundle id which will be uninstalled | ||
*/ | ||
async quitAndUninstall (updatedWDABundleId = WDA_RUNNER_BUNDLE_ID) { | ||
const status = await this.getStatus(); |
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.
Can we fallback to read the id from the actual plist bundle since status
might not be available at this stage?
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.
Sounds good.
Here is only called by 'useNewWDA' is true
@KazuCocoa I have a simpler solution. We can look or add a certain identifier to the Info.plist of the webdriveragent project. This would help us to find what we want to uninstall and we can avoid bundleid based search |
Do you mean like https://github.com/appium/appium-xcuitest-driver/pull/1052/files#diff-a0e3f2ac971dfbd2354c4efa8121165aR222-R234 ? It gets Yeah, it should work. Below are cases I considered.
Will work to simplify today. (maybe, a couple of hours later) |
Something like that. We can get a list of the applications from the phone and check for an entry like |
We can modify this method https://github.com/appium/appium-ios-simulator/blob/master/lib/simulator-xcode-6.js#L182 and list all apps with their Info.plist parsed. This would do the same thing for real devices https://github.com/appium/appium-ios-device/blob/master/lib/installation-proxy/index.js#L39 |
That's cool! |
XCode might be building it weirdly and stripping stuff from the Info.plist but CFBundleName also sounds cool |
lib/wda/webdriveragent.js
Outdated
*/ | ||
async getInstalledWDBundleId () { | ||
if (this.isRealDevice) { | ||
return await getIBundleIdsByCFBundleName(this.device, WDA_CF_BUNDLE_NAME); |
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 assume this function and the next one should be methods of this.device
object
lib/simulator-management.js
Outdated
@@ -216,11 +217,11 @@ async function shutdownOtherSimulators (currentDevice) { | |||
|
|||
async function getInstalledBundleIds (device, candidateBundleIds) { | |||
const bundleIds = []; | |||
for (const bundleId of candidateBundleIds) { | |||
await B.filter(candidateBundleIds, async (bundleId) => { | |||
if (await device.isAppInstalled(bundleId)) { |
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 really - the filter condition should be async (bundleId) => await device.isAppInstalled(bundleId)
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.
and the result could be returned immediately. There is no need for the intermediate accumulator
lib/wda/webdriveragent.js
Outdated
@@ -422,7 +423,7 @@ class WebDriverAgent { | |||
*/ | |||
async getInstalledWDBundleId () { | |||
return this.isRealDevice | |||
? await getIBundleIdsByCFBundleName(this.device, WDA_CF_BUNDLE_NAME) |
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.
so how about moving these methods into corresponding classes and make it polymorphic?
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.
yes. I also thought we can get CFBundleNam
in simulator case (ios-simulator does not have such a method for now tho) as future work
lib/simulator-management.js
Outdated
@@ -214,5 +215,15 @@ async function shutdownOtherSimulators (currentDevice) { | |||
} | |||
} | |||
|
|||
async function getInstalledBundleIds (device, candidateBundleIds) { |
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 actually change this in appium-ios-simulator that we get a similar api like what the real devices have? This would help us get rid of having a list of potential bundle ids
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.
we can either add this call to ios simulator or we can attach it to the object dynamically right in this module:
this.device.getInstalledBundleIds = getInstalledBundleIds.bind(this.device);
Then this
context in this method will be pointing to device instance if called from this.device.getInstalledBundleIds(...)
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'm talking about something else. I'm talking about making this method similar as the getBundleIdsByBundleName (device, bundleName)
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 one as well. Otherwise how can it be polymorphic?
lib/wda/webdriveragent.js
Outdated
} | ||
|
||
log.debug(`Uninstalling WDAs: '${bundleIds}'`); | ||
await B.each(bundleIds, async (bundleId) => { |
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.
and here I would revert back to for of
. each
call does not provide any preferences over a normal loop
lib/real-device-management.js
Outdated
* @returns {Array<string>} A list of User level apps' bundle ids which has | ||
* 'CFBundleName' attribute as 'bundleName'. | ||
*/ | ||
async function getBundleIdsByBundleName (device, bundleName) { |
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.
yep, lets move this method into IOSDeploy class
lib/simulator-management.js
Outdated
@@ -214,5 +215,15 @@ async function shutdownOtherSimulators (currentDevice) { | |||
} | |||
} | |||
|
|||
async function getInstalledBundleIds (device, candidateBundleIds) { |
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.
since this is an oneliner then we could simply move it to getInstalledWDBundleId
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 like it
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.
Nice work!
closes appium/appium#13086
Will take a look again tomorrow.
(Draft for now)
this.opts.updatedWDABundleId