25 lines
679 B
TypeScript
25 lines
679 B
TypeScript
import { binding } from 'cucumber-tsflow';
|
|
import { Builder, Capabilities, ThenableWebDriver } from 'selenium-webdriver';
|
|
|
|
const capabilities = Capabilities.chrome();
|
|
capabilities.set('chromeOptions', { w3c: false });
|
|
|
|
@binding()
|
|
export class WebDriver {
|
|
protected readonly driver: ThenableWebDriver;
|
|
private static instance: WebDriver;
|
|
|
|
public constructor() {
|
|
if (WebDriver.instance) {
|
|
return WebDriver.instance;
|
|
}
|
|
|
|
this.driver = new Builder().usingServer(process.env.SELENIUM_SERVER_URL).withCapabilities(capabilities).build();
|
|
this.driver.manage().setTimeouts({ implicit: 100 });
|
|
WebDriver.instance = this;
|
|
}
|
|
|
|
public getDriver() {
|
|
return this.driver;
|
|
}
|
|
}
|