Nightwatch "TimeoutError ... element was not found" in CI
Nightwatch commands like waitForElementVisible poll for an element up to a configured timeout. In CI a slower render means the element is not present in time, so Nightwatch raises a TimeoutError that reads "element was not found".
What this error means
A test fails with "TimeoutError: An error occurred while running .waitForElementVisible command: timed out while waiting for element <selector> to be present for N milliseconds."
TimeoutError: An error occurred while running .waitForElementVisible command:
timed out while waiting for element <#dashboard> to be present for 5000 milliseconds.Common causes
The element rendered slower than the timeout
A contended CI runner or a slow backend pushed the element past the default wait, so it was not present yet.
A selector that never matches
The selector is wrong or the element is inside a frame, so no poll ever finds it and it always times out.
How to fix it
Raise the wait timeout for CI
- Increase globals.waitForConditionTimeout or pass a per-command timeout.
- Confirm the selector matches the rendered DOM.
- Re-run so the element is found within the larger budget.
// nightwatch.conf.js
module.exports = { test_settings: { default: { globals: { waitForConditionTimeout: 15000 } } } };Fix the selector or switch frames
If the element is in an iframe, enter the frame before asserting; if the selector is wrong, correct it so the poll can match.
browser.frame('payment-iframe')
.waitForElementVisible('#submit', 10000);How to prevent it
- Set waitForConditionTimeout higher in CI than locally.
- Verify selectors against the actual rendered markup.
- Enter frames before asserting on elements inside them.