I'm using protractor and I'm trying to select a form using it's label.
Let's take an example. I have this form with several input:
<form>
<label for="name">Name</label>
<input type="text" id="name">
<label for="address">Address</label>
<input type="text" id="address">
<label for="email">Email</label>
<input type="text" id="email">
</form>
My step definition should be something like that:
this.When(/^I fill input identified by label "([^"]*)" with value "([^"]*)"$/, function(labelName, value, callback){
...
});
I need to write this step definition because I'm using protractor with cucumber.js, so the person who will run the test should be able to fill a form knowing only the label, without inspect html code to retrieve class, id or other attributes.
I've found this question on github but I would like to know if there is a better method to do this.
Can anyone help me to solve this problem? I don't like to ask code snippets to other developers but I really don't know how to proceed and I can't find documentation about this problem.
IMPORTANT: I'm NOT using Angularjs
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire