Skip to content

Commit

Permalink
Update the step definition to fill form fields of type input Text wit…
Browse files Browse the repository at this point in the history
…h the provided table according to their labels #148
  • Loading branch information
TasneemNatshah committed Jul 13, 2024
1 parent 8789ec7 commit 62a8ddd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/features/test--when--i-fill-in.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ I want to be able to fill input text with value
Scenario: Check fill in table of input fields
Given I am on "/test--when--i-fill-in.html"
When I fill in the following:
| #uname | John Smith |
| #pword | 1234 |
| Username | John Smith |
| Password | 1234 |
When I press "Login" by attr
Then I should see "You enter Username: John Smith and Password: 1234"
24 changes: 14 additions & 10 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,25 @@ When(/^(I|we)* fill in "([^"]*)?" for "([^"]*)?" by( its)*( "([^"]*)?")* (attrib
});

/**
* Fills in form fields with provided table
* Fills in form input fields type text with provided table by there labels
* Example: When I fill in the following:
* | username | webshipco |
* | password | 1234 |
* Example: And I fill in the following"
* | username | webshipco |
* | password | 1234 |
*
* | Username | webshipco |
* | Password | 1234 |
*/

When(/^(I|we)* fill in the following:$/, function (pronoundCase, table) {

browser.setValue(table.rawTable[0][0], table.rawTable[0][1]);
var elementField = browser.element.findByText(table.rawTable[0][0]);
browser.getAttribute(elementField, 'for', function (eleAttribute) {
browser.setValue('#' + eleAttribute.value, table.rawTable[0][1]);
});

table.rows().forEach(row => {
browser.setValue(row[0], row[1]);
// browser.fillTextInput(row[0], row[1]);

elementField = browser.element.findByText(row[0]);
browser.getAttribute(elementField, 'for', function (eleAttribute2) {
browser.setValue('#' + eleAttribute2.value, row[1]);
});
});
});

Expand Down

0 comments on commit 62a8ddd

Please sign in to comment.