Fixed feature tests.

This commit is contained in:
Yogesh Mahajan 2022-06-22 17:47:09 +05:30 committed by Akshay Joshi
parent 74f7fee8b5
commit 95f63f6af8
4 changed files with 31 additions and 27 deletions

View File

@ -118,9 +118,9 @@ class QueryToolFeatureTest(BaseFeatureTest):
# this will set focus to correct iframe.
self.page.fill_codemirror_area_with('')
explain_op = self.page.find_by_css_selector(
QueryToolLocators.btn_explain_options_dropdown)
explain_op.click()
self.page.retry_click(
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown),
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose))
# disable Explain options and auto rollback only if they are enabled.
for op in (QueryToolLocators.btn_explain_verbose,
@ -261,17 +261,15 @@ SELECT generate_series(1, 1000) as id order by id desc"""
self.page.fill_codemirror_area_with(query)
explain_op = self.page.find_by_css_selector(
QueryToolLocators.btn_explain_options_dropdown)
explain_op.click()
self.page.retry_click(
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown),
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose))
# disable Explain options and auto rollback only if they are enabled.
for op in (QueryToolLocators.btn_explain_verbose,
QueryToolLocators.btn_explain_costs):
self.page.find_by_css_selector(op).click()
explain_op.click()
self.page.find_by_css_selector(
QueryToolLocators.btn_explain).click()
@ -299,17 +297,15 @@ SELECT generate_series(1, 1000) as id order by id desc"""
self.page.fill_codemirror_area_with(query)
explain_op = self.page.find_by_css_selector(
QueryToolLocators.btn_explain_options_dropdown)
explain_op.click()
self.page.retry_click(
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown),
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose))
# disable Explain options and auto rollback only if they are enabled.
for op in (QueryToolLocators.btn_explain_buffers,
QueryToolLocators.btn_explain_timing):
self.page.find_by_css_selector(op).click()
explain_op.click()
self.page.find_by_css_selector(
QueryToolLocators.btn_explain_analyze).click()
@ -685,9 +681,10 @@ SELECT 1, pg_sleep(300)"""
self.page.fill_codemirror_area_with(
"SELECT count(*) FROM pg_catalog.pg_class;")
explain_op = self.page.find_by_css_selector(
QueryToolLocators.btn_explain_options_dropdown)
explain_op.click()
self.page.retry_click(
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_options_dropdown),
(By.CSS_SELECTOR, QueryToolLocators.btn_explain_verbose))
# disable Explain options and only enable COST option
for op in (QueryToolLocators.btn_explain_verbose,
@ -702,9 +699,7 @@ SELECT 1, pg_sleep(300)"""
QueryToolLocators.btn_explain_costs)
cost_btn.click()
# close explain options
explain_op.click()
# close explain options not required
self.page.find_by_css_selector(
QueryToolLocators.btn_explain_analyze).click()

View File

@ -39,6 +39,7 @@ class PgadminPage:
# pgAdmin related methods
def login_to_app(self, user_detail):
self.driver.switch_to.default_content()
if not (self.check_if_element_exist_by_xpath(
'//a[@id="navbar-user"]', 1)):
user_edt_box_el = self.driver.find_element_by_name('email')
@ -253,11 +254,14 @@ class PgadminPage:
css_selector_of_option)
if menu_option.get_attribute('data-checked') == 'false':
while retry > 0:
menu_option.click()
time.sleep(0.2)
if menu_option.get_attribute('data-checked') == 'true':
break
else:
try:
menu_option.click()
time.sleep(0.2)
if menu_option.get_attribute('data-checked') == 'true':
break
else:
retry -= 1
except Exception:
retry -= 1
if option == 'auto_commit':
@ -618,6 +622,7 @@ class PgadminPage:
database_node = \
self.check_if_element_exists_with_scroll(database_node_xpath)
if database_node:
database_node.click()
self.driver.execute_script(
self.js_executor_scrollintoview_arg, database_node)
if self.check_if_element_exist_by_xpath(

View File

@ -1384,7 +1384,7 @@ def launch_url_in_browser(driver_instance, url, title='pgAdmin 4', timeout=50):
raise WebDriverException(exception_msg)
def get_remote_webdriver(hub_url, browser, browser_ver, test_name):
def get_remote_webdriver(hub_url, browser, browser_ver, test_name, url_client):
"""
This functions returns remote web-driver instance created in selenoid
machine.
@ -1421,6 +1421,8 @@ def get_remote_webdriver(hub_url, browser, browser_ver, test_name):
elif browser == 'chrome':
options = Options()
options.add_argument("--window-size=1280,1024")
options.add_argument(
'--unsafely-treat-insecure-origin-as-secure=' + url_client)
desired_capabilities["browserName"] = "chrome"
driver_local = webdriver.Remote(
command_executor=hub_url,

View File

@ -601,7 +601,8 @@ def run_parallel_tests(url_client, servers_details, parallel_tests_lists,
test_utils.get_remote_webdriver(hub_url,
name_of_browser,
version_of_browser,
ser['name'])
ser['name'],
url_client)
# Launch client url in browser
test_utils.launch_url_in_browser(
driver_object, url_client, timeout=60)
@ -659,7 +660,8 @@ def run_sequential_tests(url_client, servers_details, sequential_tests_lists,
driver_object = test_utils.get_remote_webdriver(hub_url,
name_of_browser,
version_of_browser,
"Sequential_Tests")
"Sequential_Tests",
url_client)
# Launch client url in browser
test_utils.launch_url_in_browser(driver_object, url_client)