nightwatch-commands icon indicating copy to clipboard operation
nightwatch-commands copied to clipboard

What's the best way to pass arguments to `condition` in the `waitForCondition` command?

Open anatoliyarkhipov opened this issue 6 years ago • 0 comments

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?

https://github.com/mobify/nightwatch-commands/blob/4d3984a7943d59deed832fd48258222071d141d6/commands/waitForCondition.js#L49-L69

anatoliyarkhipov avatar Apr 06 '18 03:04 anatoliyarkhipov