Skip to content
This repository was archived by the owner on Aug 5, 2020. It is now read-only.

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

@anatoliyarkhipov

Description

@anatoliyarkhipov

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?

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');
}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions