1
0
Fork 0

fix: Cleanup after WebDriver errors

pull/1/head
Ambrose Chua 2021-09-10 00:54:26 +08:00
parent 30c22cff9f
commit dc3cc1f282
2 changed files with 15 additions and 6 deletions

View File

@ -52,9 +52,9 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
node-version: [14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
exclude:
- {os: windows-latest, node: 16.x}
- {os: macOS-latest, node: 16.x}
exclude:
- {os: windows-latest, node: 16.x}
- {os: macOS-latest, node: 16.x}
steps:
- uses: actions/checkout@v2

View File

@ -50,8 +50,7 @@ export default class PlatformBrowser implements Platform {
this.silent = silent;
}
async run(ctx: Context, file: string): Promise<Result> {
const {child, port} = await start(this.driver, this.silent);
async interact(ctx: Context, file: string, port: number): Promise<Result> {
const client = await WebDriver.newSession({
logLevel: 'warn',
port,
@ -75,7 +74,17 @@ export default class PlatformBrowser implements Platform {
)) as Result;
await client.deleteSession();
await stop(child);
return result;
}
async run(ctx: Context, file: string): Promise<Result> {
const {child, port} = await start(this.driver, this.silent);
try {
const result = await this.interact(ctx, file, port);
await stop(child);
return result;
} finally {
await stop(child);
}
}
}