webship-js 1.0.22 → 1.0.24

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 (51) hide show
  1. package/.circleci/config.yml +8 -5
  2. package/.github/workflows/github-actions.yml +26 -7
  3. package/.gitlab-ci.yml +23 -35
  4. package/CNAME +1 -0
  5. package/README.md +4 -7
  6. package/assets/config_templates/circleci-linux-chrome.conf.js +8 -3
  7. package/bitbucket-pipelines.yml +1 -1
  8. package/examples/test--then--i-should--not--see-text-in-element.html +1 -1
  9. package/examples/test--then--i-should--see-text-in-element.html +48 -0
  10. package/examples/test--when--i-check-uncheck-checkbox.html +5 -3
  11. package/examples/test-acceptable-url-path.html +11 -0
  12. package/generate-reports.js +1 -1
  13. package/lib/custom-assertions/{smartCheckboxChecked.js → checkboxChecked.js} +43 -10
  14. package/lib/custom-assertions/{smartElementContainsCss.js → elementContainsCss.js} +42 -10
  15. package/lib/custom-assertions/{smartElementContains.js → elementContainsText.js} +42 -10
  16. package/lib/custom-assertions/responseStatus.js +13 -0
  17. package/lib/custom-assertions/shouldVisible.js +8 -0
  18. package/lib/custom-assertions/textMatching.js +34 -2
  19. package/lib/custom-commands/checkItem.js +44 -0
  20. package/lib/custom-commands/{smartUploadFile.js → fileUpload.js} +0 -1
  21. package/lib/custom-commands/press.js +3 -0
  22. package/lib/custom-commands/uncheckItem.js +44 -0
  23. package/lib/custom-commands/wait.js +12 -0
  24. package/nightwatch.conf.js +6 -2
  25. package/package.json +14 -14
  26. package/tests/features/test--given--i-am-on-homepage.feature +9 -5
  27. package/tests/features/test--then--i-should--not--see-text-in-element.feature +8 -8
  28. package/tests/features/test--then--i-should--see-text-matching-pattern-in-element.feature +0 -5
  29. package/tests/features/test--then--i-should--see-text-matching-pattern.feature +0 -0
  30. package/tests/features/test--then--i-should-be-on-page.feature +1 -1
  31. package/tests/features/test--then--the-checkbox-is-checked.feature +9 -9
  32. package/tests/features/test--then--the-checkbox-should-be-checked.feature +3 -3
  33. package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +2 -2
  34. package/tests/features/test--then--the-field-should-contain-value.feature +4 -4
  35. package/tests/features/test--then--the-response-status-code-should-be.feature +4 -4
  36. package/tests/features/test--then--the-url-should-match.feature +7 -0
  37. package/tests/features/test--when--i-attach-file-to-feild.feature +5 -5
  38. package/tests/features/test--when--i-check-checkbox.feature +13 -9
  39. package/tests/features/test--when--i-click-link.feature +2 -2
  40. package/tests/features/test--when--i-fill-in.feature +8 -8
  41. package/tests/features/test--when--i-go-to-homepage.feature +10 -0
  42. package/tests/features/test--when--i-move-forward-backward-one-page.feature +2 -2
  43. package/tests/features/test--when--i-select-option-from-dropdownlist.feature +1 -1
  44. package/tests/step-definitions/webship.js +399 -179
  45. package/lib/custom-commands/smartCheckItem.js +0 -39
  46. package/lib/custom-commands/smartPressButton.js +0 -12
  47. package/lib/custom-commands/smartUncheckItem.js +0 -39
  48. package/tests/features/test--when--i-uncheck-checkbox.feature +0 -18
  49. /package/lib/custom-commands/{smartClickLink.js → clickLink.js} +0 -0
  50. /package/lib/custom-commands/{smartFillTextInput.js → fillTextInput.js} +0 -0
  51. /package/lib/custom-commands/{smartSelectOption.js → selectOption.js} +0 -0
@@ -27,7 +27,7 @@ commands:
27
27
  - run:
28
28
  name: Install node js
29
29
  command: |
30
- curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
30
+ curl -sL https://deb.nodesource.com/setup_18.x | sudo bash -
31
31
  sudo apt install -y nodejs
32
32
  sudo npm install -g yarn
33
33
  ## Install Java.
@@ -43,14 +43,16 @@ commands:
43
43
  sudo apt install libu2f-udev
44
44
  sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
45
45
  export CHROME_BIN=/usr/bin/google-chrome
46
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
47
- sudo dpkg -i google-chrome-stable_current_amd64.deb
48
- rm google-chrome-stable_current_amd64.deb
46
+ CHROME_VERSION="115.0.5790.110-1"
47
+ wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
48
+ sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
49
+ rm google-chrome-stable_${CHROME_VERSION}_amd64.deb
50
+
49
51
  ## Install/Update Chrome Driver.
50
52
  - run:
51
53
  name: Install/Update Chrome Driver
52
54
  command: |
53
- CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE);
55
+ CHROME_DRIVER_VERSION=114.0.5735.90;
54
56
  echo $CHROME_DRIVER_VERSION;
55
57
  wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
56
58
  unzip chromedriver_linux64.zip
@@ -84,6 +86,7 @@ jobs:
84
86
  - run:
85
87
  name: Start virtual server
86
88
  command: |
89
+ export NODE_OPTIONS=--openssl-legacy-provider
87
90
  yarn start
88
91
  background: true
89
92
  - run:
@@ -8,24 +8,43 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
 
10
10
  env:
11
- TEST_BASE_URL: http://localhost:8080/
12
- SELENIUM_HOST: http://selenium:4444/wd/hub
11
+ TEST_BASE_URL: http://localhost:8080
13
12
 
14
13
  steps:
15
14
  - name: Install Chrome
16
15
  run: |
17
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
18
- sudo dpkg -i google-chrome-stable_current_amd64.deb
16
+ sudo apt install libu2f-udev
17
+ sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
18
+ export CHROME_BIN=/usr/bin/google-chrome
19
+ CHROME_VERSION="120.0.6099.109-1"
20
+ wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
21
+ sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
22
+ rm google-chrome-stable_${CHROME_VERSION}_amd64.deb
23
+ - name: Install/Update Chrome Driver
24
+ run: |
25
+ CHROME_DRIVER_VERSION="114.0.5735.90";
26
+ echo $CHROME_DRIVER_VERSION;
27
+ wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
28
+ unzip chromedriver_linux64.zip
29
+ sudo chmod +x chromedriver
30
+ sudo mv -f chromedriver /usr/bin/
31
+ rm chromedriver_linux64.zip
32
+
19
33
  - uses: actions/checkout@v3
20
34
  - name: Use Node.js
21
35
  uses: actions/setup-node@v3
22
36
  with:
23
- node-version: '16.x'
37
+ node-version: '18.x'
38
+
39
+ - name: Run Selenium Standalone server
40
+ run: |
41
+ wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.2.jar
42
+ java -jar selenium-server-4.1.2.jar -role node -hub http://localhost:4444
43
+
44
+
24
45
  - name: Install
25
46
  run: yarn install
26
47
  - name: Configure nightwatch.conf.js for Github
27
48
  run: node webship-init -ci github -os linux -b chrome
28
- - name: Start
29
- run: yarn start &
30
49
  - name: Test
31
50
  run: yarn test
package/.gitlab-ci.yml CHANGED
@@ -1,52 +1,40 @@
1
1
  image: node:16
2
2
 
3
3
  stages:
4
- - check
4
+ - setup
5
+ - test
5
6
 
6
7
  check:
7
- stage: check
8
+ stage: setup
8
9
  script:
9
- # Dependencies for chromedriver, https://gist.github.com/mikesmullin/2636776#gistcomment-1742414
10
- # Otherwise we get this error: "error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory"
11
- - apt-get update -q -y
12
- - apt-get --yes install libnss3
13
- - apt-get --yes install libgconf-2-4
10
+ # Install Node.js and yarn
11
+ - apt-get update -qy
12
+ - apt-get install -y nodejs yarn
14
13
 
15
- # Install chrome
16
- # Based off of
17
- # - https://gitlab.com/gitlab-org/gitlab-build-images/blob/9dadb28021f15913a49897126a0cd6ab0149e44f/scripts/install-chrome
18
- # - https://askubuntu.com/a/510186/196148
19
- #
20
- # Add key
21
- - curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
22
- # Add repo
23
- - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
24
- - apt-get update -q -y
25
- - apt-get install -y google-chrome-stable
14
+ # Install Google Chrome and Chromedriver
15
+ - apt-get install -y wget unzip
16
+ - wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
17
+ - dpkg -i google-chrome*.deb
18
+ - apt-get -f install -y
19
+ - CHROMEDRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
20
+ - wget -q https://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip
21
+ - unzip chromedriver_linux64.zip
22
+ - mv chromedriver /usr/local/bin/
23
+ - chmod +x /usr/local/bin/chromedriver
26
24
 
27
- - npm install chromedriver -g
28
- - npm install nightwatch -g
29
- - npm install https://gitlab.com/gitlab-org/gitlab-selenium-server.git -g
30
- - which chromedriver
31
- # The `&` at the end causes it to run in the background and not block the following commands
32
- - nohup chromedriver --port=4444 --url-base=wd/hub &
33
- - nohup gitlab-selenium-server &
34
- # Install cucumber & pretty formatter .
35
- - npm i @cucumber/cucumber
36
- - npm i @cucumber/pretty-formatter
37
-
38
- # Run your tests
39
- - npm start
40
- - npm test
25
+ # Install dependencies and run Webpack
26
+ - yarn install
27
+ - yarn start
28
+ - yarn test
41
29
 
42
30
  # Show the logs for the GitLab Selenium Server service
43
- - mkdir -p selenium/ && curl -s http://localhost:4545/logs.tar.gz | tar -xvzf - -C selenium/
44
- - mkdir -p selenium/ && curl http://localhost:4545/server-log --output selenium/server-log.txt
31
+ - mkdir -p selenium/ && curl -s http://localhost:8080/logs.tar.gz | tar -xvzf - -C selenium/
32
+ - mkdir -p selenium/ && curl http://localhost:8080/server-log --output selenium/server-log.txt
45
33
  artifacts:
46
34
  when: always
47
35
  paths:
48
36
  - selenium/
49
37
  variables:
50
- SELENIUM_REMOTE_URL: http://localhost:4545/wd/hub
38
+ SELENIUM_REMOTE_URL: http://localhost:8080
51
39
  GITLAB_TARGET_SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub
52
40
 
package/CNAME ADDED
@@ -0,0 +1 @@
1
+ webship.co
package/README.md CHANGED
@@ -1,18 +1,15 @@
1
1
  # Webship JS
2
2
 
3
3
  [![Github Actions](https://github.com/webship/webship-js/actions/workflows/github-actions.yml/badge.svg?branch=1.0.x)](https://github.com/webship/webship-js/actions)
4
- [![CircleCI](https://circleci.com/gh/webship/webship-js/tree/1.0.x.svg?style=svg)](https://circleci.com/gh/webship/webship-js/tree/1.0.x) CircleCI
5
4
  [![Gitlab CI](https://gitlab.com/webship/webship-js/badges/1.0.x/pipeline.svg?job=karma&key_text=Gitlab+CI&key_width=60)](https://gitlab.com/webship/webship-js/-/pipelines)
5
+ [![CircleCI](https://circleci.com/gh/webship/webship-js/tree/1.0.x.svg?style=svg)](https://circleci.com/gh/webship/webship-js/tree/1.0.x)
6
+ [![Bitbucket Pipelines](https://img.shields.io/bitbucket/pipelines/webshipco/webship-js/1.0.x)](https://bitbucket.org/webshipco/webship-js/pipelines)
6
7
 
7
- Webship JS has a ready step definitions for automated functional testing.
8
-
9
- ### Using:
10
- * [Cucumber-js](https://github.com/cucumber/cucumber-js)
11
- * [Nightwatch.js](https://github.com/nightwatchjs/nightwatch)
12
8
 
9
+ Webship-js is an Automated Functional Acceptance Testing tool. Helps to ease and speed the work with the End-to-end testing features in web apps or projects. Utilizing [Nightwatch.js](https://github.com/nightwatchjs/nightwatch) and [Cucumber-js](https://github.com/cucumber/cucumber-js). Having custom and advanced general step definitions.
13
10
 
14
11
  ### Webship-js Documentations
15
- All you need to know about [webship-js Docs](https://webship.co/docs/webship-js/1.0.x).
12
+ All you need to know is at [webship-js Docs](https://webship.co/docs/webship-js/1.0.x).
16
13
 
17
14
 
18
15
  ## Install webship-js using Yarn
@@ -23,11 +23,12 @@ module.exports = {
23
23
  test_settings: {
24
24
  default: {
25
25
  launch_url: 'http://localhost:8080/',
26
+ start_process: true,
26
27
  selenium_port: 4444,
27
28
  selenium_host: '127.0.0.1',
28
29
  silent: true,
29
30
  screenshots: {
30
- enabled: true,
31
+ enabled: false,
31
32
  path: './reports/screenshots',
32
33
  },
33
34
 
@@ -75,14 +76,18 @@ module.exports = {
75
76
  'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : ''),
76
77
  },
77
78
  },
79
+
80
+ webdriver: {
81
+ start_process: false
82
+ },
78
83
  },
79
84
 
80
85
  'selenium.chrome': {
81
- extends: 'selenium_server',
86
+ extends: 'selenium',
82
87
  desiredCapabilities: {
83
88
  browserName: 'chrome',
84
89
  chromeOptions: {
85
- w3c: true,
90
+ w3c: false,
86
91
  },
87
92
  },
88
93
  }
@@ -1,4 +1,4 @@
1
- image: node:16 # Choose an appropriate Node.js version
1
+ image: node:18 # Choose an appropriate Node.js version
2
2
 
3
3
  pipelines:
4
4
  default:
@@ -38,7 +38,7 @@
38
38
  <p><label for="pword"><b>Password</b></label></p>
39
39
  <p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
40
40
 
41
- <p><input id="reset" type="reset" value="Reset"><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()"></p>
41
+ <p><input id="reset" type="reset" value="Reset" /><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()" /></p>
42
42
 
43
43
  </div>
44
44
 
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <title>Press Button</title>
6
+ <style>
7
+ .container,
8
+ .container input,
9
+ .container button{
10
+ font-size: 26px;
11
+ }
12
+ .style{
13
+ width: 400px;
14
+ height: 50px;
15
+ font-size: 18px;
16
+ line-height: 50px;
17
+ text-align: center;
18
+ }
19
+ </style>
20
+
21
+ <script>
22
+ function onClick(){
23
+ const username = document.getElementById("uname");
24
+ const password = document.getElementById("pword");
25
+ const element = document.getElementById("result");
26
+ element.innerText = "You enter Username: " + username.value + " and Password: " + password.value;
27
+ }
28
+ </script>
29
+
30
+ </head>
31
+ <body>
32
+ <h1>Login</h1>
33
+
34
+ <div class="container">
35
+ <p><label for="uname"><b>Username</b></label></p>
36
+ <p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
37
+
38
+ <p><label for="pword"><b>Password</b></label></p>
39
+ <p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
40
+
41
+ <p><input id="reset" type="reset" value="Reset" /><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()" /></p>
42
+
43
+ </div>
44
+
45
+ <div id="result" class="style"></div><br/>
46
+
47
+ </body>
48
+ </html>
@@ -30,12 +30,14 @@
30
30
  <body>
31
31
  <h1>Check Option</h1>
32
32
  <form>
33
- <input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
33
+ <input type="checkbox" id="bike" name="vehicle1" value="Bike">
34
34
  <label for="vehicle1"> I have a bike</label><br>
35
- <input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
35
+ <input type="checkbox" id="car" name="vehicle2" value="Car">
36
36
  <label for="vehicle2"> I have a car</label><br>
37
- <input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
37
+ <input type="checkbox" id="boat" name="vehicle3" value="Boat">
38
38
  <label for="vehicle3"> I have a boat</label><br>
39
+ <input type="checkbox" id="van" class="van" name="vehicle4a" value="Van">
40
+ <label for="vehicle4"> I have a van</label><br>
39
41
  </form>
40
42
 
41
43
  <input id="btnClick" class="btnClick" name="btnClick" type="button" value="Submit" onclick="onClick()">
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta http-equiv='X-UA-Compatible' content='IE=edge'>
6
+ <title>Test Acceptable URL Path</title>
7
+ </head>
8
+ <body>
9
+ Example for test acceptable URL path that have "-" between words.
10
+ </body>
11
+ </html>
@@ -6,7 +6,7 @@ var options = {
6
6
  output: 'tests/reports/cucumber_report.html',
7
7
  reportSuiteAsScenarios: true,
8
8
  scenarioTimestamp: true,
9
- launchReport: true,
9
+ launchReport: false,
10
10
  brandTitle: "Test Report",
11
11
  metadata: {
12
12
  "App Version": "7.1.0",
@@ -1,33 +1,66 @@
1
1
 
2
2
  module.exports.assertion = function (checkbox, negativeCase) {
3
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
+
4
37
  browser.element('css selector', checkbox, function (result) {
5
38
  if (result.status === 0) {
6
39
  if (negativeCase) {
7
- return browser.expect.element(checkbox).to.not.be.selected;
40
+ return browser.expect.element(checkbox).to.not.be.selected.end();
8
41
  }
9
- return browser.expect.element(checkbox).to.be.selected;
42
+ return browser.expect.element(checkbox).to.be.selected.end();
10
43
  } else {
11
44
  browser.element('css selector', '#' + checkbox, function (result) {
12
45
  if (result.status === 0) {
13
46
  if (negativeCase) {
14
- return browser.expect.element('#' + checkbox).to.not.be.selected;
47
+ return browser.expect.element('#' + checkbox).to.not.be.selected.end();
15
48
  }
16
- return browser.expect.element('#' + checkbox).to.be.selected;
49
+ return browser.expect.element('#' + checkbox).to.be.selected.end();
17
50
  } else {
18
51
  browser.element('css selector', 'input[name="' + checkbox + '"]', function (result) {
19
52
  if (result.status === 0) {
20
53
  if (negativeCase) {
21
- return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected;
54
+ return browser.expect.element('input[name="' + checkbox + '"]').to.not.be.selected.end();
22
55
  }
23
- return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected;
56
+ return browser.expect.element('input[name="' + checkbox + '"]').to.be.selected.end();
24
57
  } else {
25
58
  browser.element('css selector', 'input[value="' + checkbox + '"]', function (result) {
26
59
  if (result.status === 0) {
27
60
  if (negativeCase) {
28
- return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected;
61
+ return browser.expect.element('input[value="' + checkbox + '"]').to.not.be.selected.end();
29
62
  }
30
- return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected;
63
+ return browser.expect.element('input[value="' + checkbox + '"]').to.be.selected.end();
31
64
  } else {
32
65
  browser.elements('css selector', 'label', function (elements) {
33
66
  elements.value.forEach(function (elementsObj) {
@@ -35,9 +68,9 @@ module.exports.assertion = function (checkbox, negativeCase) {
35
68
  if (result.value == checkbox) {
36
69
  browser.getAttribute(elementsObj, "for", function (forVal) {
37
70
  if (negativeCase) {
38
- return browser.expect.element('#' + forVal.value).to.not.be.selected;
71
+ return browser.expect.element('#' + forVal.value).to.not.be.selected.end();
39
72
  }
40
- return browser.expect.element('#' + forVal.value).to.be.selected;
73
+ return browser.expect.element('#' + forVal.value).to.be.selected.end();
41
74
  });
42
75
  }
43
76
  })
@@ -7,33 +7,65 @@ module.exports.assertion = function (element, negativeCase, elementCss) {
7
7
  const cssProperty = cssPropertyArr[0].trim();
8
8
  const propertyVal = cssPropertyArr[1].trim();
9
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
+
10
42
  browser.element('css selector', element, function (result) {
11
43
  if (result.status === 0) {
12
44
  if (negativeCase) {
13
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
45
+ return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
14
46
  }
15
- return browser.assert.cssProperty(element, cssProperty, propertyVal);
47
+ return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
16
48
  } else {
17
49
  browser.element('css selector', '#' + element, function (result) {
18
50
  if (result.status === 0) {
19
51
  if (negativeCase) {
20
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
52
+ return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
21
53
  }
22
- return browser.assert.cssProperty(element, cssProperty, propertyVal);
54
+ return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
23
55
  } else {
24
56
  browser.element('css selector', 'input[name="' + element + '"]', function (result) {
25
57
  if (result.status === 0) {
26
58
  if (negativeCase) {
27
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
59
+ return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
28
60
  }
29
- return browser.assert.cssProperty(element, cssProperty, propertyVal);
61
+ return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
30
62
  } else {
31
63
  browser.element('css selector', 'input[value="' + element + '"]', function (result) {
32
64
  if (result.status === 0) {
33
65
  if (negativeCase) {
34
- return browser.assert.not.cssProperty(element, cssProperty, propertyVal);
66
+ return browser.assert.not.cssProperty(element, cssProperty, propertyVal).end();
35
67
  }
36
- return browser.assert.cssProperty(element, cssProperty, propertyVal);
68
+ return browser.assert.cssProperty(element, cssProperty, propertyVal).end();
37
69
  } else {
38
70
  browser.elements('css selector', 'label', function (elements) {
39
71
  elements.value.forEach(function (elementsObj) {
@@ -43,9 +75,9 @@ module.exports.assertion = function (element, negativeCase, elementCss) {
43
75
 
44
76
  console.log('#' + forVal.value, cssProperty, propertyVal);
45
77
  if (negativeCase) {
46
- return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal);
78
+ return browser.assert.not.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
47
79
  }
48
- return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal);
80
+ return browser.assert.cssProperty('#' + forVal.value, cssProperty, propertyVal).end();
49
81
  });
50
82
  }
51
83
  })
@@ -1,33 +1,65 @@
1
1
 
2
2
  module.exports.assertion = function (negativeCase, expectedText, element) {
3
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
+ this.pass = function (value) {
29
+ return this.evaluate(value);
30
+ };
31
+
32
+ this.failure = function (result) {
33
+ return result === false || result && result.status === -1;
34
+ };
35
+
4
36
  browser.element('css selector', element, function (result) {
5
37
  if (result.status === 0) {
6
38
  if (negativeCase) {
7
- return browser.assert.not.textContains(element, expectedText);
39
+ return browser.assert.not.textContains(element, expectedText).end();
8
40
  }
9
- return browser.assert.textContains(element, expectedText);
41
+ return browser.assert.textContains(element, expectedText).end();
10
42
  } else {
11
43
  browser.element('css selector', '#' + element, function (result) {
12
44
  if (result.status === 0) {
13
45
  if (negativeCase) {
14
- return browser.assert.not.textContains(element, expectedText);
46
+ return browser.assert.not.textContains(element, expectedText).end();
15
47
  }
16
- return browser.assert.textContains(element, expectedText);
48
+ return browser.assert.textContains(element, expectedText).end();
17
49
  } else {
18
50
  browser.element('css selector', 'input[name="' + element + '"]', function (result) {
19
51
  if (result.status === 0) {
20
52
  if (negativeCase) {
21
- return browser.assert.not.textContains(element, expectedText);
53
+ return browser.assert.not.textContains(element, expectedText).end();
22
54
  }
23
- return browser.assert.textContains(element, expectedText);
55
+ return browser.assert.textContains(element, expectedText).end();
24
56
  } else {
25
57
  browser.element('css selector', 'input[value="' + element + '"]', function (result) {
26
58
  if (result.status === 0) {
27
59
  if (negativeCase) {
28
- return browser.assert.not.textContains(element, expectedText);
60
+ return browser.assert.not.textContains(element, expectedText).end();
29
61
  }
30
- return browser.assert.textContains(element, expectedText);
62
+ return browser.assert.textContains(element, expectedText).end();
31
63
  } else {
32
64
  browser.elements('css selector', 'label', function (elements) {
33
65
  elements.value.forEach(function (elementsObj) {
@@ -35,9 +67,9 @@ module.exports.assertion = function (negativeCase, expectedText, element) {
35
67
  if (result.value == element) {
36
68
  browser.getAttribute(elementsObj, "for", function (forVal) {
37
69
  if (negativeCase) {
38
- return browser.assert.not.textContains('#' + forVal.value, expectedText);
70
+ return browser.assert.not.textContains('#' + forVal.value, expectedText).end();
39
71
  }
40
- return browser.assert.textContains('#' + forVal.value, expectedText);
72
+ return browser.assert.textContains('#' + forVal.value, expectedText).end();
41
73
  });
42
74
  }
43
75
  })
@@ -0,0 +1,13 @@
1
+ const request = require("request");
2
+
3
+ module.exports.assertion = function (negativeCase, expectedStatusCode) {
4
+
5
+ return browser.url(function (currentURL) {
6
+ request(currentURL.value, (error, response, body) => {
7
+ if (negativeCase) {
8
+ return browser.assert.not.equal(response.statusCode, expectedStatusCode).end();
9
+ }
10
+ return browser.assert.equal(response.statusCode, expectedStatusCode).end();
11
+ });
12
+ });
13
+ }
@@ -0,0 +1,8 @@
1
+
2
+ module.exports.assertion = function (negativeCase, element) {
3
+
4
+ if (negativeCase) {
5
+ return browser.verify.not.visible(element).end();
6
+ }
7
+ return browser.verify.visible(element).end();
8
+ }