Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 2def202

Browse files
committedMar 23, 2019
deps(webdriver-manager): use replacement (#5088)
- Current workaround to use webdriver-manager-replacement until we publish a beta release of webdriver-manager closes #5087
1 parent 9d510db commit 2def202

File tree

6 files changed

+146
-419
lines changed

6 files changed

+146
-419
lines changed
 

‎bin/webdriver-manager

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env node
22

3-
require('webdriver-manager');
3+
require('webdriver-manager-replacement');

‎circle.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ jobs:
5252
name: Selenium Start
5353
background: true
5454
command: |
55-
./node_modules/webdriver-manager/bin/webdriver-manager update
56-
./node_modules/.bin/webdriver-manager-replacement update --gecko false
57-
./node_modules/.bin/webdriver-manager-replacement start --gecko false
55+
./node_modules/.bin/webdriver-manager update
56+
./node_modules/.bin/webdriver-manager start
5857
5958
- run:
6059
name: TestApp Start

‎lib/driverProviders/direct.ts

+11-29
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
* it down, and setting up the driver correctly.
55
*/
66
import * as fs from 'fs';
7-
import * as path from 'path';
87
import {Capabilities, WebDriver} from 'selenium-webdriver';
9-
import {ServiceBuilder as ChromeServiceBuilder} from 'selenium-webdriver/chrome';
8+
import {Driver as DriverForChrome, ServiceBuilder as ChromeServiceBuilder} from 'selenium-webdriver/chrome';
9+
import {Driver as DriverForFirefox, ServiceBuilder as FirefoxServiceBuilder} from 'selenium-webdriver/firefox';
10+
import {ChromeDriver, GeckoDriver} from 'webdriver-manager-replacement';
1011

1112
import {Config} from '../config';
1213
import {BrowserError} from '../exitCodes';
1314
import {Logger} from '../logger';
1415

1516
import {DriverProvider} from './driverProvider';
1617

17-
const SeleniumConfig = require('webdriver-manager/built/lib/config').Config;
18-
1918
let logger = new Logger('direct');
2019
export class Direct extends DriverProvider {
2120
constructor(config: Config) {
@@ -60,14 +59,10 @@ export class Direct extends DriverProvider {
6059
chromeDriverFile = this.config_.chromeDriver;
6160
} else {
6261
try {
63-
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
64-
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
65-
chromeDriverFile = updateConfig.chrome.last;
62+
chromeDriverFile = new ChromeDriver().getBinaryPath();
6663
} catch (e) {
6764
throw new BrowserError(
68-
logger,
69-
'Could not find update-config.json. ' +
70-
'Run \'webdriver-manager update\' to download binaries.');
65+
logger, 'Run \'webdriver-manager update\' to download binaries.');
7166
}
7267
}
7368

@@ -79,27 +74,19 @@ export class Direct extends DriverProvider {
7974
}
8075

8176
let chromeService = new ChromeServiceBuilder(chromeDriverFile).build();
82-
// driver = ChromeDriver.createSession(new Capabilities(this.config_.capabilities),
83-
// chromeService);
84-
// TODO(ralphj): fix typings
85-
driver =
86-
require('selenium-webdriver/chrome')
87-
.Driver.createSession(new Capabilities(this.config_.capabilities), chromeService);
77+
driver = DriverForChrome.createSession(
78+
new Capabilities(this.config_.capabilities), chromeService);
8879
break;
8980
case 'firefox':
9081
let geckoDriverFile: string;
9182
if (this.config_.geckoDriver) {
9283
geckoDriverFile = this.config_.geckoDriver;
9384
} else {
9485
try {
95-
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
96-
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
97-
geckoDriverFile = updateConfig.gecko.last;
86+
geckoDriverFile = new GeckoDriver().getBinaryPath();
9887
} catch (e) {
9988
throw new BrowserError(
100-
logger,
101-
'Could not find update-config.json. ' +
102-
'Run \'webdriver-manager update\' to download binaries.');
89+
logger, 'Run \'webdriver-manager update\' to download binaries.');
10390
}
10491
}
10592

@@ -110,14 +97,9 @@ export class Direct extends DriverProvider {
11097
'. Run \'webdriver-manager update\' to download binaries.');
11198
}
11299

113-
// TODO (mgiambalvo): Turn this into an import when the selenium typings are updated.
114-
const FirefoxServiceBuilder = require('selenium-webdriver/firefox').ServiceBuilder;
115-
116100
let firefoxService = new FirefoxServiceBuilder(geckoDriverFile).build();
117-
// TODO(mgiambalvo): Fix typings.
118-
driver =
119-
require('selenium-webdriver/firefox')
120-
.Driver.createSession(new Capabilities(this.config_.capabilities), firefoxService);
101+
driver = DriverForFirefox.createSession(
102+
new Capabilities(this.config_.capabilities), firefoxService);
121103
break;
122104
default:
123105
throw new BrowserError(

‎lib/driverProviders/local.ts

+9-26
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
* so that we only start the local selenium once per entire launch.
88
*/
99
import * as fs from 'fs';
10-
import * as path from 'path';
10+
import {SeleniumServer} from 'selenium-webdriver/remote';
11+
import {ChromeDriver, GeckoDriver, SeleniumServer as WdmSeleniumServer} from 'webdriver-manager-replacement';
1112

1213
import {Config} from '../config';
1314
import {BrowserError, ConfigError} from '../exitCodes';
1415
import {Logger} from '../logger';
1516

1617
import {DriverProvider} from './driverProvider';
1718

18-
const SeleniumConfig = require('webdriver-manager/built/lib/config').Config;
19-
const remote = require('selenium-webdriver/remote');
20-
2119
let logger = new Logger('local');
2220

2321
export class Local extends DriverProvider {
@@ -37,14 +35,9 @@ export class Local extends DriverProvider {
3735
'Attempting to find the SeleniumServerJar in the default ' +
3836
'location used by webdriver-manager');
3937
try {
40-
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
41-
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
42-
this.config_.seleniumServerJar = updateConfig.standalone.last;
38+
this.config_.seleniumServerJar = new WdmSeleniumServer().getBinaryPath();
4339
} catch (err) {
44-
throw new BrowserError(
45-
logger,
46-
'No update-config.json found.' +
47-
' Run \'webdriver-manager update\' to download binaries.');
40+
throw new BrowserError(logger, 'Run \'webdriver-manager update\' to download binaries.');
4841
}
4942
}
5043
if (!fs.existsSync(this.config_.seleniumServerJar)) {
@@ -60,14 +53,9 @@ export class Local extends DriverProvider {
6053
'location used by webdriver-manager');
6154

6255
try {
63-
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
64-
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
65-
this.config_.chromeDriver = updateConfig.chrome.last;
56+
this.config_.chromeDriver = new ChromeDriver().getBinaryPath();
6657
} catch (err) {
67-
throw new BrowserError(
68-
logger,
69-
'No update-config.json found. ' +
70-
'Run \'webdriver-manager update\' to download binaries.');
58+
throw new BrowserError(logger, 'Run \'webdriver-manager update\' to download binaries.');
7159
}
7260
}
7361

@@ -91,14 +79,9 @@ export class Local extends DriverProvider {
9179
'location used by webdriver-manager');
9280

9381
try {
94-
let updateJson = path.resolve(SeleniumConfig.getSeleniumDir(), 'update-config.json');
95-
let updateConfig = JSON.parse(fs.readFileSync(updateJson).toString());
96-
this.config_.geckoDriver = updateConfig.gecko.last;
82+
this.config_.geckoDriver = new GeckoDriver().getBinaryPath();
9783
} catch (err) {
98-
throw new BrowserError(
99-
logger,
100-
'No update-config.json found. ' +
101-
'Run \'webdriver-manager update\' to download binaries.');
84+
throw new BrowserError(logger, 'Run \'webdriver-manager update\' to download binaries.');
10285
}
10386
}
10487

@@ -152,7 +135,7 @@ export class Local extends DriverProvider {
152135
serverConf.jvmArgs.push('-Dwebdriver.gecko.driver=' + this.config_.geckoDriver);
153136
}
154137

155-
this.server_ = new remote.SeleniumServer(this.config_.seleniumServerJar, serverConf);
138+
this.server_ = new SeleniumServer(this.config_.seleniumServerJar, serverConf);
156139

157140
// start local server, grab hosted address, and resolve promise
158141
const url = await this.server_.start(this.config_.seleniumServerStartTimeout);

‎package-lock.json

+122-358
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
"selenium-webdriver": "3.6.0",
2424
"source-map-support": "~0.4.0",
2525
"webdriver-js-extender": "2.1.0",
26-
"webdriver-manager": "^12.0.6",
27-
"webdriver-manager-replacement": "^1.1.0"
26+
"webdriver-manager-replacement": "^1.1.1"
2827
},
2928
"devDependencies": {
3029
"@types/node": "^6.0.46",

0 commit comments

Comments
 (0)
This repository has been archived.