v6 slow to confirm non-existence of elements
See original GitHub issueEnvironment (please complete the following information):
- WebdriverIO version: 6.7.3
- Mode: spectron
- If WDIO Testrunner, running sync/async: [e.g. sync/async]
- Node.js version: 12.14.1
- NPM version: 7.0.3
- Browser name and version: Electron 10 (chrome 85)
- Platform name and version: macOS 10.15.7
- Additional wdio packages used (if applicable): [e.g. @wdio/spec reporter, @wdio/selenium-standalone service]
Config of WebdriverIO Stock spectron configuration
Describe the bug When trying to find a non-existing element, it is either much slower than with v4, or can fail if timeouts are not configured carefully. With v4, this is not a problem.
v4 behavior: when waiting for non-existence, if it does not exist right now, succeed quickly. If it exists, only then do you need to wait for it to not exist. 👍
v6 behavior: if it does not exist right now, webdriverio still waits … to see that it does not exist (??) And if we tried to work around this by setting a short global wait timeout (it has to be global, because $
does not accept a timeout parameter)… then if we want to wait for an existing element to disappear within some time frame… now those tests may fail! 👎
To Reproduce See repo: https://github.com/starpit/webdriverio-6092
Expected behavior webdriverio must support both use cases: 1) confirming an element does not exist, and quickly; 2) waiting for an element that may exist to no longer exist.
I’m not sure what you want by design, but in v4, the pattern client.waitForExist('.classname', timeout, true)
would correctly and quickly succeed for both use cases.
But this seems to be impossible with v6. The API has changed so that one first must find the element (e.g. via $
), and then call waitForExist({ reverse: true })
on the result. The implementation of waitForExist
just calls $$
again. As a result, trying to confirm the non-existence of an element requires paying two wait timeout penalties, one of which does not seem to allow for control at call sites — $
does not take a waitTimeout parameter.
As a result, one has to choose whether to make the first, or the second, use case reliable. By setting a short global wait timeout, the first use case (confirming that an non-existing element truly does not exist) can be… fast enough, but still not as fast as v4, because v6 will still pay a waitTimeout penalty to confirm something it already knows…
On the other hand, by setting a longer global wait timeout, the second use case (waiting for an existing element to go away) will work, but the first use case will not! The first use case will either be very slow (paying two wait timeout penalties to confirm something knowable from the get-to), or fail (e.g. if 2*waitTimeout exceeds the mocha timeout).
Log No pertinent logs for this issue
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (5 by maintainers)
This is only if you have
implicit
timeouts set, which is not recommended at all. Many people say that you should not make use of implicit waits for various reasons, one of them is exactly this scenario.I am not sure what
waitTimeout
in Spectron is doing.You guys are awesome, thanks!