I'm testing an app with Protractor; I want to simulate a click on a button 5 times but I don't want to write the same code x5. how can I do it?
element(by.css('button.click')).click();
I'm testing an app with Protractor; I want to simulate a click on a button 5 times but I don't want to write the same code x5. how can I do it?
element(by.css('button.click')).click();
 
    
    Loops offer a quick and easy way to do something repeatedly.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration
If you're looking for Protractor with loops:
I think you should read documentation ... this is a basic
for (i = 0; i < 5; i++) { 
    element(by.css('button.click')).click();
}
 
    
    Alternatively, you can also do it with browser.actions() chaining the click actions:
var link = element(by.css('button.click'));
actions = browser.actions();
for (i = 0; i < 5; i++) {
    actions = actions.click(link);
}
actions.perform();
As a side note, you can replace element(by.css('button.click')) with $('button.click') - protractor supports $ and $$ for CSS locators.
