Skip to content

Commit cdeccfe

Browse files
authored
Fixed chrome puppeteer click by coordinate (#72)
1 parent cdd4cfe commit cdeccfe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

PuppeteerLibrary/puppeteer/async_keywords/puppeteer_element.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ async def _click_with_specific_tag(self, locator: str, expect_tag_name: str):
4141

4242
async def click_element_at_coordinate(self, locator: str, xoffset: str, yoffset: str):
4343
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)
44-
await element.click()
44+
bounding_box = await element.boundingBox()
45+
await self.library_ctx.get_current_page().get_page().mouse.move(
46+
bounding_box['x'] + int(xoffset),
47+
bounding_box['y'] + int(yoffset))
48+
await self.library_ctx.get_current_page().get_page().mouse.down()
49+
await self.library_ctx.get_current_page().get_page().mouse.up()
4550

4651
async def upload_file(self, locator: str, file_path: str):
4752
element = await self.library_ctx.get_current_page().querySelector_with_selenium_locator(locator)

0 commit comments

Comments
 (0)