Skip to content

Commit 27b4902

Browse files
authored
QACOE-226: added NightwatchJS folder (#9)
1 parent 87f994a commit 27b4902

File tree

4 files changed

+307
-0
lines changed

4 files changed

+307
-0
lines changed

nightwatchJS/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
chromedriver.log
3+
geckodriver.log
4+
tests_output

nightwatchJS/nightwatch.conf.js

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
// Autogenerated by Nightwatch
2+
// Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/
3+
const Services = {}; loadServices();
4+
5+
module.exports = {
6+
// An array of folders (excluding subfolders) where your tests are located;
7+
// if this is not specified, the test source must be passed as the second argument to the test runner.
8+
src_folders: [],
9+
10+
// See https://nightwatchjs.org/guide/working-with-page-objects/
11+
page_objects_path: '',
12+
13+
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
14+
custom_commands_path: '',
15+
16+
// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
17+
custom_assertions_path: '',
18+
19+
// See https://nightwatchjs.org/guide/#external-globals
20+
globals_path : '',
21+
22+
webdriver: {},
23+
24+
test_settings: {
25+
default: {
26+
disable_error_log: false,
27+
launch_url: 'https://nightwatchjs.org',
28+
29+
screenshots: {
30+
enabled: false,
31+
path: 'screens',
32+
on_failure: true
33+
},
34+
35+
desiredCapabilities: {
36+
browserName : 'chrome'
37+
},
38+
39+
webdriver: {
40+
start_process: true,
41+
server_path: (Services.chromedriver ? Services.chromedriver.path : '')
42+
}
43+
},
44+
45+
safari: {
46+
desiredCapabilities : {
47+
browserName : 'safari',
48+
alwaysMatch: {
49+
acceptInsecureCerts: false
50+
}
51+
},
52+
webdriver: {
53+
port: 4445,
54+
start_process: true,
55+
server_path: '/usr/bin/safaridriver'
56+
}
57+
},
58+
59+
firefox: {
60+
desiredCapabilities : {
61+
browserName : 'firefox',
62+
alwaysMatch: {
63+
acceptInsecureCerts: true,
64+
'moz:firefoxOptions': {
65+
args: [
66+
// '-headless',
67+
// '-verbose'
68+
]
69+
}
70+
}
71+
72+
},
73+
webdriver: {
74+
start_process: true,
75+
port: 4444,
76+
server_path: (Services.geckodriver ? Services.geckodriver.path : ''),
77+
cli_args: [
78+
// very verbose geckodriver logs
79+
// '-vv'
80+
]
81+
}
82+
},
83+
84+
chrome: {
85+
desiredCapabilities : {
86+
browserName : 'chrome',
87+
'goog:chromeOptions' : {
88+
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
89+
//
90+
// This tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
91+
w3c: false,
92+
args: [
93+
//'--no-sandbox',
94+
//'--ignore-certificate-errors',
95+
//'--allow-insecure-localhost',
96+
//'--headless'
97+
]
98+
}
99+
},
100+
101+
webdriver: {
102+
start_process: true,
103+
port: 9515,
104+
server_path: (Services.chromedriver ? Services.chromedriver.path : ''),
105+
cli_args: [
106+
// --verbose
107+
]
108+
}
109+
},
110+
111+
edge: {
112+
desiredCapabilities : {
113+
browserName : 'MicrosoftEdge',
114+
'ms:edgeOptions' : {
115+
w3c: false,
116+
// More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
117+
args: [
118+
//'--headless'
119+
]
120+
}
121+
},
122+
123+
webdriver: {
124+
start_process: true,
125+
// Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
126+
// and set the location below:
127+
server_path: '',
128+
cli_args: [
129+
// --verbose
130+
]
131+
}
132+
},
133+
134+
//////////////////////////////////////////////////////////////////////////////////
135+
// Configuration for when using the browserstack.com cloud service |
136+
// |
137+
// Please set the username and access key by setting the environment variables: |
138+
// - BROWSERSTACK_USER |
139+
// - BROWSERSTACK_KEY |
140+
// .env files are supported |
141+
//////////////////////////////////////////////////////////////////////////////////
142+
browserstack: {
143+
selenium: {
144+
host: 'hub-cloud.browserstack.com',
145+
port: 443
146+
},
147+
// More info on configuring capabilities can be found on:
148+
// https://www.browserstack.com/automate/capabilities?tag=selenium-4
149+
desiredCapabilities: {
150+
'bstack:options' : {
151+
userName: '${BROWSERSTACK_USER}',
152+
accessKey: '${BROWSERSTACK_KEY}',
153+
}
154+
},
155+
156+
disable_error_log: true,
157+
webdriver: {
158+
timeout_options: {
159+
timeout: 15000,
160+
retry_attempts: 3
161+
},
162+
keep_alive: true,
163+
start_process: false
164+
}
165+
},
166+
167+
'browserstack.local': {
168+
extends: 'browserstack',
169+
desiredCapabilities: {
170+
'browserstack.local': true
171+
}
172+
},
173+
174+
'browserstack.chrome': {
175+
extends: 'browserstack',
176+
desiredCapabilities: {
177+
browserName: 'chrome',
178+
chromeOptions : {
179+
w3c: false
180+
}
181+
}
182+
},
183+
184+
'browserstack.firefox': {
185+
extends: 'browserstack',
186+
desiredCapabilities: {
187+
browserName: 'firefox'
188+
}
189+
},
190+
191+
'browserstack.ie': {
192+
extends: 'browserstack',
193+
desiredCapabilities: {
194+
browserName: 'internet explorer',
195+
browserVersion: '11.0'
196+
}
197+
},
198+
199+
'browserstack.safari': {
200+
extends: 'browserstack',
201+
desiredCapabilities: {
202+
browserName: 'safari'
203+
}
204+
},
205+
206+
'browserstack.local_chrome': {
207+
extends: 'browserstack.local',
208+
desiredCapabilities: {
209+
browserName: 'chrome'
210+
}
211+
},
212+
213+
'browserstack.local_firefox': {
214+
extends: 'browserstack.local',
215+
desiredCapabilities: {
216+
browserName: 'firefox'
217+
}
218+
},
219+
//////////////////////////////////////////////////////////////////////////////////
220+
// Configuration for when using the Selenium service, either locally or remote, |
221+
// like Selenium Grid |
222+
//////////////////////////////////////////////////////////////////////////////////
223+
selenium_server: {
224+
// Selenium Server is running locally and is managed by Nightwatch
225+
selenium: {
226+
start_process: true,
227+
port: 4444,
228+
server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
229+
cli_args: {
230+
'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
231+
'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '')
232+
}
233+
}
234+
},
235+
236+
'selenium.chrome': {
237+
extends: 'selenium_server',
238+
desiredCapabilities: {
239+
browserName: 'chrome',
240+
chromeOptions : {
241+
w3c: false
242+
}
243+
}
244+
},
245+
246+
'selenium.firefox': {
247+
extends: 'selenium_server',
248+
desiredCapabilities: {
249+
browserName: 'firefox',
250+
'moz:firefoxOptions': {
251+
args: [
252+
// '-headless',
253+
// '-verbose'
254+
]
255+
}
256+
}
257+
}
258+
}
259+
};
260+
261+
function loadServices() {
262+
try {
263+
Services.seleniumServer = require('selenium-server');
264+
} catch (err) {}
265+
266+
try {
267+
Services.chromedriver = require('chromedriver');
268+
} catch (err) {}
269+
270+
try {
271+
Services.geckodriver = require('geckodriver');
272+
} catch (err) {}
273+
}

nightwatchJS/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "nightwatchjs",
3+
"version": "1.0.0",
4+
"description": "Test 'https://www.ecosia.org/' web application using NightwatchJS ",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "chanaggonda",
10+
"license": "ISC",
11+
"devDependencies": {
12+
"chromedriver": "^96.0.0",
13+
"geckodriver": "^3.0.1",
14+
"nightwatch": "^1.7.13"
15+
}
16+
}

nightwatchJS/tests/Demo.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
describe('Demo test Ecosia.org', function() {
2+
test('search for nightwatch', function(browser) {
3+
browser
4+
.url('https://www.ecosia.org/')
5+
.waitForElementVisible('body')
6+
.assert.titleContains('Ecosia')
7+
.assert.visible('input[type=search]')
8+
.sendKeys('input[type=search]', 'nightwatch')
9+
.assert.visible('button[type=submit]')
10+
.click('button[type=submit]')
11+
.assert.containsText('.mainline-results', 'Nightwatch.js')
12+
.end();
13+
})
14+
});

0 commit comments

Comments
 (0)