Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waitForElementNotPresent fails immediately and does not wait #2091

Closed
lloiser opened this issue May 13, 2019 · 2 comments
Closed

waitForElementNotPresent fails immediately and does not wait #2091

lloiser opened this issue May 13, 2019 · 2 comments

Comments

@lloiser
Copy link
Collaborator

lloiser commented May 13, 2019

As part of #2079 a fix was implemented in waitForElementNotPresent which is not correct:
2c05fc1#diff-643e0b67e0938dc01d586a7a29374a9fR40

Here are my tests to highlight the problem:

module.exports = {
  before(client) {
    client
      .url('https://www.google.com/')
  },

  // '#hplogo' exists
  // '#foo' does not exist

  'present - success' (client) {
    client.waitForElementPresent('#hplogo', 5000);
  },
  'not present - success' (client) {
    client.waitForElementNotPresent('#foo', 5000);
  },

  'present - failure' (client) {
    client.waitForElementPresent('#foo', 5000);
  },
  'not present - failure' (client) {
    client.waitForElementNotPresent('#hplogo', 5000);
  },

  after(client) {
    client.end();
  }
};

And here is the output:

[My Test] Test Suite
======================
Running:  present - success

✔ Element <#hplogo> was present after 7 milliseconds.

OK. 1 assertions passed. (10ms)
Running:  not present - success

✔ Element <#foo> was not present after 5 milliseconds.

OK. 1 assertions passed. (7ms)
Running:  present - failure

✖ Timed out while waiting for element <#foo> to be present for 5000 milliseconds. - expected "found" but got: "not found"
    at Object.present - failure (/home/lloiser/projects/nightwatch-testing-repo/test/wait-test.js:18:12)
    at Context.call (/home/lloiser/projects/nightwatch/lib/testsuite/context.js:213:32)
    at TestCase.run (/home/lloiser/projects/nightwatch/lib/testsuite/testcase.js:49:31)
    at Runnable.handleRunnable [as __runFn] (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:349:32)
    at Runnable.run (/home/lloiser/projects/nightwatch/lib/testsuite/runnable.js:123:21)
    at TestSuite.createRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:415:33)
    at TestSuite.handleRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:419:17)
    at createSession.then.then._ (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:348:21)
    at process._tickCallback (internal/process/next_tick.js:68:7) 


FAILED: 1 assertions failed (5.075s)
Running:  not present - failure

✖ Timed out while waiting for element <#hplogo> to be removed for 5000 milliseconds. - expected "not found" but got: "found"
    at Object.not present - failure (/home/lloiser/projects/nightwatch-testing-repo/test/wait-test.js:21:12)
    at Context.call (/home/lloiser/projects/nightwatch/lib/testsuite/context.js:213:32)
    at TestCase.run (/home/lloiser/projects/nightwatch/lib/testsuite/testcase.js:49:31)
    at Runnable.handleRunnable [as __runFn] (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:349:32)
    at Runnable.run (/home/lloiser/projects/nightwatch/lib/testsuite/runnable.js:123:21)
    at TestSuite.createRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:415:33)
    at TestSuite.handleRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:419:17)
    at createSession.then.then._ (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:348:21)
    at process._tickCallback (internal/process/next_tick.js:68:7) 


FAILED: 1 assertions failed (7ms)
_________________________________________________

TEST FAILURE:  2 assertions failed, 2 passed. 8.269s

 ✖ wait-test
 – present - failure (5.075s)
   Timed out while waiting for element <#foo> to be present for 5000 milliseconds. - expected "found" but got: "not found"
       at Object.present - failure (/home/lloiser/projects/nightwatch-testing-repo/test/wait-test.js:18:12)
       at Context.call (/home/lloiser/projects/nightwatch/lib/testsuite/context.js:213:32)
       at TestCase.run (/home/lloiser/projects/nightwatch/lib/testsuite/testcase.js:49:31)
       at Runnable.handleRunnable [as __runFn] (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:349:32)
       at Runnable.run (/home/lloiser/projects/nightwatch/lib/testsuite/runnable.js:123:21)
       at TestSuite.createRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:415:33)
       at TestSuite.handleRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:419:17)
       at createSession.then.then._ (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:348:21)
       at process._tickCallback (internal/process/next_tick.js:68:7)
 – not present - failure (7ms)
   Timed out while waiting for element <#hplogo> to be removed for 5000 milliseconds. - expected "not found" but got: "found"
       at Object.not present - failure (/home/lloiser/projects/nightwatch-testing-repo/test/wait-test.js:21:12)
       at Context.call (/home/lloiser/projects/nightwatch/lib/testsuite/context.js:213:32)
       at TestCase.run (/home/lloiser/projects/nightwatch/lib/testsuite/testcase.js:49:31)
       at Runnable.handleRunnable [as __runFn] (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:349:32)
       at Runnable.run (/home/lloiser/projects/nightwatch/lib/testsuite/runnable.js:123:21)
       at TestSuite.createRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:415:33)
       at TestSuite.handleRunnable (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:419:17)
       at createSession.then.then._ (/home/lloiser/projects/nightwatch/lib/testsuite/testsuite.js:348:21)
       at process._tickCallback (internal/process/next_tick.js:68:7)

The output above can be interpreted as:

  • present - success succeeded after 10ms ✔️
  • not present - success succeeded after 7ms ✔️
  • present - failure failed after 5.075s ✔️
  • not present - failure failed after 7ms ❌
@VasylQA
Copy link

VasylQA commented May 16, 2019

Having described issue in my tests as well after updating to 1.1.8

@beatfactor
Copy link
Member

Fixed in 1.1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants