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

chore(ci,webdriverjs): update selenium-webdriver to latest #673

Merged
merged 3 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
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
52 changes: 26 additions & 26 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"chromedriver": "^109.0.0",
"colors": "^1.4.0",
"commander": "^9.4.1",
"selenium-webdriver": "4.3.0"
"selenium-webdriver": "^4.8.1"
},
"devDependencies": {
"@types/chai": "^4.3.3",
Expand Down
31 changes: 15 additions & 16 deletions packages/cli/src/lib/webdriver.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'mocha';
import { assert } from 'chai';
import { startDriver } from './webdriver';
import { WebDriver } from 'selenium-webdriver';
import chromedriver from 'chromedriver';
import chrome from 'selenium-webdriver/chrome';
import type { Options } from 'selenium-webdriver/chrome';
Expand All @@ -9,6 +10,7 @@ import { WebdriverConfigParams } from '../types';
describe('startDriver', () => {
let config: WebdriverConfigParams;
let browser: string;
let driver: WebDriver;
beforeEach(() => {
browser = 'chrome-headless';
config = {
Expand All @@ -19,55 +21,52 @@ describe('startDriver', () => {
});

afterEach(async () => {
const service = chrome.getDefaultService();
if (service.isRunning()) {
await service.kill();
}
await driver.quit();
});

it('creates a driver', async () => {
const driver = await startDriver(config);
driver = await startDriver(config);
assert.isObject(driver);
assert.isFunction(driver.manage);
});

xit('sets the config.browser as the browser', async () => {
browser = 'chrome';
const driver = await startDriver(config);
driver = await startDriver(config);
const capabilities = await driver.getCapabilities();
assert.equal(capabilities.get('browserName'), browser);
});

it('sets the browser as chrome with chrome-headless', async () => {
browser = 'chrome-headless';
const driver = await startDriver(config);
driver = await startDriver(config);
const capabilities = await driver.getCapabilities();

assert.equal(capabilities.get('browserName'), 'chrome');
});

it('uses the chromedriver path with chrome-headless', async () => {
browser = 'chrome-headless';
await startDriver(config);
const service = chrome.getDefaultService();
driver = await startDriver(config);
const chromedriverPath = (config as any).builder.chromeService_.exe_;

assert.equal((service as any).executable_, chromedriver.path);
assert.equal(chromedriverPath, chromedriver.path);
});

it('uses the passed in chromedriver path with chrome-headless', async () => {
browser = 'chrome-headless';
config.chromedriverPath = path.relative(process.cwd(), chromedriver.path);
await startDriver(config);
const service = chrome.getDefaultService();
driver = await startDriver(config);
const chromedriverPath = (config as any).builder.chromeService_.exe_;

assert.notEqual(config.chromedriverPath, chromedriver.path);
assert.equal((service as any).executable_, config.chromedriverPath);
assert.equal(chromedriverPath, config.chromedriverPath);
});

it('passes the --no-sandbox argument to chromeOptions', async () => {
browser = 'chrome-headless';
config.chromeOptions = ['--no-sandbox'];
await startDriver(config);
driver = await startDriver(config);

const options = config?.builder?.getChromeOptions();
assert.isArray(options?.get('goog:chromeOptions').args);
Expand All @@ -80,7 +79,7 @@ describe('startDriver', () => {
it('passes multiple arguments argument to chromeOptions', async () => {
browser = 'chrome-headless';
config.chromeOptions = ['no-sandbox', 'disable-dev-shm-usage'];
await startDriver(config);
driver = await startDriver(config);

const options = config?.builder?.getChromeOptions();
assert.isArray(options?.get('goog:chromeOptions').args);
Expand All @@ -94,7 +93,7 @@ describe('startDriver', () => {
it('sets the --timeout flag', async () => {
browser = 'chrome-headless';
config.timeout = 10000;
const driver = await startDriver(config);
driver = await startDriver(config);
config.builder;
const timeoutValue = await driver.manage().getTimeouts();

Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/lib/webdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const startDriver = async (
if (config.browser === 'chrome-headless') {
const service = new chrome.ServiceBuilder(
config.chromedriverPath || chromedriver.path
).build();
// Pinned to selenium-webdriver@4.3.0
// https://github.com/SeleniumHQ/selenium/pull/10796/files#diff-6c87d95a2288e92e15a6bb17710c763c01c2290e679beb26220858f3218b6a62L260
chrome.setDefaultService(service);
);

let options = new chrome.Options().headless();
if (config.chromeOptions?.length) {
Expand All @@ -24,7 +21,10 @@ const startDriver = async (
}, options);
}

builder = new Builder().forBrowser('chrome').setChromeOptions(options);
builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.setChromeService(service);
} else {
builder = new Builder().forBrowser(config.browser);
}
Expand Down
34 changes: 17 additions & 17 deletions packages/webdriverjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/webdriverjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"mocha": "^10.0.0",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"selenium-webdriver": "4.3.0",
"selenium-webdriver": "^4.8.1",
"sinon": "^14.0.1",
"test-listen": "^1.1.0",
"ts-node": "^10.9.1",
Expand Down