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