Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
node_modules
npm_debug.log
Screenshots
Expand Down
13 changes: 7 additions & 6 deletions nightwatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"globals_path" : "",

"selenium" : {
"start_process" : false,
"server_path" : "",
"log_path" : "",
"start_process" : true,
"server_path" : "./bin/selenium.jar",
"log_path" : "./reports",
"port" : 4444,
"cli_args" : {
"webdriver.chrome.driver" : "",
"webdriver.chrome.driver" : "./bin/chromedriver",
"webdriver.gecko.driver" : "",
"webdriver.edge.driver" : ""
}
Expand All @@ -25,11 +25,12 @@
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"enabled" : true,
"path" : ""
},
"desiredCapabilities": {
"browserName": "chrome"
"browserName": "chrome",
"javascriptEnabled": true
}
},

Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"author": "Kalefive",
"main": "server.js",
"scripts": {
"start": "node server.js"
"start": "node server.js",
"test": "nightwatch",
"e2e:setup": "node selenium-setup"
},
"dependencies": {
"blink-diff": "^1.0.13",
Expand All @@ -15,6 +17,7 @@
"geckodriver": "^1.9.0",
"nightwatch": "^0.9.16",
"node-inspector": "^1.1.1",
"selenium-download": "^2.0.10",
"selenium-webdriver": "^3.5.0"
}
}
6 changes: 6 additions & 0 deletions selenium-setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const selenium = require('selenium-download');

selenium.ensure(__dirname + '/bin', function (error) {
if (error) console.error(error.stack);
process.exit(0);
});
5 changes: 3 additions & 2 deletions tests/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ module.exports = {
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.waitForElementVisible('input[value="Google Search"]', 1000)
.saveScreenshot('./reports/homepage.png')
.click('input[value="Google Search"]')
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end();
Expand Down
23 changes: 23 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {

//Each "export" counts as one test case
'index': browser => {

//We direct our browser to the google homepage, and wait for it to load
browser.url('http://google.com')
.waitForElementVisible('body', 1000)

// We then test to see that the "Search" button is visible
browser.assert.elementPresent('input[value="Google Search"]')

//We then fill the search bar with the word "Nightwatch"
browser.setValue('#lst-ib', 'Nightwatch')

//then, we click on "Search", and wait for the search results to appear
browser.click('input[value="Google Search"]')
.waitForElementVisible('#resultStats', 1000)

//Once thats done, we close the browser
browser.end()
}
}