chore: clarify error message when node is not clickable (#6949)
This commit is contained in:
parent
f90af6639d
commit
af2b5fca12
@ -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;
|
||||
|
@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user