webship-js 1.0.30 → 1.0.31

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 (28) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.github/workflows/github-actions.yml +42 -18
  3. package/assets/config_templates/circleci-linux-chrome.conf.js +1 -1
  4. package/assets/config_templates/github-linux-chrome.conf.js +1 -1
  5. package/examples/test--then--i-should--not--see-text-in-element.html +2 -2
  6. package/examples/test--then--i-should--see-text-in-element.html +2 -2
  7. package/examples/test--then--the-element-should_not-contain-cssproperty.html +2 -2
  8. package/examples/test--when--i-fill-in.html +4 -4
  9. package/examples/test--when--i-press-button.html +5 -2
  10. package/examples/test--when--i-select-option-from-dropdownlist.html +1 -1
  11. package/nightwatch.conf.js +2 -2
  12. package/package.json +1 -1
  13. package/tests/features/test--then--i-should--not--see-text-in-element.feature +5 -5
  14. package/tests/features/test--then--the-checkbox-is-checked.feature +2 -2
  15. package/tests/features/test--then--the-checkbox-should-be-checked.feature +2 -2
  16. package/tests/features/test--then--the-element-should_not-contain-cssproperty.feature +2 -2
  17. package/tests/features/test--then--the-field-should-contain-value.feature +3 -3
  18. package/tests/features/test--when--i-attach-file-to-feild.feature +1 -1
  19. package/tests/features/test--when--i-check-checkbox.feature +4 -4
  20. package/tests/features/test--when--i-click-link-by-attribute.feature +16 -0
  21. package/tests/features/test--when--i-fill-in-by-attr.feature +17 -0
  22. package/tests/features/test--when--i-fill-in-table-by-attr.feature +19 -0
  23. package/tests/features/test--when--i-fill-in.feature +13 -12
  24. package/tests/features/test--when--i-press-button-by-attribute.feature +15 -0
  25. package/tests/features/test--when--i-press-button.feature +2 -2
  26. package/tests/features/test--when--i-reload-page.feature +1 -1
  27. package/tests/features/test--when--i-select-option-from-dropdownlist.feature +2 -4
  28. package/tests/step-definitions/webship.js +213 -18
@@ -44,7 +44,7 @@ commands:
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
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
47
+ wget https://mirror.cs.uchicago.edu/google-chrome/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
48
48
  sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
49
49
  rm google-chrome-stable_${CHROME_VERSION}_amd64.deb
50
50
 
@@ -4,38 +4,62 @@ on: [push]
4
4
 
5
5
  jobs:
6
6
  build:
7
-
8
7
  runs-on: ubuntu-latest
9
8
 
10
9
  env:
11
10
  TEST_BASE_URL: http://localhost:8080
12
- SELENIUM_HOST: http://selenium:4444/wd/hub
11
+ SELENIUM_HOST: http://localhost:4444/wd/hub
13
12
 
14
13
  steps:
15
- - name: Install Chrome
14
+ - name: Install/Update Google Chrome browser
15
+ run: |
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="115.0.5790.110-1"
20
+ wget https://mirror.cs.uchicago.edu/google-chrome/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
+
24
+ - name: Install/Update Chrome Driver
16
25
  run: |
17
- CHROME_VERSION="115.0.5790.110-1"
18
- wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
19
- sudo dpkg -i google-chrome-stable_${CHROME_VERSION}_amd64.deb
20
-
21
- - uses: actions/checkout@v3
22
- - name: Use Node.js
26
+ CHROME_DRIVER_VERSION=114.0.5735.90;
27
+ echo $CHROME_DRIVER_VERSION;
28
+ wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
29
+ unzip chromedriver_linux64.zip
30
+ sudo chmod +x chromedriver
31
+ sudo mv -f chromedriver /usr/bin/
32
+ rm chromedriver_linux64.zip
33
+
34
+ - name: Checkout repository
35
+ uses: actions/checkout@v3
36
+
37
+ - name: Set up Node.js
23
38
  uses: actions/setup-node@v3
24
39
  with:
25
40
  node-version: '18.x'
26
41
 
42
+ - name: Install Java
43
+ run: |
44
+ sudo apt update
45
+ sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
46
+
27
47
  - name: Run Selenium Standalone server
28
48
  run: |
29
- wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.1.0/selenium-server-4.1.2.jar
30
- java -jar selenium-server-4.1.2.jar standalone
31
-
32
- - name: Install
49
+ wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.4.0/selenium-server-4.4.0.jar
50
+ nohup java -jar selenium-server-4.4.0.jar standalone > selenium.log 2>&1 &
51
+
52
+
53
+ - name: Install dependencies
33
54
  run: yarn install
34
- - name: Configure nightwatch.conf.js for Github
35
- run: node webship-init -ci github -os linux -b chrome
55
+
56
+ - name: Configure nightwatch.conf.js for GitHub
57
+ run: node webship-init -ci circleci -os linux -b chrome
58
+
36
59
  - name: Start virtual server
37
60
  run: |
38
- export NODE_OPTIONS=--openssl-legacy-provider
39
- yarn start &
40
- - name: Test
61
+ export NODE_OPTIONS=--openssl-legacy-provider
62
+ yarn start &
63
+
64
+ - name: Run tests
41
65
  run: yarn test
@@ -38,7 +38,7 @@ module.exports = {
38
38
  // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
39
39
  //
40
40
  // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
41
- w3c: false,
41
+ w3c: true,
42
42
  args: [
43
43
  '--headless',
44
44
  '--start-maximized',
@@ -48,7 +48,7 @@ module.exports = {
48
48
  // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
49
49
  //
50
50
  // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
51
- w3c: false,
51
+ w3c: true,
52
52
  args: [
53
53
  '--headless',
54
54
  '--start-maximized',
@@ -32,10 +32,10 @@
32
32
  <h1>Login</h1>
33
33
 
34
34
  <div class="container">
35
- <p><label for="uname"><b>Username</b></label></p>
35
+ <p><label for="uname">Username</label></p>
36
36
  <p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
37
37
 
38
- <p><label for="pword"><b>Password</b></label></p>
38
+ <p><label for="pword">Password</label></p>
39
39
  <p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
40
40
 
41
41
  <p><input id="reset" type="reset" value="Reset" /><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()" /></p>
@@ -32,10 +32,10 @@
32
32
  <h1>Login</h1>
33
33
 
34
34
  <div class="container">
35
- <p><label for="uname"><b>Username</b></label></p>
35
+ <p><label for="uname">Username</label></p>
36
36
  <p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
37
37
 
38
- <p><label for="pword"><b>Password</b></label></p>
38
+ <p><label for="pword">Password</label></p>
39
39
  <p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
40
40
 
41
41
  <p><input id="reset" type="reset" value="Reset" /><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()" /></p>
@@ -31,10 +31,10 @@
31
31
  <h1>Login</h1>
32
32
 
33
33
  <div class="container">
34
- <p><label for="uname"><b>Username</b></label></p>
34
+ <p><label for="uname">Username</label></p>
35
35
  <p><input id="uname" class="unamecss" type="text" placeholder="Enter Username" name="username"></p>
36
36
 
37
- <p><label for="pword"><b>Password</b></label></p>
37
+ <p><label for="pword">Password</label></p>
38
38
  <p><input id="pword" class="pwordcss" type="password" placeholder="Enter Password" name="password"></p>
39
39
 
40
40
  <p><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Submit" onclick="onClick()"></p>
@@ -32,11 +32,11 @@
32
32
  <h1>Login</h1>
33
33
 
34
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>
35
+ <p><label for="uname">Username</label></p>
36
+ <p><input id="uname" class="unamecss" type="text" placeholder="Your full name" name="username"></p>
37
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>
38
+ <p><label for="pword">Password</label></p>
39
+ <p><input id="pword" class="pwordcss" type="password" placeholder="Your Password" name="password"></p>
40
40
 
41
41
  <p><input id="btnLogin" class="btnLogin" name="btnLogin" type="button" value="Login" onclick="onClick()"></p>
42
42
 
@@ -22,7 +22,10 @@
22
22
  <body>
23
23
  <h1>Press Button</h1>
24
24
  <div id="result" class="style"></div><br/>
25
- <label for="btnClickid">Press button</label>
26
- <input id="btnClickid" class="btnClickclass" name="btnClickname" type="button" value="Submit" onclick="onClick()">
25
+ <label for="btn-pressid">Press button</label>
26
+ <button id="btn-pressid" class="btn-pressclass" name="btn-pressname" onclick="onClick()">Button</button>
27
+
28
+ <input type="submit" id="submit-pressid" class="submit-pressclass" name="submit-pressname" value="Submit" onclick="onClick()" />
29
+
27
30
  </body>
28
31
  </html>
@@ -29,7 +29,7 @@
29
29
  <option value="mercedes">Mercedes</option>
30
30
  <option value="audi">Audi</option>
31
31
  </select>
32
- <input id="btnClick" class="btnClick" name="btnClick" type="button" value="Check select" onclick="onClick()">
32
+ <input id="btnClick" class="btnClick" name="btnClick" type="button" value="Submit" onclick="onClick()">
33
33
  <div id="result" class="style"></div><br/>
34
34
  </body>
35
35
  </html>
@@ -1,5 +1,5 @@
1
1
  const Services = {}; loadServices();
2
- require('events').EventEmitter.defaultMaxListeners = 100;
2
+ require('events').EventEmitter.defaultMaxListeners = 1000;
3
3
 
4
4
  module.exports = {
5
5
  // An array of folders (excluding subfolders) where your tests are located;
@@ -38,7 +38,7 @@ module.exports = {
38
38
  // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
39
39
  //
40
40
  // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
41
- w3c: false,
41
+ w3c: true,
42
42
  args: [
43
43
  '--headless',
44
44
  '--start-maximized',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
@@ -4,14 +4,14 @@ Feature: An example to test whether an element contains a certain text or not
4
4
 
5
5
  Scenario: Check an element if it contains a specific text
6
6
  Given I am on "/test--then--i-should--not--see-text-in-element.html"
7
- And I fill in "#uname" with "user1"
8
- And I fill in "#pword" with "1234"
7
+ When I fill in "Username" with "user1"
8
+ And I fill in "Password" with "1234"
9
9
  Then I should see "user1" in the "#uname" element
10
- When I fill in "#uname" with:
11
- And I fill in "#pword" with:
10
+ When I fill in "uname" with: by attr
11
+ And I fill in "Password" with:
12
12
  Then I should not see "user1" in the "#uname" element
13
13
 
14
14
  Scenario: Check an element if it does not contain a specific text
15
15
  Given I am on "/test--then--i-should--not--see-text-in-element.html"
16
- And I fill in "#uname" with "user2"
16
+ And I fill in "Username" with "user2"
17
17
  Then I should not see "user1" in the "#uname" element
@@ -6,13 +6,13 @@ Feature: An example of test for selecting a checkbox
6
6
  Given I am on "/test--then--the-checkbox-checked.html"
7
7
  When I check "rememberMe"
8
8
  And I check "PrivacyPolicy"
9
- And I press "Register"
9
+ And I press "Register" by attr
10
10
  Then the checkbox "#rememberMe" is checked
11
11
  And I should see "Registration Done Successfully"
12
12
 
13
13
  Scenario: Check that the checkbox is not checked
14
14
  Given I am on "/test--then--the-checkbox-checked.html"
15
15
  When I check "PrivacyPolicy"
16
- And I press "Register"
16
+ And I press "Register" by attr
17
17
  Then the checkbox "#rememberMe" is not checked
18
18
  Then I should see "Registration Done Successfully"
@@ -5,12 +5,12 @@ Feature: An example of test assert for selecting a checkbox
5
5
  Scenario: Check that the checkbox should be checked
6
6
  Given I am on "/test--then--the-checkbox-checked.html"
7
7
  When I check "PrivacyPolicy"
8
- And I press "Register"
8
+ And I press "Register" by attr
9
9
  Then the checkbox "#PrivacyPolicy" should be checked
10
10
  And I should see "Registration Done Successfully"
11
11
 
12
12
  Scenario: Check that the checkbox should not be checked
13
13
  Given I am on "/test--then--the-checkbox-checked.html"
14
- When I press "Register"
14
+ When I press "Register" by attr
15
15
  Then the "#PrivacyPolicy" checkbox should not be checked
16
16
  And I should see "Please check Agree to Privacy Policy"
@@ -5,11 +5,11 @@ Feature: An example to test if the element contains a certain expected CSS prope
5
5
  Scenario: Check element if the element contains a certain expected CSS property
6
6
  Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
7
7
  Then I should see a "body" element
8
- When I press "Submit"
8
+ When I press "Submit" by attr
9
9
  Then the "body" element should contain "background-color:white;"
10
10
 
11
11
  Scenario: Check element if the element not contains a certain CSS property
12
12
  Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
13
13
  Then I should see a "body" element
14
- When I press "Submit"
14
+ When I press "Submit" by attr
15
15
  Then the "#uname" element should not contain "border:solid 5px red;"
@@ -4,8 +4,8 @@ Feature: An example to test if the field contains certain value
4
4
 
5
5
  Scenario: Check field if has a particular value or not
6
6
  Given I am on "/test--then--i-should--not--see-text-in-element.html"
7
- And I fill in "#uname" with "user1"
7
+ And I fill in "Username" with "user1"
8
8
  Then the "#uname" field should contain "user1"
9
- When I press "Reset"
10
- And I fill in "#uname" with "user2"
9
+ When I press "Reset" by attr
10
+ And I fill in "Username" with "user2"
11
11
  Then the "#uname" field should not contain "user1"
@@ -6,5 +6,5 @@ Feature: An example to test attach file to field
6
6
  # Scenario: Check attach file to field
7
7
  # Given I am on "/test--when--i-attach-file-to-feild.html"
8
8
  # When I attach the file "webshipco.png" to "#fileUpload"
9
- # When I press "Submit"
9
+ # When I press "Submit" by attr
10
10
  # Then I should see "webshipco.png"
@@ -7,16 +7,16 @@ Feature: An example to uncheck the checkbox
7
7
  Given I am on "/test--when--i-check-uncheck-checkbox.html"
8
8
  When I check "bike"
9
9
  And I check "car"
10
- And I press "Submit"
10
+ And I press "Submit" by "value" attr
11
11
  Then I should see "You have a Bike Car"
12
12
  When I check "van"
13
- And I press "Submit"
13
+ And I press "Submit" by "value" attr
14
14
  Then I should see "You have a Bike Car Van"
15
15
  When I uncheck "bike"
16
- And I press "Submit"
16
+ And I press "Submit" by "value" attr
17
17
  Then I should see "You have a Car Van"
18
18
  When I uncheck "car"
19
19
  When I uncheck "van"
20
- And I press "Submit"
20
+ And I press "Submit" by "value" attr
21
21
  Then I should see "You have a"
22
22
 
@@ -0,0 +1,16 @@
1
+ Feature: An example to click link by its attribute
2
+
3
+ As a tester
4
+ I want to be able to click link by its attribute
5
+
6
+ Scenario: Check click link by class attribute
7
+ Given I am on "/test--when--i-click-link.html"
8
+ When I click "aboutUs" by "class" attr
9
+ And I wait max of 2 seconds
10
+ Then I should see "About Us"
11
+
12
+ Scenario: Check click link by its id attribute
13
+ Given I am on "/test--when--i-click-link.html"
14
+ When I click "aboutUsid" by its "id" attribute
15
+ And I wait max of 2 seconds
16
+ Then I should see "About Us"
@@ -0,0 +1,17 @@
1
+ Feature: An example of filling the input textbox with value by its attribute
2
+ As a tester
3
+ I want to be able to fill input text with value by its attribute
4
+
5
+ Scenario: Check fill in input field with ID and class attribute
6
+ Given I am on "/test--when--i-fill-in.html"
7
+ When I fill in "uname" with "John Smith" by attr
8
+ And I fill in "pwordcss" with "1234" by attr
9
+ When I press "Login"
10
+ Then I should see "You enter Username: John Smith and Password: 1234"
11
+
12
+ Scenario: Check fill in input field with value and placeholder attribute
13
+ Given I am on "/test--when--i-fill-in.html"
14
+ When I fill in "Your full name" with "John Smith" by its "placeholder" attr
15
+ And I fill in "Your Password" with "1234" by attr
16
+ When I press "Login"
17
+ Then I should see "You enter Username: John Smith and Password: 1234"
@@ -0,0 +1,19 @@
1
+ Feature: An example of filling the input text with value by attribute
2
+ As a tester
3
+ I want to be able to fill input text with value by attribute
4
+
5
+ Scenario: Check fill in table of input fields by different attribute
6
+ Given I am on "/test--when--i-fill-in.html"
7
+ When I fill in the following: by attr
8
+ | uname | John Smith |
9
+ | pwordcss | 1234 |
10
+ When I press "Login"
11
+ Then I should see "You enter Username: John Smith and Password: 1234"
12
+
13
+ Scenario: Check fill in table of input fields by specific attribute
14
+ Given I am on "/test--when--i-fill-in.html"
15
+ When I fill in the following: by its "placeholder" attribute
16
+ | Your full name | John Smith |
17
+ | Your Password | 1234 |
18
+ When I press "Login"
19
+ Then I should see "You enter Username: John Smith and Password: 1234"
@@ -4,28 +4,29 @@ I want to be able to fill input text with value
4
4
 
5
5
  Scenario: Check fill in input field with value
6
6
  Given I am on "/test--when--i-fill-in.html"
7
- When I fill in "#uname" with "John Smith"
8
- When I fill in "#pword" with "1234"
9
- When I press "Login"
7
+ When I fill in "Username" with "John Smith"
8
+ When I fill in "Password" with "1234"
9
+ When I press "Login" by attr
10
10
  Then I should see "You enter Username: John Smith and Password: 1234"
11
11
 
12
12
  Scenario: Check fill in input field with empty value
13
13
  Given I am on "/test--when--i-fill-in.html"
14
- When I fill in "#uname" with:
15
- When I press "Login"
16
- Then I should see "You enter Username: "
14
+ When I fill in "uname" with: by its "id" attribute
15
+ And I fill in "Your Password" with: by attr
16
+ When I press "Login" by attr
17
+ Then I should see "You enter Username: and Password:"
17
18
 
18
19
  Scenario: Check fill in value for input field
19
20
  Given I am on "/test--when--i-fill-in.html"
20
- When I fill in "John Smith" for "#uname"
21
- When I fill in "1234" for "#pword"
22
- When I press "Login"
21
+ When I fill in "John Smith" for "Username"
22
+ When I fill in "1234" for "pword" by its "id" attr
23
+ When I press "Login" by attr
23
24
  Then I should see "You enter Username: John Smith and Password: 1234"
24
25
 
25
26
  Scenario: Check fill in table of input fields
26
27
  Given I am on "/test--when--i-fill-in.html"
27
28
  When I fill in the following:
28
- | #uname | John Smith |
29
- | #pword | 1234 |
30
- When I press "Login"
29
+ | Username | John Smith |
30
+ | Password | 1234 |
31
+ When I press "Login" by attr
31
32
  Then I should see "You enter Username: John Smith and Password: 1234"
@@ -0,0 +1,15 @@
1
+ Feature: An example to press a button
2
+
3
+ As a tester
4
+ I want to be able to press a button
5
+
6
+ Scenario: Verify clicking a button using its ID attribute.
7
+ Given I am on "/test--when--i-press-button.html"
8
+ When I press "btn-pressid" by "id" attr
9
+ Then I should see "Button Pressed Successfully"
10
+
11
+ Scenario: Verify that you can click a button using its default name attribute.
12
+ Given I am on "/test--when--i-press-button.html"
13
+ When I press "btn-pressname" by attr
14
+ Then I should see "Button Pressed Successfully"
15
+
@@ -5,5 +5,5 @@ Feature: An example to press a button
5
5
 
6
6
  Scenario: Check press a button
7
7
  Given I am on "/test--when--i-press-button.html"
8
- When I press "Submit"
9
- Then I should see "Button Pressed Successfully"
8
+ When I press "Submit"
9
+ Then I should see "Button Pressed Successfully"
@@ -5,7 +5,7 @@ I want to be able to reload the page
5
5
 
6
6
  Scenario: Check to reload the page
7
7
  Given I am on "/test--when--i-reload-page.html"
8
- When I press "Submit"
8
+ When I press "Submit" by attr
9
9
  Then I should see "Button Pressed Successfully"
10
10
  When I reload the page
11
11
  Then I should not see "Button Pressed Successfully"
@@ -6,7 +6,5 @@ Feature: An example to select option from drop down list
6
6
  Scenario: Check of selecting option from drop down list
7
7
  Given I am on "/test--when--i-select-option-from-dropdownlist.html"
8
8
  When I select "Saab" from "cars"
9
- When I press "Check select"
10
- Then I should see "Option ( Saab ) has been selected successfully"
11
-
12
-
9
+ When I press "Submit" by attr
10
+ Then I should see "Option ( Saab ) has been selected successfully"
@@ -107,7 +107,34 @@ When(/^(I|we)* move backward one page$/, function (pronoundCase) {
107
107
  *
108
108
  */
109
109
  When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
110
- browser.click('[value="' + element + '"]');
110
+ browser.click("[value='" + element +"']");
111
+ });
112
+
113
+ /**
114
+ * Presses button with specified element
115
+ * Example: When I press "btn-pressid" by attr
116
+ * Example: When I press "btn-pressid" by attribute
117
+ * Example: And I press "Your full name" by "placeholder" attribute
118
+ * Example: And I press "Your full name" by its "placeholder" attribute
119
+ * Example: And I press "save-name" by "data-drupal-selector" attr
120
+ *
121
+ */
122
+ When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
123
+
124
+ const hasASpace = attrValue.indexOf(' ');
125
+
126
+ var selector = '';
127
+ if (!attr && hasASpace == -1){
128
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
129
+ }
130
+ else if (!attr && hasASpace > -1){
131
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
132
+ }
133
+ else {
134
+ selector = '[' + attr + '="' + attrValue + '"]';
135
+ }
136
+
137
+ browser.click(selector);
111
138
  });
112
139
 
113
140
  /**
@@ -120,12 +147,40 @@ When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
120
147
  return browser.click("link text", item);
121
148
  });
122
149
 
150
+ /**
151
+ * Click Link with specified element
152
+ * Example: When I click "aboutUs" by attr
153
+ * Example: When I click "aboutUs" by attribute
154
+ * Example: And I click "aboutUs" by "class" attr
155
+ * Example: And I click "aboutUsid" by its "id" attribute
156
+ *
157
+ */
158
+ When(/^(I|we)* click "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {
159
+
160
+ const hasASpace = attrValue.indexOf(' ');
161
+
162
+ var selector = '';
163
+ if (!attr && hasASpace == -1){
164
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
165
+ }
166
+ else if (!attr && hasASpace > -1){
167
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
168
+ }
169
+ else {
170
+ selector = '[' + attr + '="' + attrValue + '"]';
171
+ }
172
+
173
+ return browser.click(selector);
174
+
175
+ });
176
+
123
177
  /**
124
178
  * Reloads current page
125
179
  * Example: When I reload page
126
180
  * Example: And I reload page
127
181
  *
128
182
  */
183
+
129
184
  When(/^(I|we)* reload page$/, function (pronoundCase) {
130
185
  return browser.refresh(browser.getCurrentUrl());
131
186
  });
@@ -147,43 +202,183 @@ When(/^(I|we)* reload the page$/, function (pronoundCase) {
147
202
  *
148
203
  */
149
204
  When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?"$/, function (pronoundCase, field, value) {
150
- browser.setValue(field, value);
205
+ const elementField = browser.element.findByText(field);
206
+ browser.getAttribute(elementField, 'for', function (eleAttribute) {
207
+ return browser.setValue('#' + eleAttribute.value, value);
208
+ });
151
209
  });
152
210
 
153
211
  /**
154
- * Fills in form field with specified element
155
- * Example: When I fill in "username" with:
212
+ * Fill input type text with value by its attribute
213
+ * Example: When I fill in "uname" with "John Smith" by attr
214
+ * Example: And I fill in "pwordcss" with "1234" by "class" attr
215
+ * Example: And I fill in "Your full name" with "John Smith" by its "placeholder" attribute
216
+ *
217
+ */
218
+ When(/^(I|we)* fill in "([^"]*)?" with "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, txtValue, itsCase, attr, attrCase) {
219
+
220
+ const hasASpace = attrValue.indexOf(' ');
221
+
222
+ var selector = '';
223
+ if (!attr && hasASpace == -1){
224
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
225
+ }
226
+ else if (!attr && hasASpace > -1){
227
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
228
+ }
229
+ else {
230
+ selector = '[' + attr + '="' + attrValue + '"]';
231
+ }
232
+
233
+ return browser.setValue(selector, txtValue);
234
+
235
+ });
236
+
237
+ /**
238
+ * Fill input type text with empty value by its Label
239
+ * Example: When I fill in "Username" with:
156
240
  *
157
241
  */
158
242
  When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
159
- browser.setValue(field, '');
243
+ const elementField = browser.element.findByText(field);
244
+ browser.getAttribute(elementField, 'for', function (eleAttribute) {
245
+ return browser.setValue('#' + eleAttribute.value, '');
246
+ });
160
247
  });
161
248
 
162
249
  /**
163
- * Fills in form field with specified element
164
- * Example: And I fill in "webshipco" for "username"
250
+ * Fill input type text with empty value by its attribute
251
+ * Example: When I fill in "uname" with: by attr
252
+ * Example: And I fill in "pwordcss" with: by "class" attr
253
+ * Example: And I fill in "Your full name" with: by its "placeholder" attribute
254
+ *
255
+ */
256
+ When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue , itsCase, attr, attrCase) {
257
+
258
+ const hasASpace = attrValue.indexOf(' ');
259
+ const txtValue = '';
260
+ var selector = '';
261
+
262
+ if (!attr && hasASpace == -1){
263
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
264
+ }
265
+ else if (!attr && hasASpace > -1){
266
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
267
+ }
268
+ else {
269
+ selector = '[' + attr + '="' + attrValue + '"]';
270
+ }
271
+
272
+ return browser.setValue(selector, txtValue);
273
+
274
+ });
275
+
276
+ /**
277
+ * Fill in value for input type text by its Label
278
+ * Example: When I fill in "webshipco" for "Username"
165
279
  *
166
280
  */
167
281
  When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?"$/, function (pronoundCase, value, field) {
168
- browser.setValue(field, value);
282
+ const elementField = browser.element.findByText(field);
283
+ browser.getAttribute(elementField, 'for', function (eleAttribute) {
284
+ return browser.setValue('#' + eleAttribute.value, value);
285
+ });
169
286
  });
170
287
 
171
288
  /**
172
- * Fills in form fields with provided table
173
- * Example: When I fill in the following:
174
- * | username | webshipco |
175
- * | password | 1234 |
176
- * Example: And I fill in the following"
177
- * | username | webshipco |
178
- * | password | 1234 |
289
+ * Fill in value for input type text by its attribute
290
+ * Example: When I fill in "John Smith" for "uname" by attr
291
+ * Example: And I fill in "1234" for "pwordcss" by "class" attr
292
+ * Example: And I fill in "John Smith" for "Your full name" by its "placeholder" attribute
179
293
  *
180
294
  */
295
+ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, txtValue, attrValue, itsCase, attr, attrCase) {
296
+
297
+ const hasASpace = attrValue.indexOf(' ');
298
+
299
+ var selector = '';
300
+ if (!attr && hasASpace == -1){
301
+ selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
302
+ }
303
+ else if (!attr && hasASpace > -1){
304
+ selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
305
+ }
306
+ else {
307
+ selector = '[' + attr + '="' + attrValue + '"]';
308
+ }
309
+
310
+ return browser.setValue(selector, txtValue);
311
+
312
+ });
313
+
314
+ /**
315
+ * Fills in form input fields type text with provided table by there labels
316
+ * Example: When I fill in the following:
317
+ * | Username | webshipco |
318
+ * | Password | 1234 |
319
+ */
320
+
181
321
  When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {
182
322
 
183
- browser.setValue(table.rawTable[0][0], table.rawTable[0][1]);
323
+ var elementField = browser.element.findByText(table.rawTable[0][0]);
324
+ browser.getAttribute(elementField, 'for', function (eleAttribute) {
325
+ browser.setValue('#' + eleAttribute.value, table.rawTable[0][1]);
326
+ });
327
+
328
+ table.rows().forEach(row => {
329
+
330
+ elementField = browser.element.findByText(row[0]);
331
+ browser.getAttribute(elementField, 'for', function (eleAttribute2) {
332
+ browser.setValue('#' + eleAttribute2.value, row[1]);
333
+ });
334
+ });
335
+ });
336
+
337
+ /**
338
+ * Fill in value for input type text by its attributeFill form fields of type input Text with the provided table according to their attributes
339
+ * Example: When I fill in the following: by attr
340
+ * | uname | John Smith |
341
+ * | pwordcss | 1234 |
342
+
343
+ * Example: When I fill in the following: by its "placeholder" attribute
344
+ * | Your full name | John Smith |
345
+ * | Your Password | 1234 |
346
+ */
347
+
348
+ When(/^(I|we)* fill in the following: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, itsCase, attr, attrCase, table) {
349
+
350
+ var hasASpace = table.rawTable[0][0].indexOf(' ');
351
+ var selector = '';
352
+ if (!attr && hasASpace == -1){
353
+ selector = table.rawTable[0][0] + ',#' + table.rawTable[0][0] + ',.' + table.rawTable[0][0] + ',[name=' + table.rawTable[0][0] + "]," + '[value="' + table.rawTable[0][0] + '"],[placeholder="' + table.rawTable[0][0] + '"]';
354
+ }
355
+ else if (!attr && hasASpace > -1){
356
+ selector ='[value="' + table.rawTable[0][0] + '"],[placeholder="' + table.rawTable[0][0] + '"]';
357
+ }
358
+ else {
359
+ selector = '[' + attr + '="' + table.rawTable[0][0] + '"]';
360
+ }
361
+
362
+ browser.setValue(selector, table.rawTable[0][1]);
363
+
364
+
184
365
  table.rows().forEach(row => {
185
- browser.setValue(row[0], row[1]);
186
- // browser.fillTextInput(row[0], row[1]);
366
+
367
+ hasASpace = row[0].indexOf(' ');
368
+ var selector = '';
369
+ if (!attr && hasASpace == -1){
370
+
371
+ selector = row[0] + ',#' + row[0] + ',.' + row[0] + ',[name=' + row[0] + "]," + '[value="' + row[0] + '"],[placeholder="' + row[0] + '"]';
372
+ }
373
+ else if (!attr && hasASpace > -1){
374
+ selector ='[value="' + row[0] + '"],[placeholder="' + row[0] + '"]';
375
+ }
376
+ else {
377
+ selector = '[' + attr + '="' + row[0] + '"]';
378
+ }
379
+
380
+ browser.setValue(selector, row[1]);
381
+
187
382
  });
188
383
  });
189
384