-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from revjet-qa/feature/wait-for-loaded
Added waitForPageToLoad function
- Loading branch information
Showing
27 changed files
with
373 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"ecmaVersion": 2017, | ||
"sourceType": "module" | ||
}, | ||
"env": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"cucumberautocomplete.steps": [ | ||
"src/steps/*.js" | ||
], | ||
"cucumberautocomplete.syncfeatures": "test/features/*feature", | ||
"cucumberautocomplete.strictGherkinCompletion": true, | ||
"cucumberautocomplete.smartSnippets": true, | ||
"cucumberautocomplete.stepsInvariants": true, | ||
"cucumberautocomplete.customParameters": [ | ||
{ | ||
"parameter":"(_r(", | ||
"value":"(" | ||
}, | ||
{ | ||
"parameter":"${dictionaryObject}", | ||
"value":"([a-zA-Z0-9_-]+ from [a-zA-Z0-9_-]+ dictionary|\"[^\"]*\")" | ||
}, | ||
{ | ||
"parameter":"${pageObject}", | ||
"value":"([a-zA-Z0-9_-]+ from [a-zA-Z0-9_-]+ page)" | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const waitForPageToLoad = require('./wait.for.page.to.load'); | ||
|
||
module.exports = function applyCommands () { | ||
browser.addCommand('waitForPageToLoad', waitForPageToLoad); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* global stepsConfig */ | ||
|
||
module.exports = function waitForPageToLoad () { | ||
/** | ||
* Wait for page to get fully loaded | ||
* @param {callback} callback - A callback to run | ||
*/ | ||
return browser.waitUntil(stepsConfig.finishedLoadingConditions); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const defaultFinishedLoadingConditions = (loaderSelectors) => { | ||
// Check if jQuery is present on the page and if any XMLHttpRequests (AJAX) are in progress | ||
if (typeof $ !== 'undefined' && $.active) { | ||
return false; | ||
} | ||
|
||
// Check if any loaders are still present on the page | ||
return browser.executeAsync((selectors, done) => { | ||
done(!selectors.some((selector) => { | ||
return document.querySelector(selector); | ||
})); | ||
}, loaderSelectors).value; | ||
|
||
}; | ||
|
||
const defaultIdGenerator = () => (new Date()).getTime(); | ||
|
||
module.exports = function ({ | ||
loaderSelectors = [], // <string>[] - array of xpath selectors, that will be used by finishedLoadingConditions. | ||
finishedLoadingConditions = defaultFinishedLoadingConditions, // <(loaderSelectors) => <boolean>>. | ||
pages = {}, // <{[key: string]: {[key: string]: <string>}}> - object, that contains "key" -> "Page object" pairs. | ||
defaultIdValue = '', // Default value of steps config Id. | ||
idGenerator = defaultIdGenerator, // <() => <string|number>> - function, that will return new generated id. | ||
objectsProcessor = {} // objectsProcessor childs could be previded here - see objects.processor.js for more details. | ||
}) { | ||
const Id = class { | ||
constructor () { | ||
this.value = defaultIdValue || idGenerator.call(this); | ||
} | ||
get idValue () { | ||
return this.value; | ||
} | ||
regenerate () { | ||
this.value = idGenerator.call(this); | ||
} | ||
}; | ||
|
||
return { | ||
loaderSelectors, | ||
finishedLoadingConditions: finishedLoadingConditions.bind(this, loaderSelectors), | ||
pages, | ||
id: new Id(), | ||
objectsProcessor | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.