Add modifier options to click_by_index (not recorded yet)

This commit is contained in:
Isaiah Odhner 2023-09-11 19:12:26 -04:00
parent d6399022ee
commit 6c108294b8

View File

@ -279,12 +279,12 @@ async def drag(selector: str, offsets: list[Offset], shift: bool = False, meta:
# steps_code += f"await pilot.click(offset=Offset({offset.x}, {offset.y}) + widget.region.offset)\n" # steps_code += f"await pilot.click(offset=Offset({offset.x}, {offset.y}) + widget.region.offset)\n"
# Strategy: add a class to the widget, and click on that. # Strategy: add a class to the widget, and click on that.
helpers.add(""" helpers.add("""
async def click_by_index(selector: str, index: int) -> None: async def click_by_index(selector: str, index: int, shift: bool = False, meta: bool = False, control: bool = False) -> None:
\"""Click on widget, query disambiguated by index\""" \"""Click on widget, query disambiguated by index\"""
# await pilot.pause(0.5) # await pilot.pause(0.5)
widget = pilot.app.query(selector)[index] widget = pilot.app.query(selector)[index]
widget.add_class('pilot-click-target') widget.add_class('pilot-click-target')
await pilot.click('.pilot-click-target') await pilot.click('.pilot-click-target', shift=shift, meta=meta, control=control)
widget.remove_class('pilot-click-target') widget.remove_class('pilot-click-target')
""") """)