Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: appium/WebDriverAgent
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.2.0
Choose a base ref
...
head repository: appium/WebDriverAgent
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.2.1
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on Mar 28, 2024

  1. chore: wait for wda start in sim as well for preinstalled wda start (#…

    …876)
    
    * chore: wait for wda start in sim as well for preinstalled wda start
    
    * move to inner func
    
    * modify a bit
    
    * remove redundant new line
    
    * add wait for logic in getStatus
    
    * remoe a new line
    
    * use waitForCondition in getSttus
    
    * modify error handling
    
    * tweak error log
    
    * tweak log further
    
    * Update webdriveragent.js
    KazuCocoa authored Mar 28, 2024

    Verified

    This commit was created on github.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6c8920a View commit details
  2. chore(release): 8.2.1 [skip ci]

    ## [8.2.1](v8.2.0...v8.2.1) (2024-03-28)
    
    ### Miscellaneous Chores
    
    * wait for wda start in sim as well for preinstalled wda start ([#876](#876)) ([6c8920a](6c8920a))
    semantic-release-bot committed Mar 28, 2024
    Copy the full SHA
    8e7f17b View commit details
Showing with 58 additions and 24 deletions.
  1. +7 −0 CHANGELOG.md
  2. +50 −23 lib/webdriveragent.js
  3. +1 −1 package.json
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [8.2.1](https://github.com/appium/WebDriverAgent/compare/v8.2.0...v8.2.1) (2024-03-28)


### Miscellaneous Chores

* wait for wda start in sim as well for preinstalled wda start ([#876](https://github.com/appium/WebDriverAgent/issues/876)) ([6c8920a](https://github.com/appium/WebDriverAgent/commit/6c8920adddb373b463259c3e6c14cb3c49ecbf2b))

## [8.2.0](https://github.com/appium/WebDriverAgent/compare/v8.1.0...v8.2.0) (2024-03-28)


73 changes: 50 additions & 23 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
@@ -190,21 +190,53 @@ class WebDriverAgent {
* }
* }
*
* @return {Promise<any?>} State Object
* @param {number} [timeoutMs=0] If the given timeoutMs is zero or negative number,
* this function will return the response of `/status` immediately. If the given timeoutMs,
* this function will try to get the response of `/status` up to the timeoutMs.
* @return {Promise<import('@appium/types').StringRecord|null>} State Object
* @throws {Error} If there was an error within timeoutMs timeout.
* No error is raised if zero or negative number for the timeoutMs.
*/
async getStatus () {
async getStatus (timeoutMs = 0) {
const noSessionProxy = new NoSessionProxy({
server: this.url.hostname,
port: this.url.port,
base: this.basePath,
timeout: 3000,
});

const sendGetStatus = async () => await /** @type import('@appium/types').StringRecord */ (noSessionProxy.command('/status', 'GET'));

if (_.isNil(timeoutMs) || timeoutMs <= 0) {
try {
return await sendGetStatus();
} catch (err) {
this.log.debug(`WDA is not listening at '${this.url.href}'. Original error:: ${err.message}`);
return null;
}
}

let lastError = null;
let status = null;
try {
return await noSessionProxy.command('/status', 'GET');
await waitForCondition(async () => {
try {
status = await sendGetStatus();
return true;
} catch (err) {
lastError = err;
}
return false;
}, {
waitMs: timeoutMs,
intervalMs: 300,
});
} catch (err) {
this.log.debug(`WDA is not listening at '${this.url.href}'`);
return null;
this.log.debug(`Failed to get the status endpoint in ${timeoutMs} ms. ` +
`The last error while accessing ${this.url.href}: ${lastError}. Original error:: ${err.message}.`);
throw new Error(`WDA was not ready in ${timeoutMs} ms.`);
}
return status;
}

/**
@@ -317,28 +349,14 @@ class WebDriverAgent {
await this.device.devicectl.launchApp(
this.bundleIdForXctest, { env, terminateExisting: true }
);

// Launching app via decictl does not wait for the app start.
// We should wait for the app start by ourselves.
try {
await waitForCondition(async () => !_.isNull(await this.getStatus()), {
waitMs: this.wdaLaunchTimeout,
intervalMs: 300,
});

} catch (err) {
throw new Error(
`Failed to start the preinstalled WebDriverAgent in ${this.wdaLaunchTimeout} ms. ` +
`The WebDriverAgent might not be properly built or the device might be locked. ` +
`The 'appium:wdaLaunchTimeout' capability modifies the timeout.`
);
}
}

/**
* Launch WDA with preinstalled package without xcodebuild.
* @param {string} sessionId Launch WDA and establish the session with this sessionId
* @return {Promise<any?>} State Object
* @return {Promise<import('@appium/types').StringRecord|null>} State Object
* @throws {Error} If there was an error within timeoutMs timeout.
* No error is raised if zero or negative number for the timeoutMs.
*/
async launchWithPreinstalledWDA(sessionId) {
const xctestEnv = {
@@ -371,7 +389,16 @@ class WebDriverAgent {
}

this.setupProxies(sessionId);
const status = await this.getStatus();
let status;
try {
status = await this.getStatus(this.wdaLaunchTimeout);
} catch (err) {
throw new Error(
`Failed to start the preinstalled WebDriverAgent in ${this.wdaLaunchTimeout} ms. ` +
`The WebDriverAgent might not be properly built or the device might be locked. ` +
`The 'appium:wdaLaunchTimeout' capability modifies the timeout.`
);
}
this.started = true;
return status;
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "appium-webdriveragent",
"version": "8.2.0",
"version": "8.2.1",
"description": "Package bundling WebDriverAgent",
"main": "./build/index.js",
"scripts": {