Skip to content

Commit

Permalink
Change assertion that element exists on the current page by its label #…
Browse files Browse the repository at this point in the history
  • Loading branch information
TasneemNatshah committed Jul 25, 2024
1 parent b83d734 commit 7e7c310
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
12 changes: 6 additions & 6 deletions tests/features/test--then--i-should-see-an-element.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Feature: An example to test seeing for a specific element on current page
Feature: An example to test seeing for a specific element on current page by its label
As a user
I want to make sure that when I'm on a particular page, I should see a specific element
I want to make sure that when I'm on a particular page, I should see a specific element by its label

Scenario: Check to test seeing for a specific element
Given I am on "/about-us.html"
Then I should see a "body" element
And I should see a "#paragraphid" element
Scenario: Check to test seeing for a specific element by its label
Given I am on "/test--then--i-should--see-text-in-element.html"
Then I should see a "Username" element
And I should see a "Password" element
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ Feature: An example to test if the element contains a certain expected CSS prope

Scenario: Check element if the element contains a certain expected CSS property
Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
Then I should see a "body" element
When I press "Submit" by attr
Then the "body" element should contain "background-color:white;"

Scenario: Check element if the element not contains a certain CSS property
Given I am on "/test--then--the-element-should_not-contain-cssproperty.html"
Then I should see a "body" element
When I press "Submit" by attr
Then the "#uname" element should not contain "border:solid 5px red;"
20 changes: 7 additions & 13 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,21 +564,15 @@ Then(/^(I|we)* should not see "([^"]*)?" in the "([^"]*)?" element by( its)*( "(
});

/**
* Assert, that element exists on current page
* Example: Then I should see a "body" element
*
*/
Then(/^(I|we)* should see a "([^"]*)?" element$/, function (pronoundCase, element) {
return browser.verify.visible(element);
});

/**
* Assert, that element exists on current page
* Example: Then I should see an "#email" element
* Assert, that element exists on current page by its label
* Example: Then I should see a "Username" element
*
*/
Then(/^(I|we)* should see an "([^"]*)?" element$/, function (pronoundCase, element) {
return browser.verify.visible(element);
Then(/^(I|we)* should see (a|an) "([^"]*)?" element$/, function (pronoundCase, aAnCase, element) {
const elementField = browser.element.findByText(element);
browser.getAttribute(elementField, 'for', function (eleAttribute) {
return browser.verify.visible('#' + eleAttribute.value);
});
});

/**
Expand Down

0 comments on commit 7e7c310

Please sign in to comment.