Skip to content

Commit a11d289

Browse files
committed
test: harden click_modal backdrop wait and open_query_tool stale-element retry
click_modal: wait up to 5s for the MuiDialog-backdrop to become invisible after clicking the modal button. MUI v7 leaves the backdrop in the DOM during the ~300ms close animation, which intercepts the next click in tests that chain modal->modal interactions. open_query_tool: the execute-query toolbar button can re-render between the visibility wait and the ActionChains.move_to_element call (Firefox/geckodriver hits this regularly). Retry the move up to 3 times on StaleElementReferenceException, refetching the element each attempt rather than reusing a stale handle. Both changes are pure test-side stability fixes; no production code or behavior is affected.
1 parent a50a553 commit a11d289

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

web/regression/feature_utils/pgadmin_page.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,16 @@ def click_modal(self, button_text, docker=False):
106106

107107
self.click_element(modal_button)
108108

109+
# Wait for the dialog backdrop to fade out so subsequent clicks
110+
# are not intercepted by the closing modal. MUI v7 leaves the
111+
# backdrop in the DOM for ~300ms while the close animation runs.
112+
try:
113+
WebDriverWait(self.driver, 5).until(
114+
EC.invisibility_of_element_located(
115+
(By.CSS_SELECTOR, ".MuiDialog-backdrop")))
116+
except TimeoutException:
117+
pass
118+
109119
def add_server(self, server_config):
110120
server_group_node = \
111121
self.find_by_xpath(TreeAreaLocators.server_group_node("Servers"))
@@ -173,11 +183,22 @@ def open_query_tool(self):
173183
), "Timed out waiting for execute query button to appear"
174184
)
175185

176-
# Need to add this as by default tool tip is shown for file
177-
ActionChains(self.driver).move_to_element(
178-
self.driver.find_element(
179-
By.CSS_SELECTOR,
180-
QueryToolLocators.btn_execute_query_css)).perform()
186+
# Need to add this as by default tool tip is shown for file.
187+
# Retry on stale-element: the toolbar can re-render between the
188+
# visibility wait above and the move_to_element below (Firefox
189+
# is particularly sensitive to this). Refetch the element on
190+
# each attempt rather than relying on a captured reference.
191+
for attempt in range(3):
192+
try:
193+
ActionChains(self.driver).move_to_element(
194+
self.driver.find_element(
195+
By.CSS_SELECTOR,
196+
QueryToolLocators.btn_execute_query_css)).perform()
197+
break
198+
except StaleElementReferenceException:
199+
if attempt == 2:
200+
raise
201+
time.sleep(0.2)
181202

182203
def open_view_data(self, table_name):
183204
self.click_element(self.find_by_css_selector(

0 commit comments

Comments
 (0)