From ed96b2ad011cbf6e1b57cf5c8918d4a7631a7d5b Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 4 Jan 2024 23:50:42 -0500 Subject: [PATCH 1/8] [UPD] script selenium: implement configuration and merge script --- script/selenium/web_login.py | 306 ++++++++++++++++-- script/selenium/web_login_open_me_devops.py | 169 ---------- .../selenium/web_login_open_me_devops_auto.py | 171 ---------- .../web_login_open_me_devops_auto_force.py | 171 ---------- 4 files changed, 273 insertions(+), 544 deletions(-) delete mode 100755 script/selenium/web_login_open_me_devops.py delete mode 100755 script/selenium/web_login_open_me_devops_auto.py delete mode 100755 script/selenium/web_login_open_me_devops_auto_force.py diff --git a/script/selenium/web_login.py b/script/selenium/web_login.py index f5d2ba6..9afc7e8 100755 --- a/script/selenium/web_login.py +++ b/script/selenium/web_login.py @@ -1,44 +1,284 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import argparse +import os +import sys + from selenium import webdriver from selenium.webdriver.common.by import By +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.support.ui import WebDriverWait -# Configuration pour lancer Firefox en mode de navigation privée -firefox_options = webdriver.FirefoxOptions() -firefox_options.add_argument("--private") -# Définissez la préférence pour les notifications de bureau -# 1 signifie "autoriser", 2 signifie "bloquer" -firefox_options.set_preference("permissions.default.desktop-notification", 1) - -# Créez une instance du navigateur Firefox avec les options de navigation privée -driver = webdriver.Firefox(options=firefox_options) - -# Ouvrez la page web -driver.get("http://127.0.0.1:8069/web") - -# Trouvez les éléments du formulaire -courriel_input = driver.find_element(By.NAME, "login") -mot_de_passe_input = driver.find_element(By.NAME, "password") -try: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/div/div/form/div[3]/button" - # '//button[contains(text(), "Log in")]' +def get_config(): + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description="""Selenium script to open web browser to ERPLibre.""", + epilog="""\ +""", ) -except Exception: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/main/div/form/div[3]/button" - # '//button[contains(text(), "Connexion")]' + parser.add_argument( + "--open_me_devops", + action="store_true", + help="Open application devops and show entry me.", + ) + parser.add_argument( + "--open_me_devops_auto", + action="store_true", + help="Open application devops and show entry me and run auto setup.", + ) + parser.add_argument( + "--open_me_devops_auto_force", + action="store_true", + help=( + "Open application devops and show entry me and run auto setup with" + " forcing argument." + ), + ) + parser.add_argument( + "--not_private_mode", + action="store_true", + help="Default is private mode.", + ) + parser.add_argument( + "--record_mode", + action="store_true", + help="Start recording (not finish to be implemented).", + ) + parser.add_argument( + "--not_dark_mode", + action="store_true", + help=( + "By default, will be in dark mode, because the main developer" + " like it!" + ), + ) + parser.add_argument( + "--url", + default="http://127.0.0.1:8069", + help="URL to open.", + ) + args = parser.parse_args() + if args.open_me_devops_auto_force: + args.open_me_devops_auto = True + args.open_me_devops = True + elif args.open_me_devops_auto: + args.open_me_devops = True + return args + + +def click(driver, xpath, time=5): + wait = WebDriverWait(driver, time) + button = wait.until( + EC.element_to_be_clickable( + ( + By.XPATH, + xpath, + ) + ) + ) + button.click() + + +def run(config): + if config.record_mode: + new_path = os.path.normpath( + os.path.join(os.path.dirname(__file__), "..", "..") + ) + sys.path.append(new_path) + from script.selenium.selenium_video import VideoRecorder + + # Configuration pour lancer Firefox en mode de navigation privée + firefox_options = webdriver.FirefoxOptions() + if not config.not_private_mode: + firefox_options.add_argument("--private") + + # Définissez la préférence pour les notifications de bureau + # 1 signifie "autoriser", 2 signifie "bloquer" + firefox_options.set_preference( + "permissions.default.desktop-notification", 1 ) -# Remplissez le courriel et le mot de passe -courriel_input.send_keys("admin") -mot_de_passe_input.send_keys("admin") + # Créez une instance du navigateur Firefox avec les options de navigation privée + driver = webdriver.Firefox(options=firefox_options) -# Cliquez sur le bouton "Connexion" -connexion_button.click() + # Ajout de l'enregistrement + if config.record_mode: + video_recorder = VideoRecorder(driver) + else: + video_recorder = None -# Fermez le navigateur -# driver.quit() + # Install DarkReader to help my eyes + # TODO do a script to check if it's the last version + if not config.not_dark_mode: + driver.install_addon( + "./script/selenium/darkreader-firefox.xpi", temporary=True + ) + driver.install_addon( + "./script/selenium/odoo_debug-4.0.xpi", temporary=True + ) + + if not config.not_private_mode and not config.not_dark_mode: + driver.get("about:addons") + # Enable Dark Reader into incognito + click(driver, "/html/body/div/div[1]/categories-box/button[2]") + click( + driver, + "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/div/div/div/button", + ) + click( + driver, + "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/addon-options/panel-list/panel-item[5]", + ) + click( + driver, + "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", + ) + + # Enable Odoo_debug into incognito + # Back + click( + driver, "/html/body/div/div[2]/addon-page-header/div/div[2]/button" + ) + click( + driver, + "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/div/div/div/button", + ) + click( + driver, + "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/addon-options/panel-list/panel-item[5]", + ) + click( + driver, + "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", + ) + + # Ouvrez la page web + driver.get(f"{config.url}/web") + + # Close tab opening by DarkReader + if config.not_private_mode and not config.not_dark_mode: + driver.switch_to.window(driver.window_handles[-1]) + driver.close() + driver.switch_to.window(driver.window_handles[0]) + + # Démarrer l'enregistrement + if config.record_mode: + video_recorder.start() + + # Trouvez les éléments du formulaire + courriel_input = driver.find_element(By.NAME, "login") + mot_de_passe_input = driver.find_element(By.NAME, "password") + try: + connexion_button = driver.find_element( + By.XPATH, + "/html/body/div/div/div/form/div[3]/button" + # '//button[contains(text(), "Log in")]' + ) + except Exception: + connexion_button = driver.find_element( + By.XPATH, + "/html/body/div/main/div/form/div[3]/button" + # '//button[contains(text(), "Connexion")]' + ) + + # Remplissez le courriel et le mot de passe + courriel_input.send_keys("admin") + mot_de_passe_input.send_keys("admin") + + # Cliquez sur le bouton "Connexion" + connexion_button.click() + + # Attendez que l'élément soit cliquable + wait = WebDriverWait(driver, 5) + # menu_toggle = wait.until( + # EC.element_to_be_clickable((By.XPATH, "/html/body/header/nav/ul[1]/li/a")) + # ) + # + # # Cliquez sur l'élément + # menu_toggle.click() + # + # # Attendez que le lien soit cliquable + # menu_item = wait.until( + # EC.element_to_be_clickable( + # ( + # By.XPATH, + # "/html/body/header/nav/ul[1]/li/div/a[2]", + # ) + # ) + # ) + + # Open View + if config.open_me_devops: + click( + driver, + "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a", + ) + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]", + ) + if config.open_me_devops_auto: + click( + driver, + "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a", + ) + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]", + ) + + # CG self + # Bouton modifier + click( + driver, + "/html/body/div[1]/main/div[1]/div[2]/div/div/div[1]/button[1]", + ) + # Tab CG + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[3]/a", + ) + if config.open_me_devops_auto_force: + # Disable «Stop Execution if Env Not Clean + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[2]/tbody/tr/td[1]/label", + ) + # Gen + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[1]/tbody/tr[2]/td[1]/button", + ) + + # Check error + click( + driver, + "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[14]/a", + ) + # click(driver, "/html/body/div[1]/main/div[2]/div/div/div[6]/div/div[14]/div/div[2]/table/tbody/tr[1]", time=60*2) + + # Arrêter l'enregistrement + if config.record_mode: + video_recorder.stop() + + # Open conversation chat + # conversation_button = driver.find_element(By.XPATH, '/html/body/header/nav/ul[3]/li[2]/a') + # conversation_button.click() + + # Close bot chat + # conversation_button = driver.find_element(By.XPATH, '/html/body/div[3]/div[1]/span[2]/a[2]') + # conversation_button.click() + + # Fermez le navigateur + # driver.quit() + + +def main(): + config = get_config() + run(config) + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/script/selenium/web_login_open_me_devops.py b/script/selenium/web_login_open_me_devops.py deleted file mode 100755 index 3c9b6e8..0000000 --- a/script/selenium/web_login_open_me_devops.py +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import os -import sys - -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait - -private_mode = True -record_mode = False -dark_reader_mode = True - - -def click(driver, xpath, time=5): - wait = WebDriverWait(driver, time) - button = wait.until( - EC.element_to_be_clickable( - ( - By.XPATH, - xpath, - ) - ) - ) - button.click() - - -if record_mode: - new_path = os.path.normpath( - os.path.join(os.path.dirname(__file__), "..", "..") - ) - sys.path.append(new_path) - from script.selenium.selenium_video import VideoRecorder - -# Configuration pour lancer Firefox en mode de navigation privée -firefox_options = webdriver.FirefoxOptions() -if private_mode: - firefox_options.add_argument("--private") - -# Définissez la préférence pour les notifications de bureau -# 1 signifie "autoriser", 2 signifie "bloquer" -firefox_options.set_preference("permissions.default.desktop-notification", 1) - -# Créez une instance du navigateur Firefox avec les options de navigation privée -driver = webdriver.Firefox(options=firefox_options) - -# Ajout de l'enregistrement -if record_mode: - video_recorder = VideoRecorder(driver) -else: - video_recorder = None - -# Install DarkReader to help my eyes -# TODO do a script to check if it's the last version -if dark_reader_mode: - driver.install_addon( - "./script/selenium/darkreader-firefox.xpi", temporary=True - ) - driver.install_addon( - "./script/selenium/odoo_debug-4.0.xpi", temporary=True - ) - -if private_mode and dark_reader_mode: - driver.get("about:addons") - # Enable Dark Reader into incognito - click(driver, "/html/body/div/div[1]/categories-box/button[2]") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - - # Enable Odoo_debug into incognito - # Back - click(driver, "/html/body/div/div[2]/addon-page-header/div/div[2]/button") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - -# Ouvrez la page web -driver.get("http://127.0.0.1:8069/web") - -# Close tab opening by DarkReader -if not private_mode and dark_reader_mode: - driver.switch_to.window(driver.window_handles[-1]) - driver.close() - driver.switch_to.window(driver.window_handles[0]) - -# Démarrer l'enregistrement -if record_mode: - video_recorder.start() - -# Trouvez les éléments du formulaire -courriel_input = driver.find_element(By.NAME, "login") -mot_de_passe_input = driver.find_element(By.NAME, "password") -try: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/div/div/form/div[3]/button" - # '//button[contains(text(), "Log in")]' - ) -except Exception: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/main/div/form/div[3]/button" - # '//button[contains(text(), "Connexion")]' - ) - -# Remplissez le courriel et le mot de passe -courriel_input.send_keys("admin") -mot_de_passe_input.send_keys("admin") - -# Cliquez sur le bouton "Connexion" -connexion_button.click() - -# Attendez que l'élément soit cliquable -wait = WebDriverWait(driver, 5) -# menu_toggle = wait.until( -# EC.element_to_be_clickable((By.XPATH, "/html/body/header/nav/ul[1]/li/a")) -# ) -# -# # Cliquez sur l'élément -# menu_toggle.click() -# -# # Attendez que le lien soit cliquable -# menu_item = wait.until( -# EC.element_to_be_clickable( -# ( -# By.XPATH, -# "/html/body/header/nav/ul[1]/li/div/a[2]", -# ) -# ) -# ) - -# Open View -click(driver, "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a") -click(driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]") - -# Arrêter l'enregistrement -if record_mode: - video_recorder.stop() - -# Open conversation chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/header/nav/ul[3]/li[2]/a') -# conversation_button.click() - -# Close bot chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/div[3]/div[1]/span[2]/a[2]') -# conversation_button.click() - -# Fermez le navigateur -# driver.quit() diff --git a/script/selenium/web_login_open_me_devops_auto.py b/script/selenium/web_login_open_me_devops_auto.py deleted file mode 100755 index 23bcf6f..0000000 --- a/script/selenium/web_login_open_me_devops_auto.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import os -import sys - -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait - -private_mode = True -record_mode = False -dark_reader_mode = True - - -def click(driver, xpath, time=5): - wait = WebDriverWait(driver, time) - button = wait.until( - EC.element_to_be_clickable( - ( - By.XPATH, - xpath, - ) - ) - ) - button.click() - - -if record_mode: - new_path = os.path.normpath( - os.path.join(os.path.dirname(__file__), "..", "..") - ) - sys.path.append(new_path) - from script.selenium.selenium_video import VideoRecorder - -# Configuration pour lancer Firefox en mode de navigation privée -firefox_options = webdriver.FirefoxOptions() -if private_mode: - firefox_options.add_argument("--private") - -# Définissez la préférence pour les notifications de bureau -# 1 signifie "autoriser", 2 signifie "bloquer" -firefox_options.set_preference("permissions.default.desktop-notification", 1) - -# Créez une instance du navigateur Firefox avec les options de navigation privée -driver = webdriver.Firefox(options=firefox_options) - -# Ajout de l'enregistrement -if record_mode: - video_recorder = VideoRecorder(driver) -else: - video_recorder = None - -# Install DarkReader to help my eyes -# TODO do a script to check if it's the last version -if dark_reader_mode: - driver.install_addon( - "./script/selenium/darkreader-firefox.xpi", temporary=True - ) - driver.install_addon( - "./script/selenium/odoo_debug-4.0.xpi", temporary=True - ) - -if private_mode and dark_reader_mode: - driver.get("about:addons") - click(driver, "/html/body/div/div[1]/categories-box/button[2]") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - - # Enable Odoo_debug into incognito - # Back - click(driver, "/html/body/div/div[2]/addon-page-header/div/div[2]/button") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - -# Ouvrez la page web -driver.get("http://127.0.0.1:8069/web") - -# Close tab opening by DarkReader -if not private_mode and dark_reader_mode: - driver.switch_to.window(driver.window_handles[-1]) - driver.close() - driver.switch_to.window(driver.window_handles[0]) - -# Démarrer l'enregistrement -if record_mode: - video_recorder.start() - -# Trouvez les éléments du formulaire -courriel_input = driver.find_element(By.NAME, "login") -mot_de_passe_input = driver.find_element(By.NAME, "password") -try: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/div/div/form/div[3]/button" - # '//button[contains(text(), "Log in")]' - ) -except Exception: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/main/div/form/div[3]/button" - # '//button[contains(text(), "Connexion")]' - ) - -# Remplissez le courriel et le mot de passe -courriel_input.send_keys("admin") -mot_de_passe_input.send_keys("admin") - -# Cliquez sur le bouton "Connexion" -connexion_button.click() - -# Open View -click(driver, "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a") -click(driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]") -click(driver, "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a") -click(driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]") - -# CG self -# Bouton modifier -click(driver, "/html/body/div[1]/main/div[1]/div[2]/div/div/div[1]/button[1]") -# Tab CG -click(driver, "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[3]/a") -# Disable «Stop Execution if Env Not Clean -# click( -# driver, -# "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[2]/tbody/tr/td[1]/label", -# ) -# Gen -click( - driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[1]/tbody/tr[2]/td[1]/button", -) - -# Check error -click(driver, "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[14]/a") -# click(driver, "/html/body/div[1]/main/div[2]/div/div/div[6]/div/div[14]/div/div[2]/table/tbody/tr[1]", time=60*2) - -# Arrêter l'enregistrement -if record_mode: - video_recorder.stop() - -# Open conversation chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/header/nav/ul[3]/li[2]/a') -# conversation_button.click() - -# Close bot chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/div[3]/div[1]/span[2]/a[2]') -# conversation_button.click() - -# Fermez le navigateur -# driver.quit() diff --git a/script/selenium/web_login_open_me_devops_auto_force.py b/script/selenium/web_login_open_me_devops_auto_force.py deleted file mode 100755 index 8dbb7cd..0000000 --- a/script/selenium/web_login_open_me_devops_auto_force.py +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -import os -import sys - -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support import expected_conditions as EC -from selenium.webdriver.support.ui import WebDriverWait - -private_mode = True -record_mode = False -dark_reader_mode = True - - -def click(driver, xpath, time=5): - wait = WebDriverWait(driver, time) - button = wait.until( - EC.element_to_be_clickable( - ( - By.XPATH, - xpath, - ) - ) - ) - button.click() - - -if record_mode: - new_path = os.path.normpath( - os.path.join(os.path.dirname(__file__), "..", "..") - ) - sys.path.append(new_path) - from script.selenium.selenium_video import VideoRecorder - -# Configuration pour lancer Firefox en mode de navigation privée -firefox_options = webdriver.FirefoxOptions() -if private_mode: - firefox_options.add_argument("--private") - -# Définissez la préférence pour les notifications de bureau -# 1 signifie "autoriser", 2 signifie "bloquer" -firefox_options.set_preference("permissions.default.desktop-notification", 1) - -# Créez une instance du navigateur Firefox avec les options de navigation privée -driver = webdriver.Firefox(options=firefox_options) - -# Ajout de l'enregistrement -if record_mode: - video_recorder = VideoRecorder(driver) -else: - video_recorder = None - -# Install DarkReader to help my eyes -# TODO do a script to check if it's the last version -if dark_reader_mode: - driver.install_addon( - "./script/selenium/darkreader-firefox.xpi", temporary=True - ) - driver.install_addon( - "./script/selenium/odoo_debug-4.0.xpi", temporary=True - ) - -if private_mode and dark_reader_mode: - driver.get("about:addons") - click(driver, "/html/body/div/div[1]/categories-box/button[2]") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - - # Enable Odoo_debug into incognito - # Back - click(driver, "/html/body/div/div[2]/addon-page-header/div/div[2]/button") - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/div/div/div/button", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-list/section[1]/addon-card[2]/div/addon-options/panel-list/panel-item[5]", - ) - click( - driver, - "/html/body/div/div[2]/div/addon-card/div/addon-details/named-deck/section/div[5]/div/label[1]/input", - ) - -# Ouvrez la page web -driver.get("http://127.0.0.1:8069/web") - -# Close tab opening by DarkReader -if not private_mode and dark_reader_mode: - driver.switch_to.window(driver.window_handles[-1]) - driver.close() - driver.switch_to.window(driver.window_handles[0]) - -# Démarrer l'enregistrement -if record_mode: - video_recorder.start() - -# Trouvez les éléments du formulaire -courriel_input = driver.find_element(By.NAME, "login") -mot_de_passe_input = driver.find_element(By.NAME, "password") -try: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/div/div/form/div[3]/button" - # '//button[contains(text(), "Log in")]' - ) -except Exception: - connexion_button = driver.find_element( - By.XPATH, - "/html/body/div/main/div/form/div[3]/button" - # '//button[contains(text(), "Connexion")]' - ) - -# Remplissez le courriel et le mot de passe -courriel_input.send_keys("admin") -mot_de_passe_input.send_keys("admin") - -# Cliquez sur le bouton "Connexion" -connexion_button.click() - -# Open View -click(driver, "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a") -click(driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]") -click(driver, "/html/body/header/nav/div/div[1]/div[2]/div/div/div/ul/li[2]/a") -click(driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]") - -# CG self -# Bouton modifier -click(driver, "/html/body/div[1]/main/div[1]/div[2]/div/div/div[1]/button[1]") -# Tab CG -click(driver, "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[3]/a") -# Disable «Stop Execution if Env Not Clean -click( - driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[2]/tbody/tr/td[1]/label", -) -# Gen -click( - driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[1]/tbody/tr[2]/td[1]/button", -) - -# Check error -click(driver, "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[14]/a") -# click(driver, "/html/body/div[1]/main/div[2]/div/div/div[6]/div/div[14]/div/div[2]/table/tbody/tr[1]", time=60*2) - -# Arrêter l'enregistrement -if record_mode: - video_recorder.stop() - -# Open conversation chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/header/nav/ul[3]/li[2]/a') -# conversation_button.click() - -# Close bot chat -# conversation_button = driver.find_element(By.XPATH, '/html/body/div[3]/div[1]/span[2]/a[2]') -# conversation_button.click() - -# Fermez le navigateur -# driver.quit() From 4340f1e088574f0fdddb09e85ab29bde25a7bbb7 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 11 Jan 2024 00:51:34 -0500 Subject: [PATCH 2/8] [UPD] script web_login.py: use plan instead of workspace - auto close chat bot before use wizard --- script/selenium/web_login.py | 63 ++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 10 deletions(-) diff --git a/script/selenium/web_login.py b/script/selenium/web_login.py index 9afc7e8..c752bd3 100755 --- a/script/selenium/web_login.py +++ b/script/selenium/web_login.py @@ -3,11 +3,13 @@ import argparse import os import sys +import time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait +from selenium.common.exceptions import NoSuchElementException def get_config(): @@ -80,6 +82,15 @@ def click(driver, xpath, time=5): button.click() +def check_bot_chat_and_close(driver): + try: + xpath_button = "/html/body/div[3]/div[1]/span[2]/a[2]" + button = driver.find_element(By.XPATH, xpath_button) + click(driver, xpath_button) + except Exception: + print("element not found") + + def run(config): if config.record_mode: new_path = os.path.normpath( @@ -190,7 +201,7 @@ def run(config): connexion_button.click() # Attendez que l'élément soit cliquable - wait = WebDriverWait(driver, 5) + # wait = WebDriverWait(driver, 5) # menu_toggle = wait.until( # EC.element_to_be_clickable((By.XPATH, "/html/body/header/nav/ul[1]/li/a")) # ) @@ -218,6 +229,8 @@ def run(config): driver, "/html/body/div[1]/main/div[2]/div/div/table/tbody/tr[1]/td[2]", ) + # Remove chat bot if open, because will crash wizard div[4] (to div[5]) + check_bot_chat_and_close(driver) if config.open_me_devops_auto: click( driver, @@ -230,32 +243,62 @@ def run(config): # CG self # Bouton modifier + # click( + # driver, + # "/html/body/div[1]/main/div[1]/div[2]/div/div/div[1]/button[1]", + # ) + # Tab Code + # click( + # driver, + # "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[2]/a", + # ) + # Bouton Plan click( driver, - "/html/body/div[1]/main/div[1]/div[2]/div/div/div[1]/button[1]", + "/html/body/div[1]/main/div[2]/div/div/div[1]/div/button[1]", ) - # Tab CG + + # Bouton autopoiesis click( driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[3]/a", + "/html/body/div[4]/div/div/main/div/div/div[5]/table[2]/tbody/tr[2]/td[1]/button", ) + + # Bouton devops regenerate + click( + driver, + "/html/body/div[4]/div/div/main/div/div/div[6]/table[2]/tbody/tr[2]/td/button", + ) + if config.open_me_devops_auto_force: # Disable «Stop Execution if Env Not Clean + # click( + # driver, + # "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[2]/div[6]/table[2]/tbody/tr[3]/td[2]/div/label", + # ) + # Option Force Generate click( driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[2]/tbody/tr/td[1]/label", + "/html/body/div[4]/div/div/main/div/div/div[8]/table/tbody/tr[2]/td[1]/label", ) + # Gen + # click( + # driver, + # "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[2]/div[2]/table[1]/tbody/tr/td[1]/button", + # ) + + # Next state click( driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/div/div[3]/div[2]/table[1]/tbody/tr[2]/td[1]/button", + "/html/body/div[4]/div/div/footer/div/footer/div/button[1]", ) # Check error - click( - driver, - "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[14]/a", - ) + # click( + # driver, + # "/html/body/div[1]/main/div[2]/div/div/div[7]/ul/li[13]/a", + # ) # click(driver, "/html/body/div[1]/main/div[2]/div/div/div[6]/div/div[14]/div/div[2]/table/tbody/tr[1]", time=60*2) # Arrêter l'enregistrement From 2dcfbf29432839c126229e164bfd94309aa02389 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Tue, 6 Feb 2024 23:27:34 -0500 Subject: [PATCH 3/8] [FIX] script selenium: web login support firefox snap --- script/selenium/install.md | 4 ++++ script/selenium/web_login.py | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/script/selenium/install.md b/script/selenium/install.md index 448a05d..db23680 100644 --- a/script/selenium/install.md +++ b/script/selenium/install.md @@ -1,3 +1,7 @@ +wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz +tar xvf geckodriver-v0.34.0-linux64.tar.gz +sudo mv ./.venv/geckodriver /usr/bin/geckdriver + sudo apt install libcairo2-dev python3-dev pkg-config libxt-dev libgirepository1.0-dev pip install pycairo PyGObject diff --git a/script/selenium/web_login.py b/script/selenium/web_login.py index c752bd3..287f678 100755 --- a/script/selenium/web_login.py +++ b/script/selenium/web_login.py @@ -10,6 +10,8 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import NoSuchElementException +from selenium.webdriver.firefox.service import Service +from subprocess import getoutput def get_config(): @@ -55,6 +57,14 @@ def get_config(): " like it!" ), ) + parser.add_argument( + "--firefox_binary_path", + help="Can specify firefox path to open selenium.", + ) + parser.add_argument( + "--gecko_binary_path", + help="Can specify firefox path to open selenium.", + ) parser.add_argument( "--url", default="http://127.0.0.1:8069", @@ -109,9 +119,30 @@ def run(config): firefox_options.set_preference( "permissions.default.desktop-notification", 1 ) + firefox_services = None + if config.firefox_binary_path: + firefox_services = Service(executable_path=config.firefox_binary_path) + if config.gecko_binary_path: + firefox_options.binary_location = config.gecko_binary_path # Créez une instance du navigateur Firefox avec les options de navigation privée - driver = webdriver.Firefox(options=firefox_options) + try: + driver = webdriver.Firefox( + options=firefox_options, service=firefox_services + ) + except Exception: + print("Cannot open Firefox profile, so will force firefox snap for Ubuntu users.") + firefox_services = Service( + executable_path=getoutput( + "find /snap/firefox -name geckodriver" + ).split("\n")[-1] + ) + firefox_options.binary_location = getoutput( + "find /snap/firefox -name firefox" + ).split("\n")[-1] + driver = webdriver.Firefox( + options=firefox_options, service=firefox_services + ) # Ajout de l'enregistrement if config.record_mode: From 4a7be4a77f6b4844d80f114a90d031d2e02e5ab2 Mon Sep 17 00:00:00 2001 From: Christian Lavoie Date: Fri, 16 Feb 2024 16:06:22 -0500 Subject: [PATCH 4/8] [UPD] script install selenium: missing pip --- script/selenium/install.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/script/selenium/install.md b/script/selenium/install.md index db23680..c44407f 100644 --- a/script/selenium/install.md +++ b/script/selenium/install.md @@ -2,6 +2,8 @@ wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodrive tar xvf geckodriver-v0.34.0-linux64.tar.gz sudo mv ./.venv/geckodriver /usr/bin/geckdriver +pip install selenium + sudo apt install libcairo2-dev python3-dev pkg-config libxt-dev libgirepository1.0-dev pip install pycairo PyGObject From eee8e83ac8ef29630eef9f7da5c3dc544add9bb1 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 22 Feb 2024 03:13:29 -0500 Subject: [PATCH 5/8] [ADD] script remote git compare: support git cola like git gui --- script/git/remote_code_generation_git_compare.py | 8 ++++++-- script/selenium/web_login.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/script/git/remote_code_generation_git_compare.py b/script/git/remote_code_generation_git_compare.py index 2296605..6f4e295 100755 --- a/script/git/remote_code_generation_git_compare.py +++ b/script/git/remote_code_generation_git_compare.py @@ -49,6 +49,9 @@ def get_config(): help="Don't show output of difference.", ) parser.add_argument("--git_gui", action="store_true", help="Open git gui.") + parser.add_argument( + "--git_cola", action="store_true", help="Open git cola." + ) parser.add_argument("--meld", action="store_true", help="Open meld.") parser.add_argument( "--clear", @@ -64,7 +67,7 @@ def main(): # path = tempfile.mkdtemp() path = tempfile.NamedTemporaryFile().name if os.path.exists(config.directory1) and os.path.exists(config.directory2): - if config.git_gui: + if config.git_gui or config.git_cola: shutil.copytree(config.directory1, path) shutil.copy2("./.gitignore", path) # repo = Repo(path) @@ -79,8 +82,9 @@ def main(): if not config.quiet: print(status) + cmd = "git cola" if config.git_cola else "git gui" try: - subprocess.call(f"cd {path};git gui", shell=True) + subprocess.call(f"cd {path};{cmd}", shell=True) except: pass if config.clear: diff --git a/script/selenium/web_login.py b/script/selenium/web_login.py index 287f678..9ee711e 100755 --- a/script/selenium/web_login.py +++ b/script/selenium/web_login.py @@ -131,7 +131,10 @@ def run(config): options=firefox_options, service=firefox_services ) except Exception: - print("Cannot open Firefox profile, so will force firefox snap for Ubuntu users.") + print( + "Cannot open Firefox profile, so will force firefox snap for" + " Ubuntu users." + ) firefox_services = Service( executable_path=getoutput( "find /snap/firefox -name geckodriver" From c1997e2a18e094f7f6b7418a1182fa9368d29091 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Mon, 18 Mar 2024 22:45:03 -0400 Subject: [PATCH 6/8] [ADD] repo JayVora-SerpentCS SerpentCS_Contributions Thanks SerpentCS for your contributions --- manifest/default.dev.xml | 2 ++ script/generate_config.sh | 1 + source_repo_addons.csv | 1 + 3 files changed, 4 insertions(+) diff --git a/manifest/default.dev.xml b/manifest/default.dev.xml index c94ab8d..3225930 100644 --- a/manifest/default.dev.xml +++ b/manifest/default.dev.xml @@ -13,6 +13,7 @@ + @@ -143,6 +144,7 @@ + diff --git a/script/generate_config.sh b/script/generate_config.sh index 80a7ad6..cf22cc1 100755 --- a/script/generate_config.sh +++ b/script/generate_config.sh @@ -32,6 +32,7 @@ if [[ ${EL_MINIMAL_ADDONS} = "False" ]]; then printf "${EL_HOME}/addons/ERPLibre_erplibre-3D-printing-addons," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/ERPLibre_erplibre_addons," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/ERPLibre_erplibre_theme_addons," >> ${EL_CONFIG_FILE} + printf "${EL_HOME}/addons/JayVora-SerpentCS_SerpentCS_Contributions," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/MathBenTech_QuotationRevision," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/MathBenTech_development," >> ${EL_CONFIG_FILE} printf "${EL_HOME}/addons/MathBenTech_erplibre-family-management," >> ${EL_CONFIG_FILE} diff --git a/source_repo_addons.csv b/source_repo_addons.csv index 05d77e7..986f6ea 100644 --- a/source_repo_addons.csv +++ b/source_repo_addons.csv @@ -135,3 +135,4 @@ https://github.com/ajepe/odoo-addons.git,addons,, https://github.com/OmniaGit/odooplm.git,addons,, https://github.com/MathBenTech/erplibre-family-management.git,addons,, https://github.com/ERPLibre/erplibre-3D-printing-addons.git,addons,, +https://github.com/JayVora-SerpentCS/SerpentCS_Contributions.git,addons,, From 741b854229369f5e638298582cde0da5e447988d Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 18 Apr 2024 01:50:38 -0400 Subject: [PATCH 7/8] [ADD] script open terminal: double root, second open selenium --- script/open_terminal_code_generator.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script/open_terminal_code_generator.sh b/script/open_terminal_code_generator.sh index c62dd6e..257934d 100755 --- a/script/open_terminal_code_generator.sh +++ b/script/open_terminal_code_generator.sh @@ -2,6 +2,7 @@ # Open a new gnome-terminal with different path on new tab working_path=$(readlink -f .) paths=( + "${working_path}/" "${working_path}/" "${working_path}/addons/ERPLibre_erplibre_addons" "${working_path}/addons/TechnoLibre_odoo-code-generator" @@ -11,6 +12,7 @@ paths=( ) first_iteration=true +second_iteration=true if [[ "${OSTYPE}" == "linux-gnu" ]]; then cmd_before="cd " cmd_after_first=";gnome-terminal --tab -- bash -c 'source ./.venv/bin/activate;git status;bash';" @@ -20,6 +22,9 @@ if [[ "${OSTYPE}" == "linux-gnu" ]]; then if $first_iteration; then LONGCMD+="${cmd_before}${t}${cmd_after_first}" first_iteration=false + elif $second_iteration; then + LONGCMD+="${cmd_before}${t}${cmd_after_first}" + second_iteration=false else LONGCMD+="${cmd_before}${t}${cmd_after}" fi @@ -36,6 +41,9 @@ elif [[ "${OSTYPE}" == "darwin"* ]]; then if $first_iteration; then osascript_command+=" -e 'tell application \"System Events\" to keystroke \"t\" using {command down}' -e 'delay 0.1' -e 'do script \"cd ${t}; source ./.venv/bin/activate; git status\" in front window'" first_iteration=false + elif $second_iteration; then + osascript_command+=" -e 'tell application \"System Events\" to keystroke \"t\" using {command down}' -e 'delay 0.1' -e 'do script \"cd ${t}; source ./.venv/bin/activate; git status\" in front window'" + second_iteration=false else osascript_command+=" -e 'tell application \"System Events\" to keystroke \"t\" using {command down}' -e 'delay 0.1' -e 'do script \"cd ${t}; git status\" in front window'" fi From ee1acf91f20eb1ca0e4037ae7d746a6f370ae192 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 3 May 2024 23:29:59 -0400 Subject: [PATCH 8/8] =?UTF-8?q?[UPD]=C2=A0changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 382b030..94bb4f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Selenium script to increase open software client interface and automated some actions. - FAQ about kill git-daemon - Support Ubuntu 23.10 +- ADD repo JayVora-SerpentCS_SerpentCS_Contributions ## Changed