Can I use await page.click(element) to click on a very specific part of that element using playwright

5.2k Views Asked by At

I use the following line to click on an element using playwright

 await page.click(text);

The element in question is the word "Test". When clicked, the caret position appears between the "e" and "s" in test - in other words right in the centre for the element.

How can I get it to click at the start of this element - just before the letter "T"?

1

There are 1 best solutions below

0
On BEST ANSWER

page.click accepts a position option that can be used to specify the point to click, relative to the top-left corner of the element. API docs.

await page.click(text, {position: {x: 5, y: 5}});