parent
2c6f07b7ba
commit
7ea52cb35c
@ -0,0 +1,28 @@ |
||||
import { NightwatchBrowser } from 'nightwatch' |
||||
import EventEmitter from 'events' |
||||
|
||||
class WaitForElementNotContainsText extends EventEmitter { |
||||
command (this: NightwatchBrowser, id: string, value: string, timeout = 10000): NightwatchBrowser { |
||||
let waitId // eslint-disable-line
|
||||
let currentValue |
||||
const runid = setInterval(() => { |
||||
this.api.getText(id, (result) => { |
||||
currentValue = result.value |
||||
if (typeof result.value === 'string' && result.value.indexOf(value) !== -1) { |
||||
clearInterval(runid) |
||||
clearTimeout(waitId) |
||||
this.api.assert.ok(false, `WaitForElementContainsText ${id} contains ${value} . It should not`) |
||||
this.emit('complete') |
||||
} |
||||
}) |
||||
}, 200) |
||||
|
||||
waitId = setTimeout(() => { |
||||
clearInterval(runid) |
||||
this.api.assert.fail(`TimeoutError: An error occurred while running .waitForElementContainsText() command on ${id} after ${timeout} milliseconds. expected: ${value} - got: ${currentValue}`) |
||||
}, timeout) |
||||
return this |
||||
} |
||||
} |
||||
|
||||
module.exports = WaitForElementNotContainsText |
Loading…
Reference in new issue