offer exit on driver

This commit is contained in:
Kai Maetzel
2019-01-02 17:28:38 -08:00
parent 5ed55a8606
commit 26ed89df8a
4 changed files with 16 additions and 3 deletions
+1
View File
@@ -89,6 +89,7 @@ export class Application {
async stop(): Promise<any> {
if (this._code) {
await this._code.exit();
this._code.dispose();
this._code = undefined;
}
+5 -3
View File
@@ -64,7 +64,7 @@ async function connect(child: cp.ChildProcess, outPath: string, handlePath: stri
while (true) {
try {
const { client, driver } = await connectDriver(outPath, handlePath);
return new Code(child, client, driver, logger);
return new Code(client, driver, logger);
} catch (err) {
if (++errCount > 50) {
child.kill();
@@ -188,7 +188,6 @@ export class Code {
private driver: IDriver;
constructor(
private process: cp.ChildProcess,
private client: IDisposable,
driver: IDriver,
readonly logger: Logger
@@ -230,6 +229,10 @@ export class Code {
await this.driver.reloadWindow(windowId);
}
async exit(): Promise<void> {
await this.driver.exitApplication();
}
async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise<string> {
const windowId = await this.getActiveWindowId();
accept = accept || (result => textContent !== void 0 ? textContent === result : !!result);
@@ -302,7 +305,6 @@ export class Code {
dispose(): void {
this.client.dispose();
this.process.kill();
}
}