-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added waitForPageToLoad function #57
Merged
Merged
Changes from 14 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
e0113a3
More code cleaning
Marketionist 2cad97b
Added waitForLoaded function
Marketionist 15b4188
Refactored wdio.conf.js to use steps.conf.js
Marketionist 13ab29a
Added 'I click' step and test
Marketionist 377ee6f
Renamed waitForPageToLoad()
Marketionist 5e3c0e9
Refactored stepsConfig for global usage
Marketionist e323c9b
Fixed mocha tests to include stepsConfig
Marketionist 5d262b4
We should not ignore .vscode/settings.json file
alexkrechik 2942a0b
Fixed finishedLoadingConditions function
alexkrechik fa124c4
Fixed I click ${pageObject}$ method
alexkrechik 0828574
Attempt to add .vscode folder
alexkrechik 7cb8cd9
Added vscode settings.json file
alexkrechik 9bb36e3
Removed unnecessary waiter in the end of feature
alexkrechik 7a127c2
Separate steps config logic and values provided.
alexkrechik c0d1f18
Apply commands via applyStepsCommands function
alexkrechik 81bbe4e
Using of config finishedLoadingConditions
alexkrechik 46c7cc9
Using of const were possible
alexkrechik d1fed7e
Using Class for Id. Fixed mocha tests.
alexkrechik 21ce939
Some fixes due to Dima's review
alexkrechik 475207b
Use ecmaVersion: 2017 for linting
Marketionist bfdd711
Refactored 'I click' step to use async await
Marketionist 32073a5
Switched to node.js 7 to use async await
Marketionist ad08727
Updated tests to be more descriptive
Marketionist 09d9d3b
Refactored When steps to use async await
Marketionist fd00403
Refactored Then steps to use async await
Marketionist 0e4594a
Refactored Given steps to use async await
Marketionist c535e88
Added moveToObject for click
Marketionist 032f67e
Added 'I doubleclick' step
Marketionist 8fe45b3
Used scroll and 2 clicks for steps with clicks
Marketionist a6d411a
Bumped up wdio-cucumber-framework: ^1.1.0, wdio-selenium-standalone-s…
Marketionist 07437d0
Added checkbox with some js for tests
Marketionist 493fab5
Added tests for 'I click', 'I doubleclick' steps
Marketionist d551cbd
Updated new-page with text block for doubleclick
Marketionist 9b9cbff
Returned to moveToObject and doubleClick as it is not depricated
Marketionist e53491e
Updated tests for click and doubleclick
Marketionist d0b0266
Added loaders to new-page
Marketionist f906ad9
Added loaders scripts, styles, images
Marketionist 297edb9
Added tests for waitForPageToLoad
Marketionist 96bfce4
Used executeAsync in waitForPageToLoad
Marketionist 3883fac
Added promise to waitForPageToLoad
Marketionist 352a59b
Added loadingFinished
Marketionist 821262f
Refactored defaultFinishedLoadingConditions
Marketionist c6f9593
Fixed loaderSelectore visibility issues.
alexkrechik 61bc704
Fixed defaultFinishedLoadingConditions returnvalue
alexkrechik 069847e
Fixed waitForPageToLoad function
alexkrechik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,34 @@ | ||
/* global stepsConfig */ | ||
|
||
module.exports = function waitForPageToLoad (callback) { | ||
/** | ||
* Wait for page to get fully loaded | ||
* @param {callback} callback - A callback to run | ||
*/ | ||
const timeout = 100; | ||
let loaderSelectors = stepsConfig.loaderSelectors; | ||
|
||
let finishedLoadingConditions = function () { | ||
// 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 !loaderSelectors.some((selector) => browser.execute((s) => document.querySelector(s), selector)); | ||
}; | ||
|
||
// If loading of the page was finished - launch callback function | ||
if (finishedLoadingConditions()) { | ||
callback(); | ||
} | ||
|
||
// If loading of the page was not finished - relaunch finishedLoadingConditions() each 100 ms | ||
let interval = setInterval(function () { | ||
if (finishedLoadingConditions()) { | ||
clearInterval(interval); | ||
callback(); | ||
} | ||
}, timeout); | ||
|
||
}; |
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,36 @@ | ||
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 !loaderSelectors.some((selector) => browser.execute((s) => document.querySelector(s), selector)); | ||
}; | ||
|
||
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 = { | ||
value: defaultIdValue || idGenerator.call(this), | ||
getId: () => this.value, | ||
regenerate: () => { | ||
this.value = idGenerator.call(this); | ||
} | ||
}; | ||
|
||
return { | ||
loaderSelectors, | ||
finishedLoadingConditions: finishedLoadingConditions.bind(this, loaderSelectors), | ||
pages, | ||
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
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,16 @@ | ||
// Array of selectors for loaders that appear when page is loaded or XHR/AJAX requests are done | ||
const loaderSelectors = [ | ||
'div:not([style*="display: none"])[class*="test-loader"]', | ||
'div:not([style*="visibility: hidden"])[class*="test-loader"]' | ||
]; | ||
|
||
// Object that contains pathes to all page objects used for tests | ||
const pages = { | ||
main: require('./features/page_objects/main'), | ||
values: require('./features/dictionary_objects/values') | ||
}; | ||
|
||
module.exports = { | ||
loaderSelectors, | ||
pages | ||
}; |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should rename this file to something like
steps.helper.functions.js
(because it looks more like a file with logic then config and we also have a second file with the same name intest/steps.conf.js
- and it looks like a real config file more)?