Skip to content

Commit

Permalink
Fix failure to clear field (#8329)
Browse files Browse the repository at this point in the history
Signed-off-by: Elena Bondarenko <[email protected]>
  • Loading branch information
ebondare authored Sep 29, 2023
1 parent 13b0e44 commit 311ba0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 12 additions & 0 deletions ocs_ci/ocs/ui/base_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions ocs_ci/ocs/ui/pvc_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 311ba0c

Please sign in to comment.