Skip to content

Commit

Permalink
Update assertion that input text contains a specific value to be by i…
Browse files Browse the repository at this point in the history
…ts label #153
  • Loading branch information
TasneemNatshah committed Jul 20, 2024
1 parent 5b7aee0 commit 14dc2f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tests/features/test--then--i-should--see-text-in-element.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: An example to test whether an input text contains a certain text by its label
As a tester
I want to be able to check an element contains a certain text or not

Scenario: Check an element if it contains a specific text
Given I am on "/test--then--i-should--not--see-text-in-element.html"
When I fill in "Username" with "user1"
And I fill in "Password" with "1234"
Then I should see "user1" in the "Username" element
And I should see "1234" in the "Password" element
13 changes: 8 additions & 5 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,17 @@ Then(/^the response should not contain "([^"]*)?"$/, function (expectedText) {


/**
* Assert, that element contains a specific text value
* Example: Then I should see "John Smith" in the "#username" element
* Assert, that input text contains a specific value by its label
* Example: Then I should see "John Smith" in the "Username" element
*
*/
Then(/^(I|we)* should see "([^"]*)?" in the "([^"]*)?" element$/, function (pronoundCase, expectedText, element) {
return this.shouldSee = function (browser) {
browser.assert.textContains(element, expectedText);
};
const elementField = browser.element.findByText(element);
browser.getAttribute(elementField, 'for', function (eleAttribute) {
return this.shouldSee = function (browser) {
browser.assert.textContains('#' + eleAttribute.value, expectedText);
};
});
});

/**
Expand Down

0 comments on commit 14dc2f1

Please sign in to comment.