2

my team and me are using Nightwatch to write end-to-end-acceptance tests for a microservice oriented architecture with a total of five systems. After putting in some work to set it up and wiring together our services with docker-compose, it works great now and all tests are clicked through on the UI in a browser (not headless).

We got the idea to use this for demos, too (initial sprint demo etc) and wondered if there is some kind of setting (which we didn't found until now) or other possibility to simple add some artificial delay between the clicks/tests/assertions and everything.

Does someone have an idea?

jpietzsch
  • 536
  • 5
  • 18

2 Answers2

1

You can add pauses in your suite wherever you want by using:

.pause(5000) // a pause for 5 seconds
//or alternately
.pause(this.timeout)

this.timeout can be set in your base-test-case.js

var timeout = 5000; // in your variable declarations

and then in that same file, on your base Class prototype you want:

  before: function (client) {
    this.timeout = timeout;
QualiT
  • 1,934
  • 2
  • 18
  • 37
  • 1
    So if I have multiple assertions I have to put a `.pause()` before **every** assertion? That's a little bit ugly. From Selenium IDE I know there is a slider which automatically waits a specific amount of time before executing the next command. So there is no equivalent in nightwatch? (such as a global `.setSpeed()` command at the beginning) – Munchkin May 19 '17 at 07:28
  • No, you *don't need* to put pause before every assertion. In most cases you won't need to at all, but let's say you are waiting for some item to be added to the DOM or for the page to load, you could use .waitForElementPresent(selector, timeout) there is no setSpeed() equivalent because none is needed. It's not intended as a demo tool, though I have seen it used that way. If you want to use it as a demo, though, you might want to use .pause(timeout) for any part of the app you want to slow down. – QualiT May 19 '17 at 14:27
  • 1
    Putting a test runner into a "slow mode" either for demos or for tricky pages (eg controls that use transitions) is an old-feature and a must have. Littering your code with pauses or waits is what makes e2e tests brittle, slow, and awful to maintain. Capybara continues to set the standard of how good e2e testing can be. – gap Apr 15 '21 at 16:27
0

browser.pause between clicks or setValue to have nice delay, anything between 100-300 miliseconds is good

http://nightwatchjs.org/api#pause

Terry
  • 1,470
  • 13
  • 15