0

How to input between lines of code some force-timeout (like java Thread.Sleep) in NighWatch.js ? Have to wait for element to have exact value after page render.

Michau
  • 59
  • 1
  • 9

2 Answers2

22

I don't think this is the correct answer. For the original poster it's probably too late but other users might google it:

If you use the Nightwatch testing frame work then you can use these commands: http://nightwatchjs.org/api#pause browser.pause(1000); // pauses the test for 1000 milliseconds

or wait for an element to be present:

browser.waitForElementPresent('body', 1000); // waits max. 1000 ms for the element to appear

  • This should be the correct answer in regards to the original question within the context of Nightwatch. Setting a setInterval in your test script will indeed delay the script found within, but won't delay the completion of the given test. Using browser.pause will do what your are looking for. – Prusprus Aug 07 '16 at 14:42
1

You won't be able to stop the thread since javascript is single thread non blocking. What you want to do is this

setInterval(function () {alert("Hello")}, 3000); The syntax is.

window.setInterval("javascript function", milliseconds);

See : http://www.w3schools.com/js/js_timing.asp

BastianBuhrkall
  • 348
  • 1
  • 7
  • 18