UNPKG

codeceptjs

Version:

Modern Era Acceptance Testing Framework for NodeJS

19 lines (17 loc) 497 B
const Locator = require('../../locator'); /** * Uses to throw readable element not found error * Stringify object's locators */ class ElementNotFound { constructor( locator, prefixMessage = 'Element', postfixMessage = 'was not found by text|CSS|XPath', ) { if (typeof locator === 'object') { locator = JSON.stringify(locator); } throw new Error(`${prefixMessage} "${(new Locator(locator)).toString()}" ${postfixMessage}`); } } module.exports = ElementNotFound;