This repository was archived by the owner on Aug 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
What's the best way to pass arguments to condition in the waitForCondition command? #83
Copy link
Copy link
Open
Description
For example, in a condition like this I want to pass the selector argument:
const condition = (selector) => {
return !! $(selector).attr('disabled')
}But it looks like there is no way to do this except of constructing condition as string:
// like this
const condition = `return !! $(${selector}).attr('disabled')`
// or this
const conditionFunc = () => {
return !! $({{SELECTOR}}).attr('disabled')
}
const condition = conditionFunc.toString().replace('{{SELECTOR}}', selector)Not a big deal in the exampe, but there might be really big condition functions where such constructing can really bother.
Wouldn't it be as simple to add support for arguments as to add the extra argument for the execute call here?
nightwatch-commands/commands/waitForCondition.js
Lines 49 to 69 in 4d3984a
| this.protocol.execute.call(this.client, this.condition, function(result) { | |
| var now = new Date().getTime(); | |
| if (result.status === 0 && result.value !== 'undefined') { | |
| setTimeout(function() { | |
| var msg = self.messages.success + (now - self.startTimer) + ' milliseconds.'; | |
| self.cb.call(self.client.api, result.value); | |
| self.client.assertion(true, !!result.value, false, msg, true); | |
| return self.emit('complete'); | |
| }, self.timeout); | |
| } else if (now - self.startTimer < self.ms) { | |
| setTimeout(function() { | |
| self.check(); | |
| }, 500); | |
| } else { | |
| var msg = self.messages.timeout + self.ms + ' milliseconds.'; | |
| self.cb.call(self.client.api, false); | |
| self.client.assertion(false, false, false, msg, true); | |
| return self.emit('complete'); | |
| } | |
| }); |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels