Skip to content
This repository has been archived by the owner on Jan 3, 2019. It is now read-only.

Commit

Permalink
feat: add configuration option for selenium timeouts
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #30
  • Loading branch information
clebert committed Apr 4, 2017
1 parent c4a6bbd commit 84858cc
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -95,7 +95,8 @@ The following configuration is active by default:
"include": "**/*.e2e.js",
"retries": 4,
"retryDelay": 500,
"screenshotDirectory": "screenshots"
"screenshotDirectory": "screenshots",
"timeouts": {"element": 0, "page": 30000, "script": 30000}
}
```

Expand Down
26 changes: 26 additions & 0 deletions config-schema.json
Expand Up @@ -65,6 +65,32 @@
"screenshotDirectory": {
"type": "string",
"minLength": 1
},
"timeouts": {
"type": "object",
"properties": {
"element": {
"type": "number",
"minimum": 0,
"multipleOf": 1
},
"page": {
"type": "number",
"minimum": 0,
"multipleOf": 1
},
"script": {
"type": "number",
"minimum": 0,
"multipleOf": 1
}
},
"required": [
"element",
"page",
"script"
],
"additionalProperties": false
}
},
"additionalProperties": false
Expand Down
3 changes: 2 additions & 1 deletion fixtures/config.js
Expand Up @@ -6,5 +6,6 @@ module.exports = {
include: '*.js',
retries: 3,
retryDelay: 1000,
screenshotDirectory: '/dev/null'
screenshotDirectory: '/dev/null',
timeouts: {element: 123, page: 456, script: 789}
};
2 changes: 2 additions & 0 deletions src/__tests__/index.test.ts
Expand Up @@ -18,6 +18,7 @@ Config:
retries: 3
retryDelay: 1000
screenshotDirectory: '/dev/null'
timeouts: { element: 123, page: 456, script: 789 }
`;

const defaultStderr = `
Expand All @@ -30,6 +31,7 @@ Config:
retries: 4
retryDelay: 500
screenshotDirectory: 'screenshots'
timeouts: { element: 0, page: 30000, script: 30000 }
`;

let customResult: Result;
Expand Down
10 changes: 9 additions & 1 deletion src/config.ts
Expand Up @@ -3,6 +3,12 @@ import Ajv = require('ajv');
import {resolve} from 'path';
import {inspect} from 'util';

export interface Timeouts {
readonly element: number;
readonly page: number;
readonly script: number;
}

export interface Config {
readonly capabilities: object;
readonly concurrency: number;
Expand All @@ -12,6 +18,7 @@ export interface Config {
readonly retries: number;
readonly retryDelay: number;
readonly screenshotDirectory: string;
readonly timeouts: Timeouts;
}

const defaultConfig: Config = {
Expand All @@ -22,7 +29,8 @@ const defaultConfig: Config = {
include: '**/*.e2e.js',
retries: 4,
retryDelay: 500,
screenshotDirectory: 'screenshots'
screenshotDirectory: 'screenshots',
timeouts: {element: 0, page: 30000, script: 30000}
};

const configFilename = process.argv[2];
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Expand Up @@ -74,6 +74,12 @@ export function test(name: string, implementation?: Implementation): void {
).build();

try {
const {element, page, script} = config.timeouts;

await driver.manage().timeouts().implicitlyWait(element);
await driver.manage().timeouts().pageLoadTimeout(page);
await driver.manage().timeouts().setScriptTimeout(script);

await implementation(new TapTest(driver, t));
} finally {
await driver.quit();
Expand Down

0 comments on commit 84858cc

Please sign in to comment.