am I the only one wondering, how to make the acceptance tests more stable??
Strange things are happening - on my local development machine and also on CircleCi:
-
browser.waitForExist()
&&browser.waitForVisible()
act really unstable. The give false negatives, telling me that an element is NOT visible/existing, but it is. -
browser.setValue
is really unstable and likes to mess up keys, p.e. inserts ‘„est Question?T”’ instead of ‘„Test Question?”’ - modal-windows do NOT open, if the browser does NOT have focus (or for whatever reason - this also happens on CI)
- … and so on…
I am starting to really really hate it, because trying to fix things is soo time-intense and I still did NOT have any successfull-build on CircleCi There are always tests failing.
Are there some tricks that I am missing?
Anyone out there to share some tears?
For beginners, I started wrapping webdriver functionality into a wrapper, p.e. this guy here helps from time to time:
/**
* More stable version of waitForVisible.
*/
waitForVisible(element) {
Stabilize.waitForExist(element)
Logger.log(`waiting for element to be visible "${element}"`)
const isVisible = Stabilize.isVisible(element)
if (!isVisible) {
Logger.log('element exists, but is NOT visible. Let`s scroll to it', 1)
browser.scroll(element)
}
Logger.log('waiting for element to be visible', 1)
try {
browser.waitForVisible(element)
} catch (e) {
// I don't know why, but it really happens, that right NOW the element
// IS visible. So there seems to be a bug in webdriver.
// Use try-catch as a workaround and do NOT throw
browser.isExisting(element) // KEEP it - it might force the modal to show
if (!browser.isVisible(element)) {
Logger.log('element is NOT visible after timeout! This is some data for debug', 1)
console.log('browser.isExisting(element)', browser.isExisting(element))
console.log('browser.isVisible(element)', browser.isVisible(element))
throw e
} else {
Logger.log('we just faked webdriver.waitForVisible! The element IS visible(!!)', 1)
}
}
Logger.log(`element is finally visible: ${element}`, 1)
}