@christian-bromann/webdriverio
Version:
A nodejs bindings implementation for selenium 2.0/webdriver
30 lines (27 loc) • 815 B
JavaScript
/**
* check if selenium response contains an element result
* @param {object} result response object from the driver
* @return {Boolean} returns
* 0 if response was not an element result
* 1 if response was a element result
* 2 if response was an elements result
*/
function hasElementResult (result) {
/**
* check for element call
*/
if (result && (
(result.value && result.value.ELEMENT) ||
(typeof result.selector === 'string' && result.value === null)
)) {
return 1
}
/**
* check for elements call
*/
if (result && Array.isArray(result.value) && result.value.filter((r) => !r.ELEMENT).length === 0) {
return 2
}
return 0
}
export default hasElementResult