From 31edf993299eeaae7dffa76b4bcd8487a7e326c9 Mon Sep 17 00:00:00 2001 From: Omar Munoz Date: Thu, 21 Sep 2023 12:31:37 -0500 Subject: [PATCH] Make selenium v4 syntax optional using the same pattern as https://review.opendev.org/c/openstack/openstack-helm-infra/+/892708 Change-Id: Ifbf2e4d6a127ac1e7858c05b73321e4903d60596 --- horizon/Chart.yaml | 2 +- horizon/templates/bin/_selenium-test.py.tpl | 15 +++++++++++++++ horizon/values.yaml | 3 +++ releasenotes/notes/horizon.yaml | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/horizon/Chart.yaml b/horizon/Chart.yaml index b1d0cb3ecb..4cc5bf8952 100644 --- a/horizon/Chart.yaml +++ b/horizon/Chart.yaml @@ -14,7 +14,7 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Horizon name: horizon -version: 0.3.12 +version: 0.3.13 home: https://docs.openstack.org/horizon/latest/ icon: https://www.openstack.org/themes/openstack/images/project-mascots/Horizon/OpenStack_Project_Horizon_vertical.png sources: diff --git a/horizon/templates/bin/_selenium-test.py.tpl b/horizon/templates/bin/_selenium-test.py.tpl index 14cae8adfc..4373ca7ee0 100644 --- a/horizon/templates/bin/_selenium-test.py.tpl +++ b/horizon/templates/bin/_selenium-test.py.tpl @@ -23,6 +23,9 @@ from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options +{{- if .Values.selenium_v4 }} +from selenium.webdriver.chrome.service import Service +{{- end }} from selenium.common.exceptions import TimeoutException from selenium.common.exceptions import NoSuchElementException @@ -58,7 +61,12 @@ options = Options() options.add_argument('--headless') options.add_argument('--no-sandbox') chrome_driver = '/etc/selenium/chromedriver' +{{- if .Values.selenium_v4 }} +service = Service(executable_path=chrome_driver) +browser = webdriver.Chrome(service=service, options=options) +{{- else }} browser = webdriver.Chrome(chrome_driver, chrome_options=options) +{{- end }} try: logger.info('Attempting to connect to Horizon') @@ -74,10 +82,17 @@ except TimeoutException: try: logger.info('Attempting to log into Horizon') +{{- if .Values.selenium_v4 }} + browser.find_element(By.NAME, 'domain').send_keys(user_domain_name) + browser.find_element(By.NAME, 'username').send_keys(keystone_user) + browser.find_element(By.NAME, 'password').send_keys(keystone_password) + browser.find_element(By.ID, 'loginBtn').click() +{{- else }} browser.find_element_by_name('domain').send_keys(user_domain_name) browser.find_element_by_name('username').send_keys(keystone_user) browser.find_element_by_name('password').send_keys(keystone_password) browser.find_element_by_id('loginBtn').click() +{{- end }} WebDriverWait(browser, 15).until( EC.presence_of_element_located((By.ID, 'navbar-collapse')) ) diff --git a/horizon/values.yaml b/horizon/values.yaml index 73b0d46501..381d4fe33f 100644 --- a/horizon/values.yaml +++ b/horizon/values.yaml @@ -32,6 +32,9 @@ images: - dep_check - image_repo_sync +# Use selenium v4 syntax +selenium_v4: true + release_group: null labels: diff --git a/releasenotes/notes/horizon.yaml b/releasenotes/notes/horizon.yaml index 1107b8928f..ec0ef2ab8e 100644 --- a/releasenotes/notes/horizon.yaml +++ b/releasenotes/notes/horizon.yaml @@ -49,4 +49,5 @@ horizon: - 0.3.10 Add 2023.1 overrides - 0.3.11 Rollout when logo configmap is changed - 0.3.12 Add Ubuntu Jammy overrides + - 0.3.13 Make selenium v4 syntax optional ...