webship-js 1.0.47 → 2.0.0-beta1

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 (46) hide show
  1. package/.circleci/config.yml +15 -63
  2. package/.github/workflows/github-actions.yml +7 -37
  3. package/.gitlab-ci.yml +11 -35
  4. package/.travis-ci.yml +12 -23
  5. package/.travis.yml +17 -0
  6. package/README.md +8 -8
  7. package/bitbucket-pipelines.yml +3 -7
  8. package/cucumber.js +36 -0
  9. package/examples/dynamic-examples.html +1 -2
  10. package/examples/index.html +0 -1
  11. package/examples/test--modal-dialogs.html +252 -0
  12. package/examples/test--when--i-click-text-in-table-row.html +1 -1
  13. package/examples/test--when--i-scroll-functionality.html +34 -33
  14. package/examples/test--when--i-scroll-left-right-functionality.html +115 -173
  15. package/package.json +10 -21
  16. package/playwright.config.ts +37 -0
  17. package/tests/assets/test-document.pdf +14 -0
  18. package/tests/step-definitions/webship-api.js +5 -31
  19. package/tests/step-definitions/webship.js +849 -2498
  20. package/tsconfig.json +10 -0
  21. package/.claude/settings.local.json +0 -10
  22. package/.eslintignore +0 -3
  23. package/.eslintrc.json +0 -34
  24. package/assets/config_templates/circleci-linux-chrome.conf.js +0 -130
  25. package/assets/config_templates/github-linux-chrome.conf.js +0 -136
  26. package/dist/nightwatch.conf.dev.js +0 -93
  27. package/examples/main.js +0 -17
  28. package/lib/custom-assertions/checkboxChecked.js +0 -87
  29. package/lib/custom-assertions/elementContainsCss.js +0 -94
  30. package/lib/custom-assertions/elementContainsText.js +0 -86
  31. package/lib/custom-assertions/responseStatus.js +0 -31
  32. package/lib/custom-assertions/shouldVisible.js +0 -8
  33. package/lib/custom-assertions/textMatching.js +0 -44
  34. package/lib/custom-commands/checkItem.js +0 -4
  35. package/lib/custom-commands/clickLink.js +0 -23
  36. package/lib/custom-commands/fileUpload.js +0 -37
  37. package/lib/custom-commands/fillTextInput.js +0 -56
  38. package/lib/custom-commands/press.js +0 -3
  39. package/lib/custom-commands/selectOption.js +0 -11
  40. package/lib/custom-commands/uncheckItem.js +0 -4
  41. package/lib/custom-commands/wait.js +0 -12
  42. package/nightwatch.conf.js +0 -136
  43. package/src/index.js +0 -10
  44. package/steplist.js +0 -245
  45. package/webpack.config.js +0 -17
  46. package/webship-init.js +0 -75
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "CommonJS",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "types": ["node"]
8
+ },
9
+ "include": ["playwright.config.ts"]
10
+ }
@@ -1,10 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(FORCE_COLOR=1 node -e \"\nconst {styleText} = require\\('node:util'\\);\nconst {Writable} = require\\('stream'\\);\nconst fakeStream = new Writable\\({write\\(c,e,cb\\){cb\\(\\)}}\\);\nfakeStream.isTTY = false;\nconst result = styleText\\('red', 'test', {stream: fakeStream}\\);\nconsole.log\\('Non-TTY WITH FORCE_COLOR=1:', JSON.stringify\\(result\\)\\);\n\")",
5
- "Bash(node -e \"\n// Check the full styleText source to understand FORCE_COLOR handling\nconst src = require\\('node:util'\\).styleText.toString\\(\\);\nconsole.log\\(src\\);\n\")",
6
- "Bash(node -e \"\n// Check what shouldColorize does - it's in node:util internals\n// Let's check how FORCE_COLOR interacts with shouldColorize\nconst util = require\\('node:util'\\);\n\n// The shouldColorize function checks:\n// 1. stream.isTTY\n// 2. FORCE_COLOR env var\n// 3. NO_COLOR env var\n// Let's verify by testing edge cases\n\nconst {Writable} = require\\('stream'\\);\nconst fakeStream = new Writable\\({write\\(c,e,cb\\){cb\\(\\)}}\\);\nfakeStream.isTTY = false;\n\n// Test NO_COLOR\nconst result1 = require\\('child_process'\\).execSync\\(\n 'node -e \\\\\"const {styleText}=require\\(\\\\\\\\\\\\\"node:util\\\\\\\\\\\\\"\\); const {Writable}=require\\(\\\\\\\\\\\\\"stream\\\\\\\\\\\\\"\\); const s=new Writable\\({write\\(c,e,cb\\){cb\\(\\)}}\\); s.isTTY=true; console.log\\(JSON.stringify\\(styleText\\(\\\\\\\\\\\\\"red\\\\\\\\\\\\\",\\\\\\\\\\\\\"x\\\\\\\\\\\\\",{stream:s}\\)\\)\\)\\\\\"',\n {env: {...process.env, NO_COLOR: '1'}}\n\\).toString\\(\\).trim\\(\\);\nconsole.log\\('TTY + NO_COLOR=1:', result1\\);\n\nconst result2 = require\\('child_process'\\).execSync\\(\n 'node -e \\\\\"const {styleText}=require\\(\\\\\\\\\\\\\"node:util\\\\\\\\\\\\\"\\); const {Writable}=require\\(\\\\\\\\\\\\\"stream\\\\\\\\\\\\\"\\); const s=new Writable\\({write\\(c,e,cb\\){cb\\(\\)}}\\); s.isTTY=false; console.log\\(JSON.stringify\\(styleText\\(\\\\\\\\\\\\\"red\\\\\\\\\\\\\",\\\\\\\\\\\\\"x\\\\\\\\\\\\\",{stream:s}\\)\\)\\)\\\\\"',\n {env: {...process.env, FORCE_COLOR: '1'}}\n\\).toString\\(\\).trim\\(\\);\nconsole.log\\('non-TTY + FORCE_COLOR=1:', result2\\);\n\")",
7
- "Bash(NO_COLOR=1 node -e \"\nconst {styleText} = require\\('node:util'\\);\nconst {Writable} = require\\('stream'\\);\nconst s = new Writable\\({write\\(c,e,cb\\){cb\\(\\)}}\\);\ns.isTTY = true;\nconst result = styleText\\('red', 'x', {stream: s}\\);\nconsole.log\\('TTY + NO_COLOR=1:', JSON.stringify\\(result\\)\\);\n\")"
8
- ]
9
- }
10
- }
package/.eslintignore DELETED
@@ -1,3 +0,0 @@
1
- node_modules
2
- nightwatch.conf.js
3
- tests_output
package/.eslintrc.json DELETED
@@ -1,34 +0,0 @@
1
- {
2
- "extends": [
3
- "airbnb-base"
4
- ],
5
- "root": true,
6
- "env": {
7
- "browser": true,
8
- "node": true
9
- },
10
- "globals": {
11
- "loadjs": true
12
- },
13
- "rules": {
14
- "consistent-return": ["off"],
15
- "no-underscore-dangle": ["off"],
16
- "max-nested-callbacks": ["warn", 5],
17
- "import/no-mutable-exports": ["warn"],
18
- "no-console": ["off"],
19
- "no-plusplus": ["warn", {
20
- "allowForLoopAfterthoughts": true
21
- }],
22
- "no-param-reassign": ["off"],
23
- "no-prototype-builtins": ["off"],
24
- "valid-jsdoc": ["warn", {
25
- "prefer": {
26
- "returns": "return",
27
- "property": "prop"
28
- },
29
- "requireReturn": false
30
- }],
31
- "no-unused-vars": ["warn"],
32
- "operator-linebreak": ["error", "after", { "overrides": { "?": "ignore", ":": "ignore" } }]
33
- }
34
- }
@@ -1,130 +0,0 @@
1
- const Services = {}; loadServices();
2
-
3
- module.exports = {
4
- // An array of folders (excluding subfolders) where your tests are located;
5
- // if this is not specified, the test source must be passed as the second argument to the test runner.
6
- src_folders: ['tests/step-definitions'],
7
-
8
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
9
- custom_commands_path: './lib/custom-commands',
10
-
11
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
12
- custom_assertions_path: './lib/custom-assertions',
13
-
14
- test_runner: {
15
- type: 'cucumber',
16
- options: {
17
- feature_path: 'tests/features/*.feature',
18
- additional_config: '',
19
- parallel: 1,
20
- 'format-options': JSON.stringify({
21
- colorsEnabled: true,
22
- theme: {
23
- 'feature keyword': ['bold', 'blue'],
24
- 'feature name': ['blue', 'underline'],
25
- 'feature description': ['blueBright'],
26
- 'scenario keyword': ['bold', 'magenta'],
27
- 'scenario name': ['magenta', 'underline'],
28
- 'step keyword': ['bold', 'green'],
29
- 'step text': ['greenBright', 'italic'],
30
- },
31
- }),
32
- },
33
- },
34
- globals: {
35
- assets_folder : "/test/assets/",
36
- minimum_wait_time: {
37
- page: 3000,
38
- before_scenario: 0,
39
- after_scenario: 0,
40
- before_step: 0,
41
- after_step: 1000
42
- }
43
- },
44
- test_settings: {
45
- default: {
46
- launch_url: 'http://localhost:8080/',
47
- start_process: true,
48
- selenium_port: 4444,
49
- selenium_host: '127.0.0.1',
50
- silent: true,
51
- output: false,
52
- screenshots: {
53
- enabled: false,
54
- path: './reports/screenshots',
55
- },
56
-
57
- desiredCapabilities: {
58
- browserName: 'chrome',
59
- 'goog:chromeOptions': {
60
- // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
61
- //
62
- // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
63
- w3c: true,
64
- args: [
65
- '--headless',
66
- '--start-maximized',
67
- '--disable-gpu',
68
- '--window-size=1600,1200',
69
- '--no-sandbox',
70
- '--disable-dev-shm-usage',
71
- '--disable-setuid-sandbox',
72
- '--disable-web-security',
73
- '--DNS-prefetch-disable',
74
- '--disable-translate',
75
- '--ignore-certificate-errors',
76
- '--test-type',
77
- '--disable-extensions',
78
- '--incognito',
79
- '--disable-infobars',
80
- '--remote-debugging-port=9222',
81
- '--allowed-ips=*',
82
- '--whitelisted-ips=*',
83
- '--allow-insecure-localhost',
84
- ],
85
- },
86
- },
87
- },
88
- },
89
-
90
- selenium_server: {
91
- // Selenium Server is running locally and is managed by Nightwatch
92
- selenium: {
93
- start_process: true,
94
- port: 4444,
95
- server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
96
- cli_args: {
97
- 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
98
- 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
99
- },
100
- },
101
-
102
- webdriver: {
103
- start_process: false
104
- },
105
- },
106
-
107
- 'selenium.chrome': {
108
- extends: 'selenium',
109
- desiredCapabilities: {
110
- browserName: 'chrome',
111
- chromeOptions: {
112
- w3c: false,
113
- },
114
- },
115
- }
116
- };
117
-
118
- function loadServices() {
119
- try {
120
- Services.seleniumServer = require('selenium-server');
121
- } catch (err) {}
122
-
123
- try {
124
- Services.chromedriver = require('chromedriver');
125
- } catch (err) {}
126
-
127
- try {
128
- Services.geckodriver = require('geckodriver');
129
- } catch (err) {}
130
- }
@@ -1,136 +0,0 @@
1
- const Services = {}; loadServices();
2
-
3
- module.exports = {
4
- // An array of folders (excluding subfolders) where your tests are located;
5
- // if this is not specified, the test source must be passed as the second argument to the test runner.
6
- src_folders: ['tests/step-definitions'],
7
-
8
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
9
- custom_commands_path: './lib/custom-commands',
10
-
11
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
12
- custom_assertions_path: './lib/custom-assertions',
13
-
14
- webdriver: {
15
- start_process: true,
16
- port: 4444,
17
- server_path: require('chromedriver').path,
18
- cli_args: [
19
- // very verbose geckodriver logs
20
- // '-vv'
21
- ]
22
- },
23
-
24
- test_runner: {
25
- type: 'cucumber',
26
- options: {
27
- feature_path: 'tests/features/*.feature',
28
- additional_config: '',
29
- parallel: 1,
30
- 'format-options': JSON.stringify({
31
- colorsEnabled: true,
32
- theme: {
33
- 'feature keyword': ['bold', 'blue'],
34
- 'feature name': ['blue', 'underline'],
35
- 'feature description': ['blueBright'],
36
- 'scenario keyword': ['bold', 'magenta'],
37
- 'scenario name': ['magenta', 'underline'],
38
- 'step keyword': ['bold', 'green'],
39
- 'step text': ['greenBright', 'italic'],
40
- },
41
- }),
42
- },
43
-
44
- },
45
- globals: {
46
- assets_folder : "/test/assets/",
47
- minimum_wait_time: {
48
- page: 3000,
49
- before_scenario: 0,
50
- after_scenario: 0,
51
- before_step: 0,
52
- after_step: 1000
53
- }
54
- },
55
- test_settings: {
56
- default: {
57
- launch_url: 'http://localhost:8080/',
58
- selenium_port: 4444,
59
- selenium_host: '127.0.0.1',
60
- silent: true,
61
- output: false,
62
- screenshots: {
63
- enabled: true,
64
- path: './reports/screenshots',
65
- },
66
-
67
- desiredCapabilities: {
68
- browserName: 'chrome',
69
- 'goog:chromeOptions': {
70
- // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
71
- //
72
- // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
73
- w3c: true,
74
- args: [
75
- '--headless',
76
- '--start-maximized',
77
- '--disable-gpu',
78
- '--window-size=1600,1200',
79
- '--no-sandbox',
80
- '--disable-dev-shm-usage',
81
- '--disable-setuid-sandbox',
82
- '--disable-web-security',
83
- '--DNS-prefetch-disable',
84
- '--disable-translate',
85
- '--ignore-certificate-errors',
86
- '--test-type',
87
- '--disable-extensions',
88
- '--incognito',
89
- '--disable-infobars',
90
- '--remote-debugging-port=9222',
91
- '--allowed-ips=*',
92
- '--whitelisted-ips=*',
93
- '--allow-insecure-localhost',
94
- ],
95
- },
96
- },
97
- },
98
- },
99
-
100
- selenium_server: {
101
- // Selenium Server is running locally and is managed by Nightwatch
102
- selenium: {
103
- start_process: true,
104
- port: 4444,
105
- server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
106
- cli_args: {
107
- 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
108
- 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
109
- },
110
- },
111
- },
112
-
113
- 'selenium.chrome': {
114
- extends: 'selenium_server',
115
- desiredCapabilities: {
116
- browserName: 'chrome',
117
- chromeOptions: {
118
- w3c: true,
119
- },
120
- },
121
- }
122
- };
123
-
124
- function loadServices() {
125
- try {
126
- Services.seleniumServer = require('selenium-server');
127
- } catch (err) { }
128
-
129
- try {
130
- Services.chromedriver = require('chromedriver');
131
- } catch (err) { }
132
-
133
- try {
134
- Services.geckodriver = require('geckodriver');
135
- } catch (err) { }
136
- }
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- var Services = {};
4
- loadServices();
5
- require('events').EventEmitter.defaultMaxListeners = 1000;
6
- module.exports = {
7
- // An array of folders (excluding subfolders) where your tests are located;
8
- // if this is not specified, the test source must be passed as the second argument to the test runner.
9
- src_folders: ['./tests/step-definitions'],
10
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
11
- custom_commands_path: './lib/custom-commands',
12
- // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
13
- custom_assertions_path: './lib/custom-assertions',
14
- test_runner: {
15
- type: 'cucumber',
16
- options: {
17
- feature_path: './tests/features/*.feature',
18
- additional_config: '',
19
- parallel: 1
20
- }
21
- },
22
- globals: {
23
- assets_folder: "/test/assets/",
24
- min_wait_time: {
25
- page: 10000,
26
- before_scenario: 0,
27
- after_scenario: 0,
28
- before_step: 0,
29
- after_step: 1000
30
- }
31
- },
32
- test_settings: {
33
- "default": {
34
- launch_url: 'http://localhost:8080',
35
- selenium_port: 4444,
36
- selenium_host: '127.0.0.1',
37
- silent: true,
38
- output: false,
39
- screenshots: {
40
- enabled: true,
41
- path: './reports/screenshots'
42
- },
43
- desiredCapabilities: {
44
- browserName: 'chrome',
45
- 'goog:chromeOptions': {
46
- // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
47
- //
48
- // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
49
- w3c: true,
50
- args: ['--headless', '--start-maximized', '--disable-gpu', '--window-size=1600,1200', '--no-sandbox', '--disable-dev-shm-usage', '--disable-setuid-sandbox', '--disable-web-security', '--DNS-prefetch-disable', '--disable-translate', '--ignore-certificate-errors', '--test-type', '--disable-extensions', '--incognito', '--disable-infobars', '--remote-debugging-port=9222', '--allowed-ips=*', '--whitelisted-ips=*', '--allow-insecure-localhost']
51
- }
52
- }
53
- }
54
- },
55
- selenium_server: {
56
- // Selenium Server is running locally and is managed by Nightwatch
57
- selenium: {
58
- start_process: true,
59
- port: 4444,
60
- server_path: Services.seleniumServer ? Services.seleniumServer.path : '',
61
- cli_args: {
62
- 'webdriver.gecko.driver': Services.geckodriver ? Services.geckodriver.path : '',
63
- 'webdriver.chrome.driver': Services.chromedriver ? Services.chromedriver.path : ''
64
- }
65
- },
66
- webdriver: {
67
- start_process: false
68
- }
69
- },
70
- 'selenium.chrome': {
71
- "extends": 'selenium_server',
72
- desiredCapabilities: {
73
- browserName: 'chrome',
74
- chromeOptions: {
75
- w3c: false
76
- }
77
- }
78
- }
79
- };
80
-
81
- function loadServices() {
82
- try {
83
- Services.seleniumServer = require('selenium-server');
84
- } catch (err) {}
85
-
86
- try {
87
- Services.chromedriver = require('chromedriver');
88
- } catch (err) {}
89
-
90
- try {
91
- Services.geckodriver = require('geckodriver');
92
- } catch (err) {}
93
- }
package/examples/main.js DELETED
@@ -1,17 +0,0 @@
1
- /*
2
- * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3
- * This devtool is not neither made for production nor for readable output files.
4
- * It uses "eval()" calls to create a separate source file in the browser devtools.
5
- * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6
- * or disable the default devtool with "devtool: false".
7
- * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8
- */
9
- /******/ (() => { // webpackBootstrap
10
- /*!**********************!*\
11
- !*** ./src/index.js ***!
12
- \**********************/
13
- /*! unknown exports (runtime-defined) */
14
- /*! runtime requirements: */
15
- eval("function component() {\n const element = document.createElement('div');\n\n //Lodash, now imported by this script\n element.innerHTML = _.join(['Hello', 'webpack'], ' ');\n\n return element;\n}\n\ndocument.body.appendChild(component());\n\n//# sourceURL=webpack://webship-js/./src/index.js?");
16
- /******/ })()
17
- ;
@@ -1,87 +0,0 @@
1
-
2
- module.exports.assertion = function (checkbox, negativeCase) {
3
-
4
- this.expected = function () {
5
- return negativeCase ? `not contains '${expectedText}'` : `contains '${expectedText}'`;
6
- };
7
-
8
- this.evaluate = function (value) {
9
- return (typeof value === 'string') && (value.includes(expectedText) !== negativeCase);
10
- };
11
-
12
- this.value = function (result) {
13
- return result.value;
14
- };
15
-
16
- /**
17
- * The command which is to be executed by the assertion runner; Nightwatch api is available as browser.api
18
- * @param {function} callback
19
- */
20
- this.command = function(callback) {
21
- setTimeout(function() {
22
- callback({
23
- value: ''
24
- });
25
- }, 1000);
26
- };
27
-
28
-
29
- this.pass = function (value) {
30
- return this.evaluate(value);
31
- };
32
-
33
- this.failure = function (result) {
34
- return result === false || result && result.status === -1;
35
- };
36
-
37
- browser.element('css selector', checkbox, function (result) {
38
- if (result.status === 0) {
39
- if (negativeCase) {
40
- return browser.expect.element(checkbox).to.not.be.selected.end();
41
- }
42
- return browser.expect.element(checkbox).to.be.selected.end();
43
- } else {
44
- browser.element('css selector', '#' + checkbox, function (result) {
45
- if (result.status === 0) {
46
- if (negativeCase) {
47
- return browser.expect.element('#' + checkbox).to.not.be.selected.end();
48
- }
49
- return browser.expect.element('#' + checkbox).to.be.selected.end();
50
- } else {
51
- browser.element('css selector', 'input[name="' + checkbox + '"]', function (result) {
52
- if (result.status === 0) {
53
- if (negativeCase) {
54
- return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected.end();
55
- }
56
- return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected.end();
57
- } else {
58
- browser.element('css selector', 'input[value="' + checkbox + '"]', function (result) {
59
- if (result.status === 0) {
60
- if (negativeCase) {
61
- return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected.end();
62
- }
63
- return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected.end();
64
- } else {
65
- browser.elements('css selector', 'label', function (elements) {
66
- elements.value.forEach(function (elementsObj) {
67
- browser.elementIdText(elementsObj.ELEMENT, function (result) {
68
- if (result.value == checkbox) {
69
- browser.getAttribute(elementsObj, "for", function (forVal) {
70
- if (negativeCase) {
71
- return browser.expect.element('#' + forVal.value).to.not.be.selected.end();
72
- }
73
- return browser.expect.element('#' + forVal.value).to.be.selected.end();
74
- });
75
- }
76
- })
77
- });
78
- });
79
- }
80
- });
81
- }
82
- });
83
- }
84
- });
85
- }
86
- });
87
- }
@@ -1,94 +0,0 @@
1
-
2
- module.exports.assertion = function (element, negativeCase, elementCss) {
3
-
4
- elementCss = elementCss.replace(";", '');
5
- const cssPropertyArr = elementCss.split(":");
6
-
7
- const cssProperty = cssPropertyArr[0].trim();
8
- const propertyVal = cssPropertyArr[1].trim();
9
-
10
- this.expected = function () {
11
- return negativeCase ? `not contains '${expectedText}'` : `contains '${expectedText}'`;
12
- };
13
-
14
- this.evaluate = function (value) {
15
- return (typeof value === 'string') && (value.includes(expectedText) !== negativeCase);
16
- };
17
-
18
- this.value = function (result) {
19
- return result.value;
20
- };
21
-
22
- /**
23
- * The command which is to be executed by the assertion runner; Nightwatch api is available as browser.api
24
- * @param {function} callback
25
- */
26
- this.command = function(callback) {
27
- setTimeout(function() {
28
- callback({
29
- value: ''
30
- });
31
- }, 1000);
32
- };
33
-
34
- this.pass = function (value) {
35
- return this.evaluate(value);
36
- };
37
-
38
- this.failure = function (result) {
39
- return result === false || result && result.status === -1;
40
- };
41
-
42
- browser.element('css selector', element, function (result) {
43
- if (result.status === 0) {
44
- if (negativeCase) {
45
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
46
- }
47
- return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
48
- } else {
49
- browser.element('css selector', '#' + element, function (result) {
50
- if (result.status === 0) {
51
- if (negativeCase) {
52
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
53
- }
54
- return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
55
- } else {
56
- browser.element('css selector', 'input[name="' + element + '"]', function (result) {
57
- if (result.status === 0) {
58
- if (negativeCase) {
59
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
60
- }
61
- return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
62
- } else {
63
- browser.element('css selector', 'input[value="' + element + '"]', function (result) {
64
- if (result.status === 0) {
65
- if (negativeCase) {
66
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
67
- }
68
- return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
69
- } else {
70
- browser.elements('css selector', 'label', function (elements) {
71
- elements.value.forEach(function (elementsObj) {
72
- browser.elementIdText(elementsObj.ELEMENT, function (result) {
73
- if (result.value == element) {
74
- browser.getAttribute(elementsObj, "for", function (forVal) {
75
-
76
- console.log('#' + forVal.value, cssProperty, propertyVal);
77
- if (negativeCase) {
78
- return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
79
- }
80
- return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
81
- });
82
- }
83
- })
84
- });
85
- });
86
- }
87
- });
88
- }
89
- });
90
- }
91
- });
92
- }
93
- });
94
- }