4

How can we run the same test multiple times in Protractor?

Looks like this has been a problem before, any solution for this?

Kevin
  • 95
  • 3
  • 7
  • What do you mean exactly? Can you give an example – Gunderson Apr 29 '16 at 12:40
  • Under Conf.js I have a Specs: ['test1.js], If I run > protractor conf.js form the Command Prompt my test runs and I can see the result. I like for the Specs:['test1.js] run 100 times and verify the results. – Kevin Apr 29 '16 at 12:53

3 Answers3

3

Solve it on a higher level with bash running protractor from the command line N times:

Or, you can also do it via the grunt task manager, sample can be found here:


There is also protactor-flake package that will automatically rerun failing protractor tests.

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
1

Similar to what @alecxe suggested, I do this in the bash shell to run protractor n times to find tests that fail intermittently:

for ((n=0;n<100;n++)); do protractor protractor.conf.js; done

I use jasmine-spec-reporter, and often add a grep at the end to find only the errors:

for ((n=0;n<10;n++)); do protractor ./protractor/protractor.conf.js; done | grep FAILED

hkong
  • 8,222
  • 1
  • 19
  • 15
-1

Doing a for loop, like in Linux, didn't work for me. What worked for me was this command:

for /l %A in (1, 1, 100) do protractor conf.js %A

/l means we use it for numbers. %A means it's a command line (%%A is used for a batch file)