Skip to content

Commit

Permalink
Add a step definition when I click link by the attribute name #141
Browse files Browse the repository at this point in the history
  • Loading branch information
TasneemNatshah committed Jul 12, 2024
1 parent 207d0e4 commit 0266fdc
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 @@ -157,9 +157,14 @@ When(/^(I|we)* click "([^"]*)?"$/, function (pronoundCase, item) {
*/
When(/^(I|we)* click "([^"]*)?" 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 0266fdc

Please sign in to comment.