Added tests to terminal.js and created journalChildIncludes command to check if any child element of journal (console) contains a value.
parent
fc2f947c42
commit
4bb44b8d04
@ -0,0 +1,30 @@ |
||||
const EventEmitter = require('events') |
||||
|
||||
/* |
||||
Checks if any child elements of journal (console) contains a value. |
||||
*/ |
||||
class JournalChildIncludes extends EventEmitter { |
||||
command (val) { |
||||
let isTextFound = false |
||||
const browser = this.api |
||||
|
||||
this.api.elements('css selector', '#journal', (res) => { |
||||
res.value.forEach(function (jsonWebElement) { |
||||
const jsonWebElementId = jsonWebElement.ELEMENT |
||||
|
||||
browser.elementIdText(jsonWebElementId, (jsonElement) => { |
||||
const text = jsonElement.value |
||||
|
||||
if (text.indexOf(val) !== -1) isTextFound = true |
||||
}) |
||||
}) |
||||
}) |
||||
browser.perform(() => { |
||||
browser.assert.ok(isTextFound, isTextFound ? `<#journal> contains ${val}.` : `${val} not found in <#journal > div:last-child>`) |
||||
this.emit('complete') |
||||
}) |
||||
return this |
||||
} |
||||
} |
||||
|
||||
module.exports = JournalChildIncludes |
Loading…
Reference in new issue