Skip to content
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

WAT-4497 Kill chromedriver process when test case ends #258

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion packages/plugin-selenium-driver/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
WindowFeaturesConfig,
} from '@testring/types';

import {ChildProcess} from 'child_process';
import {ChildProcess, execSync} from 'child_process';

import {remote} from 'webdriverio';
import * as deepmerge from 'deepmerge';
Expand Down Expand Up @@ -485,12 +485,27 @@ export class SeleniumPlugin implements IBrowserProxyPlugin {

this.localSelenium.removeAllListeners();

this.killProcess();

this.logger.debug(
'Selenium process and all associated pipes closed.',
);
}
}

public killProcess() {
let result = execSync("ps aux | grep '[c]hromedriver' | awk '{print $2}'");
const pids = result.toString().trim().split('\n').filter((pid) => pid).join(' ');
if (pids && pids.length > 0) {
this.logger.debug(`Killing ChromeDriver processes with PIDs: ${pids}...`);
result = execSync(`kill -9 ${pids}`);
this.logger.debug(`Killed ChromeDriver processes with PIDs: ${pids}.`);
} else {
this.logger.debug('No ChromeDriver processes found.');
}
return result;
}

public async refresh(applicant: string) {
await this.createClient(applicant);
const client = this.getBrowserClient(applicant);
Expand Down