webship-js 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.circleci/config.yml +15 -8
  2. package/.github/workflows/github-actions.yml +13 -10
  3. package/.gitlab-ci.yml +1 -0
  4. package/.travis-ci.yml +0 -0
  5. package/README.md +1 -1
  6. package/assets/config_templates/circleci-linux-chrome.conf.js +100 -0
  7. package/assets/config_templates/github-linux-chrome.conf.js +111 -0
  8. package/{bitbucket-pipelines.yml → bitbucket-pipelines-test.yml} +0 -0
  9. package/examples/about-us.html +10 -0
  10. package/examples/contact-us.html +10 -0
  11. package/examples/index.html +26 -0
  12. package/examples/main.js +17 -0
  13. package/examples/test--when--i-fill-in.html +48 -0
  14. package/examples/test--when--i-follow-link.html +18 -0
  15. package/examples/test--when--i-press-button.html +27 -0
  16. package/examples/test--when--i-reload-page.html +27 -0
  17. package/examples/test--when--i-select-option-from-selectbox.html +35 -0
  18. package/lib/custom-commands/smartSelectOption.js +15 -0
  19. package/lib/get-element.js +65 -0
  20. package/nightwatch.conf.js +24 -259
  21. package/package.json +11 -4
  22. package/src/index.js +10 -0
  23. package/tests/features/test--given--i-am-on-homepage.feature +12 -0
  24. package/tests/features/test--when--i-fill-in.feature +36 -0
  25. package/tests/features/test--when--i-follow-link.feature +11 -0
  26. package/tests/features/test--when--i-move-forward-backward-one-page.feature +14 -0
  27. package/tests/features/test--when--i-press-button.feature +11 -0
  28. package/tests/features/test--when--i-reload-page.feature +14 -0
  29. package/tests/features/test--when--i-select-option-from-selectbox.feature +13 -0
  30. package/tests/reports/cucumber-report.html +0 -0
  31. package/tests/reports/cucumber-report.json +0 -0
  32. package/tests/step-definitions/webship.js +156 -10
  33. package/webpack.config.js +17 -0
  34. package/webship-init.js +75 -0
  35. package/tests/features/check-webshipco-site.feature +0 -8
@@ -1,32 +1,12 @@
1
1
  const Services = {}; loadServices();
2
2
 
3
- // _ _ _ _ _ _ _
4
- // | \ | |(_) | | | | | | | |
5
- // | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
6
- // | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
7
- // | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
8
- // \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
9
- // __/ |
10
- // |___/
11
-
12
3
  module.exports = {
13
4
  // An array of folders (excluding subfolders) where your tests are located;
14
5
  // if this is not specified, the test source must be passed as the second argument to the test runner.
15
6
  src_folders: ['tests/step-definitions'],
16
7
 
17
- // See https://nightwatchjs.org/guide/working-with-page-objects/
18
- page_objects_path: '',
19
-
20
8
  // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
21
- custom_commands_path: '',
22
-
23
- // See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
24
- custom_assertions_path: '',
25
-
26
- // See https://nightwatchjs.org/guide/#external-globals
27
- globals_path: '',
28
-
29
- webdriver: {},
9
+ custom_commands_path: './lib/custom-commands',
30
10
 
31
11
  test_runner: {
32
12
  type: 'cucumber',
@@ -35,12 +15,11 @@ module.exports = {
35
15
  additional_config: '',
36
16
  parallel: 2,
37
17
  },
38
-
39
18
  },
40
19
 
41
20
  test_settings: {
42
21
  default: {
43
- launch_url: 'https://webship.co',
22
+ launch_url: 'http://localhost:8080/',
44
23
  selenium_port: 4444,
45
24
  selenium_host: '127.0.0.1',
46
25
  silent: true,
@@ -80,256 +59,42 @@ module.exports = {
80
59
  },
81
60
  },
82
61
  },
62
+ },
83
63
 
84
- safari: {
85
- desiredCapabilities: {
86
- browserName: 'safari',
87
- alwaysMatch: {
88
- acceptInsecureCerts: false,
89
- },
90
- },
91
- webdriver: {
92
- start_process: true,
93
- server_path: '',
94
- },
95
- },
96
-
97
- firefox: {
98
- desiredCapabilities: {
99
- browserName: 'firefox',
100
- alwaysMatch: {
101
- acceptInsecureCerts: true,
102
- 'moz:firefoxOptions': {
103
- args: [
104
- // '-headless',
105
- // '-verbose'
106
- ],
107
- },
108
- },
109
- },
110
- webdriver: {
111
- start_process: true,
112
- server_path: '',
113
- cli_args: [
114
- // very verbose geckodriver logs
115
- // '-vv'
116
- ],
117
- },
118
- },
119
-
120
- chrome: {
121
- desiredCapabilities: {
122
- browserName: 'chrome',
123
- 'goog:chromeOptions': {
124
- // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
125
- //
126
- // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
127
- w3c: true,
128
- args: [
129
- // '--no-sandbox',
130
- // '--ignore-certificate-errors',
131
- // '--allow-insecure-localhost',
132
- // '--headless'
133
- ],
134
- },
135
- },
136
-
137
- webdriver: {
138
- start_process: true,
139
- server_path: '',
140
- cli_args: [
141
- // --verbose
142
- ],
143
- },
144
- },
145
-
146
- edge: {
147
- desiredCapabilities: {
148
- browserName: 'MicrosoftEdge',
149
- 'ms:edgeOptions': {
150
- w3c: true,
151
- // More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
152
- args: [
153
- // '--headless'
154
- ],
155
- },
156
- },
157
-
158
- webdriver: {
159
- start_process: true,
160
- // Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
161
- // and set the location below:
162
- server_path: '',
163
- cli_args: [
164
- // --verbose
165
- ],
166
- },
167
- },
168
-
169
- /// ///////////////////////////////////////////////////////////////////////////////
170
- // Configuration for when using cucumber-js (https://cucumber.io) |
171
- // |
172
- // It uses the bundled examples inside the nightwatch examples folder; feel free |
173
- // to adapt this to your own project needs |
174
- /// ///////////////////////////////////////////////////////////////////////////////
175
- 'cucumber-js': {
176
- src_folders: ['examples/cucumber-js/features/step_definitions'],
177
-
178
- test_runner: {
179
- // set cucumber as the runner
180
- type: 'cucumber',
181
-
182
- // define cucumber specific options
183
- options: {
184
- // set the feature path
185
- feature_path: 'node_modules/nightwatch/examples/cucumber-js/*/*.feature',
186
-
187
- // start the webdriver session automatically (enabled by default)
188
- // auto_start_session: true
189
-
190
- // use parallel execution in Cucumber
191
- // parallel: 2 // set number of workers to use (can also be defined in the cli as --parallel 2
192
- },
193
- },
194
- },
195
-
196
- /// ///////////////////////////////////////////////////////////////////////////////
197
- // Configuration for when using the browserstack.com cloud service |
198
- // |
199
- // Please set the username and access key by setting the environment variables: |
200
- // - BROWSERSTACK_USER |
201
- // - BROWSERSTACK_KEY |
202
- // .env files are supported |
203
- /// ///////////////////////////////////////////////////////////////////////////////
204
- browserstack: {
205
- selenium: {
206
- host: 'hub-cloud.browserstack.com',
207
- port: 443,
208
- },
209
- // More info on configuring capabilities can be found on:
210
- // https://www.browserstack.com/automate/capabilities?tag=selenium-4
211
- desiredCapabilities: {
212
- 'bstack:options': {
213
- userName: '${BROWSERSTACK_USER}',
214
- accessKey: '${BROWSERSTACK_KEY}',
215
- },
216
- },
217
-
218
- disable_error_log: true,
219
- webdriver: {
220
- timeout_options: {
221
- timeout: 15000,
222
- retry_attempts: 3,
223
- },
224
- keep_alive: true,
225
- start_process: false,
226
- },
227
- },
228
-
229
- 'browserstack.local': {
230
- extends: 'browserstack',
231
- desiredCapabilities: {
232
- 'browserstack.local': true,
233
- },
234
- },
235
-
236
- 'browserstack.chrome': {
237
- extends: 'browserstack',
238
- desiredCapabilities: {
239
- browserName: 'chrome',
240
- chromeOptions: {
241
- w3c: true,
242
- },
243
- },
244
- },
245
-
246
- 'browserstack.firefox': {
247
- extends: 'browserstack',
248
- desiredCapabilities: {
249
- browserName: 'firefox',
250
- },
251
- },
252
-
253
- 'browserstack.ie': {
254
- extends: 'browserstack',
255
- desiredCapabilities: {
256
- browserName: 'internet explorer',
257
- browserVersion: '11.0',
258
- },
259
- },
260
-
261
- 'browserstack.safari': {
262
- extends: 'browserstack',
263
- desiredCapabilities: {
264
- browserName: 'safari',
265
- },
266
- },
267
-
268
- 'browserstack.local_chrome': {
269
- extends: 'browserstack.local',
270
- desiredCapabilities: {
271
- browserName: 'chrome',
272
- },
273
- },
274
-
275
- 'browserstack.local_firefox': {
276
- extends: 'browserstack.local',
277
- desiredCapabilities: {
278
- browserName: 'firefox',
279
- },
280
- },
281
- /// ///////////////////////////////////////////////////////////////////////////////
282
- // Configuration for when using the Selenium service, either locally or remote, |
283
- // like Selenium Grid |
284
- /// ///////////////////////////////////////////////////////////////////////////////
285
- selenium_server: {
286
- // Selenium Server is running locally and is managed by Nightwatch
287
- selenium: {
288
- start_process: true,
289
- port: 4444,
290
- server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
291
- cli_args: {
292
- 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
293
- 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
294
- },
295
- },
296
- },
297
-
298
- 'selenium.chrome': {
299
- extends: 'selenium_server',
300
- desiredCapabilities: {
301
- browserName: 'chrome',
302
- chromeOptions: {
303
- w3c: true,
304
- },
64
+ selenium_server: {
65
+ // Selenium Server is running locally and is managed by Nightwatch
66
+ selenium: {
67
+ start_process: true,
68
+ port: 4444,
69
+ server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
70
+ cli_args: {
71
+ 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
72
+ 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
305
73
  },
306
74
  },
75
+ },
307
76
 
308
- 'selenium.firefox': {
309
- extends: 'selenium_server',
310
- desiredCapabilities: {
311
- browserName: 'firefox',
312
- 'moz:firefoxOptions': {
313
- args: [
314
- // '-headless',
315
- // '-verbose'
316
- ],
317
- },
77
+ 'selenium.chrome': {
78
+ extends: 'selenium_server',
79
+ desiredCapabilities: {
80
+ browserName: 'chrome',
81
+ chromeOptions: {
82
+ w3c: true,
318
83
  },
319
84
  },
320
- },
85
+ }
321
86
  };
322
87
 
323
88
  function loadServices() {
324
89
  try {
325
90
  Services.seleniumServer = require('selenium-server');
326
- } catch (err) {}
91
+ } catch (err) { }
327
92
 
328
93
  try {
329
94
  Services.chromedriver = require('chromedriver');
330
- } catch (err) {}
95
+ } catch (err) { }
331
96
 
332
97
  try {
333
98
  Services.geckodriver = require('geckodriver');
334
- } catch (err) {}
335
- }
99
+ } catch (err) { }
100
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -12,7 +12,10 @@
12
12
  },
13
13
  "scripts": {
14
14
  "test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html",
15
- "lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json ."
15
+ "lint:js": "node ./node_modules/eslint/bin/eslint.js --config=.eslintrc.json .",
16
+ "build": "webpack",
17
+ "start": "npm run devServer",
18
+ "devServer": "webpack serve --port 8080"
16
19
  },
17
20
  "repository": {
18
21
  "type": "git",
@@ -31,11 +34,15 @@
31
34
  "args-parser": "~1.0",
32
35
  "eslint": "~8.0",
33
36
  "eslint-config-airbnb-base": "~15.0",
34
- "eslint-plugin-import": "~2.25"
37
+ "eslint-plugin-import": "~2.25",
38
+ "lodash": "~4.17.21",
39
+ "webpack": "~5.0"
35
40
  },
36
41
  "devDependencies": {
37
42
  "chromedriver": "*",
38
- "geckodriver": "*"
43
+ "geckodriver": "*",
44
+ "webpack-cli": "~5.0",
45
+ "webpack-dev-server": "~4.0"
39
46
  },
40
47
  "bin": {
41
48
  "steplist": "./steplist.js"
package/src/index.js ADDED
@@ -0,0 +1,10 @@
1
+ function component() {
2
+ const element = document.createElement('div');
3
+
4
+ //Lodash, now imported by this script
5
+ element.innerHTML = _.join(['Hello', 'webpack'], ' ');
6
+
7
+ return element;
8
+ }
9
+
10
+ document.body.appendChild(component());
@@ -0,0 +1,12 @@
1
+ Feature: Example test for "I am on the homepage"
2
+ As a tester
3
+ I want to be able to navigate to the homepage
4
+ So that I can check the welcome message at homepage
5
+
6
+ Scenario: Check the homepage step definition
7
+ Given I am on the homepage
8
+ Then I should see "Welcome to the homepage of the Webship-js Examples"
9
+
10
+ Scenario: Check homepage step definition
11
+ Given I am on homepage
12
+ Then I should see "Welcome to the homepage of the Webship-js Examples"
@@ -0,0 +1,36 @@
1
+ Feature: Example test for filling text with value
2
+ As a developer
3
+ I want to be able to test when fill input text with value,
4
+ with empty value, value for text, and fill in table
5
+
6
+ Scenario: Check fill in input field with value
7
+ Given I am on homepage
8
+ When I go to "test--when--i-fill-in.html"
9
+ When I fill in "Username" with "webshipco"
10
+ When I fill in "Password" with "1234"
11
+ When I press "Login"
12
+ Then I should see "You enter Username: webshipco and Password: 1234"
13
+
14
+ Scenario: Check fill in input field with empty value
15
+ Given I am on homepage
16
+ When I go to "test--when--i-fill-in.html"
17
+ When I fill in "Username" with:
18
+ When I press "Login"
19
+ Then I should see "You enter Username: "
20
+
21
+ Scenario: Check fill in value for input field
22
+ Given I am on homepage
23
+ When I go to "test--when--i-fill-in.html"
24
+ When I fill in "webshipco" for "Username"
25
+ When I fill in "1234" for "Password"
26
+ When I press "Login"
27
+ Then I should see "You enter Username: webshipco and Password: 1234"
28
+
29
+ Scenario: Check fill in table of input fields
30
+ Given I am on homepage
31
+ When I go to "test--when--i-fill-in.html"
32
+ When I fill in the following:
33
+ | username | webshipco |
34
+ | password | 1234 |
35
+ When I press "Login"
36
+ Then I should see "You enter Username: webshipco and Password: 1234"
@@ -0,0 +1,11 @@
1
+ Feature: Example test for "When I follow 'link'"
2
+
3
+ As a tester
4
+ I want to be able to test when a link is clicked,
5
+ it will go to the link path page
6
+
7
+ Scenario: Check the "When I follow link" step definitions
8
+ Given I am on "test--when--i-follow-link.html"
9
+ When I follow "About us link"
10
+ Then I should see "About Us"
11
+
@@ -0,0 +1,14 @@
1
+ Feature: Example test for "I move forword one page",and "I move backword one page"
2
+
3
+ As a tester
4
+ I want to be able to test the navigate forward and backward in the browser history
5
+ So that I know it is working
6
+
7
+ Scenario: Check the "Navigate forward and backward" step definitions
8
+ Given I am on the homepage
9
+ When I go to "about-us.html"
10
+ When I move backward one page
11
+ When I move forward one page
12
+ Then I should see "About Us"
13
+ When I move backward one page
14
+ Then I should see "Welcome to the homepage of the Webship-js Examples"
@@ -0,0 +1,11 @@
1
+ Feature: Example test for "When I press button"
2
+
3
+ As a tester
4
+ I want to be able to test button press event
5
+ So that I know it is working
6
+
7
+ Scenario: Check the "When I press button" step definitions
8
+ Given I am on the homepage
9
+ When I go to "test--when--i-press-button.html"
10
+ When I press "Click Button"
11
+ Then I should see "Button Pressed Successfully"
@@ -0,0 +1,14 @@
1
+ Feature: Example test for "When I reload page"
2
+
3
+ As a tester
4
+ I want to be able to test page reload
5
+ So that I know it is working
6
+
7
+ Scenario: Check the "When I reload page" step definitions
8
+ Given I am on the homepage
9
+ When I go to "test--when--i-reload-page.html"
10
+ When I press "Click Button"
11
+ Then I should see "Button Pressed Successfully"
12
+ When I reload the page
13
+ Then I should not see "Button Pressed Successfully"
14
+
@@ -0,0 +1,13 @@
1
+ Feature: Example test for "When I select option from select list"
2
+
3
+ As a tester
4
+ I want to be able to test select option from selectbox
5
+
6
+ Scenario: Check the "When I select 'option' from 'select list'" step definitions
7
+ Given I am on homepage
8
+ When I go to "test--when--i-select-option-from-selectbox.html"
9
+ When I select "saab" from "cars"
10
+ When I press "Check select"
11
+ Then I should see "Option ( Saab ) has been selected successfully"
12
+
13
+
File without changes
File without changes