From 3f9d2431062c32d2b357543ced3c79feb7ad4394 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sun, 5 Jan 2025 02:00:39 -0500 Subject: [PATCH] [UPD] script selenium: support click and draw into a canvas --- script/selenium/selenium_lib.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/script/selenium/selenium_lib.py b/script/selenium/selenium_lib.py index 7fa7711..7a98bf8 100644 --- a/script/selenium/selenium_lib.py +++ b/script/selenium/selenium_lib.py @@ -195,6 +195,28 @@ class SeleniumLib(object): ) button.click() + def click_canvas_form( + self, + by: str = By.ID, + value: str = None, + timeout: int = 5, + form="carre", + ): + + # ele = self.driver.find_element(by, value) + ele = self.get_element(by, value, timeout) + actions = ActionChains(self.driver) + actions.move_to_element_with_offset(ele, -50, -50) + actions.click_and_hold() + if form == "carre": + actions.move_by_offset(50, 0) + actions.move_by_offset(0, 50) + actions.move_by_offset(-50, 0) + actions.move_by_offset(0, -50) + + actions.release() + actions.perform() + def input_text_with_mouse_move( self, by: str = By.ID, @@ -402,7 +424,7 @@ def fill_parser(parser): "--selenium_default_delay", default=0.4, type=float, - help="Pause at the end before close video.", + help="Pause at the end of an action.", ) group_browser = parser.add_argument_group(title="Browser")