test: add a missing test for elementHandle. (#2580)

This commit is contained in:
Yaniv Efraim 2018-05-21 23:08:31 +03:00 committed by Andrey Lushnikov
parent 2d9e5a0d25
commit b474f2ce87

View File

@ -309,6 +309,14 @@ module.exports.addTests = function({testRunner, expect}) {
const content = await elementHandle.$eval('.a', node => node.innerText); const content = await elementHandle.$eval('.a', node => node.innerText);
expect(content).toBe('a-child-div'); expect(content).toBe('a-child-div');
}); });
it('should throw in case of missing selector', async({page, server}) => {
const htmlContent = '<div class="a">not-a-child-div</div><div id="myId"></div>';
await page.setContent(htmlContent);
const elementHandle = await page.$('#myId');
const errorMessage = await elementHandle.$eval('.a', node => node.innerText).catch(error => error.message);
expect(errorMessage).toBe(`Error: failed to find element matching selector ".a"`);
});
}); });
describe('ElementHandle.$$', function() { describe('ElementHandle.$$', function() {