diff --git a/lib/helper/WebDriver.js b/lib/helper/WebDriver.js index 11de3779c..6e195ca72 100644 --- a/lib/helper/WebDriver.js +++ b/lib/helper/WebDriver.js @@ -2156,7 +2156,12 @@ async function proceedSeeField(assertType, field, value) { } }; - const proceedSingle = el => this.browser.getElementAttribute(getElementId(el), 'value').then(res => stringIncludes(`fields by ${field}`)[assertType](value, res)); + const proceedSingle = el => this.browser.getElementAttribute(getElementId(el), 'value').then((res) => { + if (res === null) { + throw new Error(`Element ${el.selector} has no value attribute`); + } + stringIncludes(`fields by ${field}`)[assertType](value, res); + }); const filterBySelected = async elements => filterAsync(elements, async el => this.browser.isElementSelected(getElementId(el))); diff --git a/test/helper/WebDriver_test.js b/test/helper/WebDriver_test.js index 656cf29df..3de9de8cd 100644 --- a/test/helper/WebDriver_test.js +++ b/test/helper/WebDriver_test.js @@ -144,6 +144,12 @@ describe('WebDriver', function () { yield wd.dontSeeInField('select2', 'not seen three'); return wd.seeInField('select2', 'see test three'); }); + + it('should return error when element has no value attribute', () => wd.amOnPage('https://codecept.io/quickstart') + .then(() => wd.seeInField('#search_input_react', 'WebDriver1') + .catch((e) => { + e.should.be.instanceOf(Error); + }))); }); describe('#pressKey', () => {