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

fix(cli): add timeout to webdriver.js #47

Merged
merged 4 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 1 addition & 2 deletions packages/cli/lib/axe-test-urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const AxeBuilder = require('axe-webdriverjs');

function testPages(urls, config, events) {
const driver = config.driver;
const scriptTimeout = (config.timeout || 20) * 1000.0;
driver.manage().setTimeouts({ script: scriptTimeout });

// End of the line, no more page left
if (urls.length === 0) {
driver.quit();
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/lib/webdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ const chromedriver = require('chromedriver');
const { Builder, Capabilities } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

function startDriver(config) {
async function startDriver(config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me this could be solved without a breaking change, by having ADT itself call setTimeouts. I don't think we should introduce a breaking change like this if we can avoid it. Seems unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a necessary change since axe core cli have a default value for settimeout and if we move it into this file it wouldn't get called since we pass in our driver instance from adt/cli -> axe-core cli

const scriptTimeout = (config.timeout || 20) * 1000.0;
let builder;

if (config.browser === 'chrome-headless') {
// Tell selenium use the driver in node_modules
const service = new chrome.ServiceBuilder(
Expand All @@ -15,7 +17,6 @@ function startDriver(config) {
if (config.chromeOptions) {
args.push(...config.chromeOptions);
}

const chromeCapabilities = Capabilities.chrome();
chromeCapabilities.set('chromeOptions', { args });

Expand All @@ -28,7 +29,9 @@ function startDriver(config) {
// Launch a browser
config.driver = builder.build();
config.builder = builder;
return config.driver

await config.driver.manage().setTimeouts({ script: scriptTimeout })
return config.driver;
}

module.exports = {
Expand Down
Loading