mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
test: add a missing test for elementHandle. (#2580)
This commit is contained in:
parent
2d9e5a0d25
commit
b474f2ce87
@ -309,6 +309,14 @@ module.exports.addTests = function({testRunner, expect}) {
|
||||
const content = await elementHandle.$eval('.a', node => node.innerText);
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user