简体   繁体   中英

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

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"?

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}});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM