Skip to content

Commit 3c08ca8

Browse files
committed
Merge pull request #1 from browserstack/nightwatch
Adding nightwatch.js sample code
2 parents 59e0b37 + 3deeec0 commit 3c08ca8

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

nightwatch/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
BrowserStack-nightwatch
2+
=========
3+
4+
Sample for using nightwatch with BrowserStack Automate.
5+
6+
###Install nightwatch.js
7+
*Starting and pre-requite: [nightwatch]*
8+
- `npm install -g nightwatch`
9+
10+
###Configuring the json
11+
- Open `settings.json`
12+
- Add `browserstack.user` and `browserstack.key` with your BrowserStack credentials. Don't have one? Get one on BrowserStack [dashboard]
13+
- Add / customise more [capabilities] to `desiredCapabilities` in `settings.json`
14+
15+
###Sample test
16+
- Path: `tests/google/googleTest.js`
17+
- To run: `nightwatch -t ./tests/google/googleTest.js -c ./settings.json`
18+
19+
[nightwatch]:http://nightwatchjs.org/guide
20+
[capabilities]:http://www.browserstack.com/automate/capabilities
21+
[dashboard]:https://www.browserstack.com/automate

nightwatch/settings.json

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"src_folders" : ["tests/"],
3+
4+
"selenium" : {
5+
"start_process" : false,
6+
"host" : "hub.browserstack.com",
7+
"port" : 80
8+
},
9+
10+
"test_settings" : {
11+
"default" : {
12+
"launch_url" : "http://hub.browserstack.com",
13+
"selenium_port" : 80,
14+
"selenium_host" : "hub.browserstack.com",
15+
"silent": true,
16+
"screenshots" : {
17+
"enabled" : false,
18+
"path" : ""
19+
},
20+
"desiredCapabilities": {
21+
"browserName": "firefox",
22+
"javascriptEnabled": true,
23+
"acceptSslCerts": true,
24+
"browserstack.user": "USERNAME",
25+
"browserstack.key": "KEY"
26+
}
27+
}
28+
}
29+
}

nightwatch/tests/google/googleTest.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
"Demo test Google" : function (browser) {
3+
browser
4+
.url("http://www.google.com")
5+
.waitForElementVisible('body', 1000)
6+
.setValue('input[type=text]', 'nightwatch')
7+
.waitForElementVisible('button[name=btnG]', 1000)
8+
.click('button[name=btnG]')
9+
.pause(1000)
10+
.assert.containsText('#main', 'The Night Watch')
11+
.end();
12+
}
13+
};

0 commit comments

Comments
 (0)