Skip to content

Commit

Permalink
Change the command of select the option in the dropdown list field to…
Browse files Browse the repository at this point in the history
… be by its text label #164
  • Loading branch information
TasneemNatshah committed Aug 12, 2024
1 parent 38e12b4 commit a125a0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Feature: An example to select option from drop down list
Feature: An example to select the option in the dropdown list field by its text label

As a tester
I want to be able to test select option from drop down list
I want to be able to test select option from dropdown list by its text label

Scenario: Check of selecting option from drop down list
Scenario: Check of selecting option from dropdown list by its text label
Given I am on "/test--when--i-select-option-from-dropdownlist.html"
When I select "Saab" from "cars"
When I select "Saab" from "Choose a car:"
When I press "Submit" by attr
Then I should see "Option ( Saab ) has been selected successfully"
10 changes: 8 additions & 2 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,13 +404,19 @@ When(/^(I|we)* fill in the following: by( its)*( "([^"]*)?")* (attribute|attr)$/
});

/**
* Selects option in select field
* Selecting the option in the dropdown list field by its text label
* Example: When I select "Mercedes" from "Cars"
*
*/
When(/^(I|we)* select "([^"]*)?" from "([^"]*)?"$/, function (pronoundCase, option, dropdownlist) {

browser.selectOption(option, dropdownlist);
const elementField = browser.element.findByText(dropdownlist);
browser.getAttribute(elementField, 'for', function (eleAttribute) {
return browser.waitForElementVisible('css selector', '#' + eleAttribute.value)
.click('#' + eleAttribute.value)
.click(browser.element.findByText(option))
.click('#' + eleAttribute.value);
});
});

/**
Expand Down

0 comments on commit a125a0f

Please sign in to comment.