From 311ba0c853cf72b894d8dc324966972fa3a60779 Mon Sep 17 00:00:00 2001 From: Elena Bondarenko <40801241+ebondare@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:24:08 +0200 Subject: [PATCH] Fix failure to clear field (#8329) Signed-off-by: Elena Bondarenko --- ocs_ci/ocs/ui/base_ui.py | 12 ++++++++++++ ocs_ci/ocs/ui/pvc_ui.py | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ocs_ci/ocs/ui/base_ui.py b/ocs_ci/ocs/ui/base_ui.py index f172c5c693f..051b108e4ec 100644 --- a/ocs_ci/ocs/ui/base_ui.py +++ b/ocs_ci/ocs/ui/base_ui.py @@ -18,6 +18,7 @@ from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.ui import WebDriverWait from urllib.parse import urlparse @@ -548,6 +549,17 @@ def do_clear(self, locator, timeout=30): element = wait.until(ec.element_to_be_clickable((locator[1], locator[0]))) element.clear() + def clear_with_ctrl_a_del(self, locator, timeout=30): + """ + Clear the existing text using CTRL + a and then Del keys, + as on some elements .clear() function doesn't always work correctly. + + """ + wait = WebDriverWait(self.driver, timeout) + element = wait.until(ec.element_to_be_clickable((locator[1], locator[0]))) + element.send_keys(Keys.CONTROL, "a") + element.send_keys(Keys.DELETE) + def wait_until_expected_text_is_found(self, locator, expected_text, timeout=60): """ Method to wait for a expected text to appear on the UI (use of explicit wait type), diff --git a/ocs_ci/ocs/ui/pvc_ui.py b/ocs_ci/ocs/ui/pvc_ui.py index 2257e4c25cb..852a6366b6a 100644 --- a/ocs_ci/ocs/ui/pvc_ui.py +++ b/ocs_ci/ocs/ui/pvc_ui.py @@ -296,9 +296,11 @@ def pvc_clone_ui( self.ocp_version_full == version.VERSION_4_6 and ocs_version == version.VERSION_4_6 ): - self.do_clear(format_locator(self.pvc_loc["clone_name_input"], clone_name)) + self.clear_with_ctrl_a_del( + format_locator(self.pvc_loc["clone_name_input"], clone_name) + ) else: - self.do_clear(self.pvc_loc["clone_name_input"]) + self.clear_with_ctrl_a_del(self.pvc_loc["clone_name_input"]) logger.info("Enter the name of clone PVC") if (