2018-10-08 05:09:30 -05:00
|
|
|
##########################################################################
|
|
|
|
#
|
|
|
|
# pgAdmin 4 - PostgreSQL Tools
|
|
|
|
#
|
2023-01-02 00:23:55 -06:00
|
|
|
# Copyright (C) 2013 - 2023, The pgAdmin Development Team
|
2018-10-08 05:09:30 -05:00
|
|
|
# This software is released under the PostgreSQL Licence
|
|
|
|
#
|
|
|
|
##########################################################################
|
2022-08-11 00:19:45 -05:00
|
|
|
import time
|
2019-11-10 23:19:00 -06:00
|
|
|
from regression.feature_utils.locators import NavMenuLocators
|
2022-07-08 07:55:00 -05:00
|
|
|
from selenium.webdriver.common.by import By
|
2022-08-11 00:19:45 -05:00
|
|
|
from selenium.webdriver.support import expected_conditions as EC
|
2018-10-08 05:09:30 -05:00
|
|
|
|
|
|
|
|
2022-08-11 00:19:45 -05:00
|
|
|
def close_bgprocess_start_popup(tester):
|
2018-10-08 05:09:30 -05:00
|
|
|
"""
|
2019-05-23 03:31:52 -05:00
|
|
|
Allows us to close the background process popup window
|
2018-10-08 05:09:30 -05:00
|
|
|
"""
|
2022-08-11 00:19:45 -05:00
|
|
|
tester.driver.find_element(
|
|
|
|
By.CSS_SELECTOR,
|
|
|
|
NavMenuLocators.process_start_close_selector).click()
|
2018-10-08 05:09:30 -05:00
|
|
|
|
2019-04-05 01:55:03 -05:00
|
|
|
|
2022-08-11 00:19:45 -05:00
|
|
|
def wait_for_process_start(tester):
|
|
|
|
tester.wait.until(EC.visibility_of_element_located(
|
|
|
|
(By.CSS_SELECTOR,
|
|
|
|
NavMenuLocators.process_start_close_selector)))
|
|
|
|
close_bgprocess_start_popup(tester)
|
|
|
|
|
|
|
|
|
|
|
|
def wait_for_process_end(self):
|
|
|
|
"""This will wait for process to complete dialogue status"""
|
|
|
|
attempts = 120
|
|
|
|
status = False
|
|
|
|
while attempts > 0:
|
|
|
|
try:
|
|
|
|
button = self.page.find_by_css_selector(
|
|
|
|
NavMenuLocators.process_end_close_selector)
|
|
|
|
status = True
|
|
|
|
button.click()
|
|
|
|
break
|
|
|
|
except Exception:
|
|
|
|
attempts -= 1
|
|
|
|
time.sleep(.5)
|
|
|
|
return status
|
|
|
|
|
|
|
|
|
|
|
|
def open_process_details(tester):
|
|
|
|
status = wait_for_process_end(tester)
|
|
|
|
if not status:
|
|
|
|
raise RuntimeError("Process not completed")
|
|
|
|
|
|
|
|
tester.page.click_tab("Processes")
|
|
|
|
time.sleep(3)
|
|
|
|
tester.page.find_by_css_selector(
|
|
|
|
"div[data-test='processes'] "
|
|
|
|
"div[data-test='row-container']:nth-child(1) "
|
|
|
|
"div[role='row'] div[role='cell']:nth-child(3) button").click()
|
|
|
|
|
|
|
|
tester.page.wait_for_element_to_disappear(
|
|
|
|
lambda driver: driver.find_element(
|
|
|
|
By.CSS_SELECTOR, "span[data-test='loading-logs']"))
|
2019-11-10 23:19:00 -06:00
|
|
|
|
|
|
|
|
|
|
|
def close_process_watcher(tester):
|
2019-11-12 23:49:21 -06:00
|
|
|
attempt = 10
|
2019-11-10 23:19:00 -06:00
|
|
|
while attempt > 0:
|
2019-12-03 08:05:48 -06:00
|
|
|
try:
|
|
|
|
if not tester.page.check_if_element_exist_by_xpath(
|
|
|
|
NavMenuLocators.process_watcher_close_button_xpath, 1):
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
close_btn = tester.page.find_by_xpath(
|
|
|
|
NavMenuLocators.process_watcher_close_button_xpath)
|
|
|
|
close_btn.click()
|
|
|
|
attempt -= 1
|
|
|
|
except Exception:
|
2019-11-10 23:19:00 -06:00
|
|
|
attempt -= 1
|