Merge pull request #474 from kiwix/more-complete-scenario-for-UI-tests

More complete scenario for ui tests
This commit is contained in:
Mossroy 2019-02-26 16:17:34 +01:00 committed by GitHub
commit 088b7b92fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 82 additions and 2 deletions

View File

@ -13,6 +13,7 @@ script:
# The free account on Sauce does not allow more than 5 concurrent sessions (including the main one)
# So we separate the recent and old browsers in order to respect this limit.
- "./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env firefox,chrome,edge"
- "./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env edge40,edge42"
- "./node_modules/nightwatch/bin/nightwatch -c nightwatch.js --env firefox45,chrome58,ie11"
- pkill node
deploy:

View File

@ -1,4 +1,5 @@
# Kiwix JS
[![Build Status](https://travis-ci.org/kiwix/kiwix-js.svg?branch=master)](https://travis-ci.org/kiwix/kiwix-js)
## Summary
Kiwix is an offline Wikipedia viewer. See the official site: https://www.kiwix.org/

View File

@ -39,6 +39,7 @@ module.exports = {
browser
.url('http://localhost:8080/')
.waitForElementVisible('#archiveFiles', 20000)
// Select the ZIM archive of Ray Charles
.execute(function() {
window.setRemoteArchives('http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimaa',
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimab',
@ -57,18 +58,75 @@ module.exports = {
'http://localhost:8080/tests/wikipedia_en_ray_charles_2015-06.zimao'
);
})
.waitForElementVisible('#formArticleSearch', 20000)
.waitForElementVisible('#searchArticles', 20000)
// Hide the bottom bar, so that it is not above any content
.execute(function(vis){
var footer = document.getElementsByTagName('footer')[0];
footer.style.visibility=vis;
},['hidden']
)
// Start a search with the prefix "Ray"
.setValue('#prefix', "Ray")
.click('#searchArticles')
.waitForElementVisible('#articleList', 20000)
// Choose the article "Ray Charles"
.useXpath()
.waitForElementVisible("//div[@id='articleList']/a[text()='Ray Charles']", 20000)
.click("//div[@id='articleList']/a[text()='Ray Charles']")
.useXpath()
.frame('articleContent')
.waitForElementPresent("//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']", 2000000)
// Check the text in the article "Ray Charles"
.useXpath()
.waitForElementPresent("//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']", 40000)
.assert.containsText("//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']", 'Life and career')
// Wait for a particular image to be visible and check its size
.useXpath()
.waitForElementVisible("//td[@id='mwCA']/p/span/img", 20000)
.assert.attributeEquals("//td[@id='mwCA']/p/span/img", "naturalWidth", "250")
// Check the CSS style
.useCss()
.waitForElementVisible('#mwBA', 20000)
.assert.cssProperty("#mwBA", "float", "right");
// For some reason, the following UI tests work on Edge 42 (version 17.x),
// but not on Edge 40 (version 15.x), where it fails with "Error while running "waitForElementPresent" command: Timed out while waiting for element <//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']> to be present for 40000 milliseconds. - expected "found" but got: "not found" ",
// and Edge 44 (version 18.x), where it fails with "An error occurred while running .getText() command on <//div[@id='content']/div[@id='mw-content-text']/blockquote[@id='mwnw']>: An unknown error occurred while processing the specified command. (WARNING: The server did not provide any stacktrace information)".
// When Microsoft will release a new version of Edge (based on Chromium), we should let the tests run when version is not set (see if statement below).
if (browser.options.desiredCapabilities.browserName !== "MicrosoftEdge"
|| (browser.options.desiredCapabilities.version
&& browser.options.desiredCapabilities.version !== "15.15063")) {
// Click on a hypertext link to another article "Quincy Jones"
browser.waitForElementVisible('#mwBTI', 20000)
.click("#mwBTI")
// Check the text of the article "Quincy Jones"
.useXpath()
.waitForElementPresent("//div[@id='content']/div[@id='mw-content-text']/blockquote[@id='mwnw']", 40000)
.assert.containsText("//div[@id='content']/div[@id='mw-content-text']/blockquote[@id='mwnw']", 'perspective of past, present and future')
// Wait for a particular image to be visible and check its size
.useCss()
.waitForElementVisible("#mwAiI", 20000)
.assert.attributeEquals("#mwAiI", "naturalWidth", "180")
// Check the CSS style
.waitForElementVisible('#mwBA', 20000)
.assert.cssProperty("#mwBA", "float", "right")
// Use the back button of the browser, to go back to "Ray Charles" article
.back()
.frameParent()
.frame('articleContent')
// Check the text in the article "Ray Charles"
.useXpath()
.waitForElementPresent("//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']", 40000)
.assert.containsText("//div[@id='content']/div[@id='mw-content-text']/h2[@id='mweQ']", 'Life and career')
// Wait for a particular image to be visible and check its size
.useXpath()
.waitForElementVisible("//td[@id='mwCA']/p/span/img", 20000)
.assert.attributeEquals("//td[@id='mwCA']/p/span/img", "naturalWidth", "250")
.end();
}
}
};

View File

@ -93,6 +93,26 @@ module.exports = {
"tunnel-identifier": TRAVIS_JOB_NUMBER
}
},
"edge40" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"version": "15.15063",
"javascriptEnabled": true,
"acceptSslCerts": true,
"build": "build-" + TRAVIS_JOB_NUMBER,
"tunnel-identifier": TRAVIS_JOB_NUMBER
}
},
"edge42" : {
"desiredCapabilities": {
"browserName": "MicrosoftEdge",
"version": "17.17134",
"javascriptEnabled": true,
"acceptSslCerts": true,
"build": "build-" + TRAVIS_JOB_NUMBER,
"tunnel-identifier": TRAVIS_JOB_NUMBER
}
},
"ie11" : {
"desiredCapabilities": {
"browserName": "internet explorer",