Skip to content

Commit

Permalink
test: add a missing test for elementHandle. (puppeteer#2580)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanivefraim authored and aslushnikov committed May 21, 2018
1 parent 2d9e5a0 commit b474f2c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/elementhandle.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit b474f2c

Please sign in to comment.