Skip to content

Commit

Permalink
Change assertion that input text field should contains a specific val…
Browse files Browse the repository at this point in the history
…ue to be by its label #167
  • Loading branch information
TasneemNatshah committed Aug 15, 2024
1 parent d234e49 commit 65ad718
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Feature: An example to test if the field contains certain value
Feature: An example to test if the field contains certain value by element label
As a tester
I want to be able to check field if has a certain value or not
I want to be able to check field if has a certain value by element label

Scenario: Check field if has a particular value or not
Scenario: Check field if has a particular value by element label
Given I am on "/test--then--i-should--not--see-text-in-element.html"
And I fill in "Username" with "user1"
Then the "#uname" field should contain "user1"
Then the "Username" field should contain "user1"
When I press "Reset" by attr
And I fill in "Username" with "user2"
Then the "#uname" field should not contain "user1"
Then the "Username" field should contain "user2"
11 changes: 7 additions & 4 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,14 +765,17 @@ When(/^(I|we)* attach the file "([^"]*)?" to "([^"]*)?"$/, function (pronoundCas

/**
* Assert, that field contain a specific text
* Example: Then the "#username" field should contain "John Smith"
* Example: Then the "Username" field should contain "John Smith"
*
*/
Then(/^the "([^"]*)?" field should contain "([^"]*)?"$/, function (field, expectedText) {

return this.shouldSee = function (browser) {
browser.assert.textContains(field, expectedText);
};
const elementField = browser.element.findByText(field);
browser.getAttribute(elementField, 'for', function (eleAttribute) {
return this.shouldSee = function (browser) {
browser.assert.textContains('#' + eleAttribute.value, expectedText);
};
});
});

/**
Expand Down

0 comments on commit 65ad718

Please sign in to comment.