Last active
June 16, 2023 21:12
-
-
Save deterralba/5862ec98613dbf073545a7d7e87a637d to your computer and use it in GitHub Desktop.
Custom nightwatch command waitForElementClickable() - tested with nightwatch 1.1.13 - inspired by https://gist.github.com/JamesBoon/dc19bc202673e19baf4b9b85d78df27f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Much simpler version (this history for the previous ones), suggested by @beatfactor | |
// More info https://github.com/nightwatchjs/nightwatch/issues/705 | |
module.exports.command = function(selector, timeout=5000) { | |
this.expect.element(selector).enabled.before(timeout); | |
this.perform(() => { | |
// eslint-disable-next-line no-console | |
console.log(`🖱️ Element clickable: <${selector}>`); | |
}); | |
return this; | |
}; |
use nightwatch's logger
const { Logger, symbols } = require('nightwatch/lib/utils');
const { colors } = Logger
module.exports.command = function (selector, timeout=5000) {
const start = Date.now()
this.expect.element(selector).enabled.before(timeout)
this.perform(() => {
const message = `Element <${selector}> was present after ${Date.now() - start} milliseconds.`
Logger.logDetailedMessage(` ${colors.green(symbols.ok)} ${message}`);
});
return this
};
It may be better to use this.globals.waitForConditionTimeout
for the default timeout.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI: broken by nightwatch 1.1New gist version: now working with 1.1.11