From e15f4f3f85006f507c574ebf110cc504ceb7193d Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Sat, 22 Nov 2025 00:03:02 -0500 Subject: [PATCH] [UPD] selenium: disable enable_tour in same time of dark mode --- script/selenium/selenium_lib.py | 39 +++++++++++++++++++-------------- script/selenium/web_login.py | 4 ++-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/script/selenium/selenium_lib.py b/script/selenium/selenium_lib.py index 04b6bad..16e66c5 100644 --- a/script/selenium/selenium_lib.py +++ b/script/selenium/selenium_lib.py @@ -1231,26 +1231,31 @@ class SeleniumLib(object): print(f"Bouton du statusbar avec le label '{status_label}' cliqué.") return status_button - def odoo_profile_click_dark_mode(self, enable_dark_mode=False): - profile_button = self.click_with_mouse_move( - By.XPATH, - "//div[contains(@class, 'o_user_menu')]/button[contains(@class, 'py-1')]", - ) - select_dark_element = self.get_element( - By.XPATH, - "//div[contains(@class, 'o_popover')]//span[@data-menu=\"color_scheme.switch\"]//input", - ) - if select_dark_element.is_selected() != enable_dark_mode: - dark_mode_button = self.click_with_mouse_move( - By.XPATH, - "//div[contains(@class, 'o_popover')]//span[@data-menu=\"color_scheme.switch\"]//input", - ) - else: - # close it - self.click_with_mouse_move( + def odoo_profile_click(self, enable_dark_mode=False, enable_tour=False): + + def toggle_data_menu(key, enable): + profile_button = self.click_with_mouse_move( By.XPATH, "//div[contains(@class, 'o_user_menu')]/button[contains(@class, 'py-1')]", ) + element = self.get_element( + By.XPATH, + f"//div[contains(@class, 'o_popover')]//span[@data-menu=\"{key}\"]//input", + ) + if element.is_selected() != enable: + self.click_with_mouse_move( + By.XPATH, + f"//div[contains(@class, 'o_popover')]//span[@data-menu=\"{key}\"]//input", + ) + else: + # close it + self.click_with_mouse_move( + By.XPATH, + "//div[contains(@class, 'o_user_menu')]/button[contains(@class, 'py-1')]", + ) + + toggle_data_menu("web_tour.tour_enabled", enable_tour) + toggle_data_menu("color_scheme.switch", enable_dark_mode) def odoo_web_form_click_statusbar_button_status_floating( self, status_label, timeout=10 diff --git a/script/selenium/web_login.py b/script/selenium/web_login.py index ee44f9d..5b595bc 100755 --- a/script/selenium/web_login.py +++ b/script/selenium/web_login.py @@ -164,8 +164,8 @@ def run( # selenium_tool.driver.quit() # Force use dark mode if enable - selenium_tool.odoo_profile_click_dark_mode( - enable_dark_mode=not config.no_dark_mode + selenium_tool.odoo_profile_click( + enable_dark_mode=not config.no_dark_mode, enable_tour=False ) print("End web_login.py")