Skip to content

Commit

Permalink
Add a step definition when I press button by its attribute #140
Browse files Browse the repository at this point in the history
  • Loading branch information
TasneemNatshah committed Jul 12, 2024
1 parent d24cc58 commit 207d0e4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,14 @@ When(/^(I|we)* press "([^"]*)?"$/, function (pronoundCase, element) {
*/
When(/^(I|we)* press "([^"]*)?" by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue, itsCase, attr, attrCase) {

const hasASpace = attrValue.indexOf(' ');

var selector = '';
if (!attr){
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "],[value=" + attrValue + "]";
if (!attr && hasASpace == -1){
selector = attrValue + ',#' + attrValue + ',.' + attrValue + ',[name=' + attrValue + "]," + '[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
}
else if (!attr && hasASpace > -1){
selector ='[value="' + attrValue + '"],[placeholder="' + attrValue + '"]';
}
else {
selector = '[' + attr + '="' + attrValue + '"]';
Expand Down

0 comments on commit 207d0e4

Please sign in to comment.