Skip to content

Commit

Permalink
WebdriverAgent & Agent: async destroy() and stop returns boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed May 11, 2021
1 parent 4c57048 commit 4445fed
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Agent {

// defaults that do nothing
async initialize() { return this; }
destroy() {}
async destroy() {}
stop() {}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/ConsoleAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class ConsoleAgent extends Agent {
}

// console agents need to kill the process before exiting.
destroy() {
async destroy() {
return this.stop();
}

Expand Down
10 changes: 6 additions & 4 deletions lib/WebdriverAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,21 @@ class WebdriverAgent extends BrowserAgent {
.then(() => Promise.all([quitP, getP]));
return this._restartP.then(() => {
this._restartP = null;
return undefined;
return true;
});
}

destroy() {
async destroy() {
let baseP = Promise.resolve();
if (this._restartP) {
// selenium doesn't like to exit properly if you try to kill while it's doing something
// so, let's wait.
baseP = this._restartP;
}

return baseP.then(() => this._driver.quit()).then(() => super.destroy());
await baseP;
await this._driver.quit();
await this._driver.quit();
return super.destroy();
}
}

Expand Down

0 comments on commit 4445fed

Please sign in to comment.