Skip to content

Commit

Permalink
Add Fill input type text with empty value by its attribute step defin…
Browse files Browse the repository at this point in the history
…ition #145
  • Loading branch information
TasneemNatshah committed Jul 13, 2024
1 parent 2970ddd commit 159fa19
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/step-definitions/webship.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,33 @@ When(/^(I|we)* fill in "([^"]*)?" with:$/, function (pronoundCase, field) {
});
});

/**
* Fill input type text with empty value by its attribute
* Example: When I fill in "uname" with: by attr
* Example: And I fill in "pwordcss" with: by "class" attr
* Example: And I fill in "Your full name" with: by its "placeholder" attribute
*
*/
When(/^(I|we)* fill in "([^"]*)?" with: by( its)*( "([^"]*)?")* (attribute|attr)$/, function (pronoundCase, attrValue , itsCase, attr, attrCase) {

const hasASpace = attrValue.indexOf(' ');
const txtValue = '';
var selector = '';

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 + '"]';
}

return browser.setValue(selector, txtValue);

});

/**
* Fills in form field with specified element
* Example: And I fill in "webshipco" for "username"
Expand Down

0 comments on commit 159fa19

Please sign in to comment.