chore: clarify error message when node is not clickable (#6949)

This commit is contained in:
Paul Adams 2021-09-14 17:38:58 +01:00 committed by GitHub
parent f90af6639d
commit af2b5fca12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -421,7 +421,7 @@ export class ElementHandle<
this._client.send('Page.getLayoutMetrics'),
]);
if (!result || !result.quads.length)
throw new Error('Node is either not visible or not an HTMLElement');
throw new Error('Node is either not clickable or not an HTMLElement');
// Filter out quads that have too small area to click into.
// Fallback to `layoutViewport` in case of using Firefox.
const { clientWidth, clientHeight } =
@ -433,7 +433,7 @@ export class ElementHandle<
)
.filter((quad) => computeQuadArea(quad) > 1);
if (!quads.length)
throw new Error('Node is either not visible or not an HTMLElement');
throw new Error('Node is either not clickable or not an HTMLElement');
// Return the middle point of the first quad.
const quad = quads[0];
let x = 0;

View File

@ -228,7 +228,7 @@ describe('ElementHandle specs', function () {
);
const error = await button.click().catch((error_) => error_);
expect(error.message).toBe(
'Node is either not visible or not an HTMLElement'
'Node is either not clickable or not an HTMLElement'
);
});
it('should throw for recursively hidden nodes', async () => {
@ -242,7 +242,7 @@ describe('ElementHandle specs', function () {
);
const error = await button.click().catch((error_) => error_);
expect(error.message).toBe(
'Node is either not visible or not an HTMLElement'
'Node is either not clickable or not an HTMLElement'
);
});
it('should throw for <br> elements', async () => {
@ -252,7 +252,7 @@ describe('ElementHandle specs', function () {
const br = await page.$('br');
const error = await br.click().catch((error_) => error_);
expect(error.message).toBe(
'Node is either not visible or not an HTMLElement'
'Node is either not clickable or not an HTMLElement'
);
});
});