remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/test-browser/commands/waitForElementContainsText.js

25 lines
777 B

5 years ago
const EventEmitter = require('events')
class WaitForElementContainsText extends EventEmitter {
command (id, value) {
let incr = 0
let runid = setInterval(() => {
this.api.getText(id, (result) => {
if (value.indexOf(result.value || '') !== -1) {
clearInterval(runid)
this.api.assert.ok(true, `WaitForElementContainsText ${id} contains ${value}`)
this.emit('complete')
} else incr++
if (incr > 50) {
clearInterval(runid)
this.api.assert.fail(`WaitForElementContainsText - expected ${value} but got ${result.value}`)
// throw new Error(`WaitForElementContainsText ${id} ${value}`)
}
})
}, 200)
return this
}
}
module.exports = WaitForElementContainsText