node.js - Terminating each() block in Protractor -
I was automating an application (using protractor) and I came in a situation where I I want to select the keyboard to move forward using the arrow buttons below. Here's how I am coming for this kind of action.
- After typing part in the text field, I am getting a reference to every option that appears in the next type.
- Now, I am using Protractor's .each () method to repeat through each option.
- I repeat the script to hit the down arrow button through each option. Write forward that say 10 options appear in the next type and the option I choose is the 5th place Is on. Now when I reach the 5th position I am opting for the option, but each () function still continues.
I should end the loop when something like the statement is required for some loop when the required option is selected.
BTW I have tried to do the above scenario with the loop, but then (unable to use the statement BREAK) inside the handler.
Please tell me how to cope with this situation.
You can throw an exception to the end of the loop, keep it in the loop and use the hold So that your results can be tilted. You can also use the Boolean variables to indicate that you've had a match and ignore everything after that point, though I use only one loop, though.
EDIT: You can add a variable to catch an action before all the benchmarks.
var action
then inside the test
if (choose from data value == option) {action = Function () {benchmark.click ();
Action call after loop exit
if (verb) verb ()
Comments
Post a Comment