Fixed following SonarQube issues:

1. String literals should not be duplicated.
 2. Cognitive Complexity of functions should not be too high.
This commit is contained in:
Yogesh Mahajan 2020-08-19 13:22:17 +05:30 committed by Akshay Joshi
parent 89e2f09b84
commit 0668a52c6b
3 changed files with 347 additions and 258 deletions

View File

@ -72,39 +72,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.server['db_password'], self.database_name)
# Backup
self.page.retry_click(
(By.LINK_TEXT,
NavMenuLocators.tools_menu_link_text),
(By.CSS_SELECTOR,
NavMenuLocators.backup_obj_css))
backup_object = self.wait.until(EC.visibility_of_element_located(
(By.CSS_SELECTOR, NavMenuLocators.backup_obj_css)))
backup_object.click()
# Enter the file name of the backup to be taken
self.wait.until(EC.visibility_of_element_located(
(By.NAME, NavMenuLocators.backup_filename_txt_box_name)))
element = self.wait.until(EC.element_to_be_clickable(
(By.NAME, NavMenuLocators.backup_filename_txt_box_name)))
element.click()
self.page.fill_input_by_field_name(
NavMenuLocators.backup_filename_txt_box_name,
"test_backup", loose_focus=True)
# Click on the take Backup button
take_bckup = self.page.find_by_xpath(
NavMenuLocators.backup_btn_xpath)
click = True
while click:
try:
take_bckup.click()
if self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_name(
NavMenuLocators.backup_filename_txt_box_name)):
click = False
except Exception:
pass
self.initiate_backup()
# Wait for the backup status alertfier
self.wait.until(EC.visibility_of_element_located(
@ -123,8 +91,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
".loading-logs"), 10)
expected_backup_success_msg = "Successfully completed."
if status != expected_backup_success_msg:
self.assertEquals(status, expected_backup_success_msg)
self.assertEquals(status, expected_backup_success_msg)
backup_file = None
# Check for XSS in Backup details
@ -151,31 +118,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
test_gui_helper.close_process_watcher(self)
# Restore
tools_menu = self.driver.find_element_by_link_text(
NavMenuLocators.tools_menu_link_text)
tools_menu.click()
restore_obj = self.page.find_by_css_selector(
NavMenuLocators.restore_obj_css)
restore_obj.click()
self.wait.until(EC.visibility_of_element_located(
(By.NAME, NavMenuLocators.restore_file_name_txt_box_name)))
self.wait.until(EC.element_to_be_clickable(
(By.NAME, NavMenuLocators.restore_file_name_txt_box_name))).click()
self.page.fill_input_by_field_name(
NavMenuLocators.restore_file_name_txt_box_name,
"test_backup", loose_focus=True)
restore_btn = self.page.find_by_xpath(
NavMenuLocators.restore_button_xpath)
restore_btn.click()
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(
NavMenuLocators.restore_file_name_txt_box_name))
self.initiate_restore()
# Wait for the backup status alertfier
self.wait.until(EC.visibility_of_element_located(
@ -192,9 +135,7 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(
".loading-logs"), 10)
if status != expected_backup_success_msg:
self.assertEquals(status, expected_backup_success_msg)
self.assertEquals(status, expected_backup_success_msg)
# Check for XSS in Restore details
if self.is_xss_check:
@ -239,6 +180,68 @@ class PGUtilitiesBackupFeatureTest(BaseFeatureTest):
'{0} detailed window'.format(tool_name)
)
def initiate_backup(self):
self.page.retry_click(
(By.LINK_TEXT,
NavMenuLocators.tools_menu_link_text),
(By.CSS_SELECTOR,
NavMenuLocators.backup_obj_css))
backup_object = self.wait.until(EC.visibility_of_element_located(
(By.CSS_SELECTOR, NavMenuLocators.backup_obj_css)))
backup_object.click()
# Enter the file name of the backup to be taken
self.wait.until(EC.visibility_of_element_located(
(By.NAME, NavMenuLocators.backup_filename_txt_box_name)))
element = self.wait.until(EC.element_to_be_clickable(
(By.NAME, NavMenuLocators.backup_filename_txt_box_name)))
element.click()
self.page.fill_input_by_field_name(
NavMenuLocators.backup_filename_txt_box_name,
"test_backup", loose_focus=True)
# Click on the take Backup button
take_bckup = self.page.find_by_xpath(
NavMenuLocators.backup_btn_xpath)
click = True
while click:
try:
take_bckup.click()
if self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_name(
NavMenuLocators.backup_filename_txt_box_name)):
click = False
except Exception:
pass
def initiate_restore(self):
tools_menu = self.driver.find_element_by_link_text(
NavMenuLocators.tools_menu_link_text)
tools_menu.click()
restore_obj = self.page.find_by_css_selector(
NavMenuLocators.restore_obj_css)
restore_obj.click()
self.wait.until(EC.visibility_of_element_located(
(By.NAME, NavMenuLocators.restore_file_name_txt_box_name)))
self.wait.until(EC.element_to_be_clickable(
(By.NAME, NavMenuLocators.restore_file_name_txt_box_name))).click()
self.page.fill_input_by_field_name(
NavMenuLocators.restore_file_name_txt_box_name,
"test_backup", loose_focus=True)
restore_btn = self.page.find_by_xpath(
NavMenuLocators.restore_button_xpath)
restore_btn.click()
self.page.wait_for_element_to_disappear(
lambda driver: driver.find_element_by_css_selector(
NavMenuLocators.restore_file_name_txt_box_name))
def _check_escaped_characters(self, source_code, string_to_find, source):
# For XSS we need to search against element's html code
assert source_code.find(string_to_find) != - \

View File

@ -28,6 +28,8 @@ class PgadminPage:
"""
Helper class for interacting with the page, given a selenium driver
"""
# Common argument passed for scrolling
js_executor_scrollintoview_arg = "arguments[0].scrollIntoView()"
def __init__(self, driver, app_config):
self.driver = driver
@ -99,17 +101,18 @@ class PgadminPage:
(By.CSS_SELECTOR, "button[type='save'].btn.btn-primary")))
self.find_by_css_selector("button[type='save'].btn.btn-primary").\
click()
server_tree_xpath = \
"//*[@id='tree']//*[.='" + server_config['name'] + "']"
try:
WebDriverWait(self.driver, 10).until(
EC.visibility_of_element_located(
(By.XPATH,
"//*[@id='tree']//*[.='" + server_config['name'] + "']")))
(By.XPATH, server_tree_xpath)))
except TimeoutException:
self.toggle_open_servers_group()
WebDriverWait(self.driver, 10).until(
EC.visibility_of_element_located(
(By.XPATH,
"//*[@id='tree']//*[.='" + server_config['name'] + "']")))
(By.XPATH, server_tree_xpath)))
def open_query_tool(self):
self.driver.find_element_by_link_text("Tools").click()
@ -222,34 +225,28 @@ class PgadminPage:
if expanded == "false":
query_options.click()
retry = 3
def update_execute_option_setting(
css_selector_of_option_status, css_selector_of_option,):
retry = 3
check_status = self.driver.find_element_by_css_selector(
css_selector_of_option_status)
if 'visibility-hidden' in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(css_selector_of_option).click()
time.sleep(0.2)
if 'visibility-hidden' not in \
check_status.get_attribute('class'):
break
else:
retry -= 1
if option == 'auto_commit':
check_status = self.driver.find_element_by_css_selector(
QueryToolLocators.btn_auto_commit_check_status)
if 'visibility-hidden' in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(
QueryToolLocators.btn_auto_commit).click()
time.sleep(0.2)
if 'visibility-hidden' not in \
check_status.get_attribute('class'):
break
else:
retry -= 1
update_execute_option_setting(
QueryToolLocators.btn_auto_commit_check_status,
QueryToolLocators.btn_auto_commit)
if option == 'auto_rollback':
check_status = self.driver.find_element_by_css_selector(
QueryToolLocators.btn_auto_rollback_check_status)
if 'visibility-hidden' in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(
QueryToolLocators.btn_auto_rollback).click()
time.sleep(0.2)
if 'visibility-hidden' not in \
check_status.get_attribute('class'):
break
else:
retry -= 1
update_execute_option_setting(
QueryToolLocators.btn_auto_rollback_check_status,
QueryToolLocators.btn_auto_rollback)
def uncheck_execute_option(self, option):
""""This function will uncheck auto commit or auto roll back based on
@ -260,33 +257,30 @@ class PgadminPage:
if expanded == "false":
query_options.click()
retry = 3
def update_execute_option_setting(
css_selector_of_option_status, css_selector_of_option):
retry = 3
check_status = self.driver.find_element_by_css_selector(
css_selector_of_option_status)
if 'visibility-hidden' not in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(
css_selector_of_option).click()
time.sleep(0.2)
if 'visibility-hidden' in \
check_status.get_attribute('class'):
break
else:
retry -= 1
if option == 'auto_commit':
check_status = self.driver.find_element_by_css_selector(
QueryToolLocators.btn_auto_commit_check_status)
if 'visibility-hidden' not in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(
QueryToolLocators.btn_auto_commit).click()
time.sleep(0.2)
if 'visibility-hidden' in \
check_status.get_attribute('class'):
break
else:
retry -= 1
update_execute_option_setting(
QueryToolLocators.btn_auto_commit_check_status,
QueryToolLocators.btn_auto_commit)
if option == 'auto_rollback':
check_status = self.driver.find_element_by_css_selector(
QueryToolLocators.btn_auto_rollback_check_status)
if 'visibility-hidden' not in check_status.get_attribute('class'):
while retry > 0:
self.find_by_css_selector(
QueryToolLocators.btn_auto_rollback).click()
time.sleep(0.2)
if 'visibility-hidden' in \
check_status.get_attribute('class'):
break
else:
retry -= 1
update_execute_option_setting(
QueryToolLocators.btn_auto_rollback_check_status,
QueryToolLocators.btn_auto_rollback)
def close_data_grid(self):
self.driver.switch_to_default_content()
@ -299,7 +293,7 @@ class PgadminPage:
"//*[@id='tree']//*[.='" + server_config['name'] +
"' and @class='aciTreeItem']")
self.driver.execute_script(
"arguments[0].scrollIntoView()", server_to_remove)
self.js_executor_scrollintoview_arg, server_to_remove)
self.click_element(server_to_remove)
object_menu_item = self.find_by_partial_link_text("Object")
self.click_element(object_menu_item)
@ -311,7 +305,7 @@ class PgadminPage:
item = self.find_by_xpath(
"//*[@id='tree']//*[contains(text(), '" + tree_item_text + "')]"
"/parent::span[@class='aciTreeItem']")
self.driver.execute_script("arguments[0].scrollIntoView()", item)
self.driver.execute_script(self.js_executor_scrollintoview_arg, item)
# unexpected exception like element overlapping, click attempts more
# than one time
attempts = 3
@ -336,7 +330,7 @@ class PgadminPage:
elements, element_name)
if index_of_element >= 0:
self.driver.execute_script(
"arguments[0].scrollIntoView()",
self.js_executor_scrollintoview_arg,
list_of_element[index_of_element])
self.wait_for_elements_to_appear(
self.driver, list_of_element[index_of_element])
@ -396,31 +390,12 @@ class PgadminPage:
index_of_server_node = self.get_index_of_element(
subnodes_of_servers, server_name)
if not self.check_server_is_connected(
index_of_server_node):
if self.click_and_connect_server(
subnodes_of_servers[index_of_server_node],
server_password):
server_node_expansion_status = True
else:
print(
"(expand_server_node)The server node is "
"not expanded",
file=sys.stderr)
else:
if not self.get_expansion_status_of_node_element(
subnodes_of_servers_expansion_status[
index_of_server_node]):
webdriver.ActionChains(self.driver).double_click(
subnodes_of_servers[
index_of_server_node]).perform()
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_a_server_node(server_name),
30):
server_node_expansion_status = True
else:
server_node_expansion_status = True
server_node_expansion_status = self.click_expand_server_node(
subnodes_of_servers_expansion_status,
index_of_server_node,
subnodes_of_servers,
server_name,
server_password)
else:
print(
"(expand_server_node) The Servers node is"
@ -428,6 +403,46 @@ class PgadminPage:
file=sys.stderr)
return server_node_expansion_status
def click_expand_server_node(self, subnodes_of_servers_expansion_status,
index_of_server_node, subnodes_of_servers,
server_name, server_password):
"""
Method actually clicks on server node to expand
:param subnodes_of_servers_expansion_status:
:param index_of_server_node:
:param subnodes_of_servers:
:param server_name:
:param server_password:
:return: True is click action is successful & server node expanded
"""
server_node_expansion_status = False
if not self.check_server_is_connected(
index_of_server_node):
if self.click_and_connect_server(
subnodes_of_servers[index_of_server_node],
server_password):
server_node_expansion_status = True
else:
print(
"(expand_server_node)The server node is "
"not expanded",
file=sys.stderr)
else:
if not self.get_expansion_status_of_node_element(
subnodes_of_servers_expansion_status[
index_of_server_node]):
webdriver.ActionChains(self.driver).double_click(
subnodes_of_servers[
index_of_server_node]).perform()
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_a_server_node(server_name),
30):
server_node_expansion_status = True
else:
server_node_expansion_status = True
return server_node_expansion_status
def expand_databases_node(self, server_name, server_password):
"""will expand databases node under server node"""
databases_node_expanded = False
@ -447,20 +462,11 @@ class PgadminPage:
expansion_status = self.get_expansion_status_of_node_element(
subnode_of_server_node_exp_status[index_of_databases_node])
if not expansion_status:
retry = 5
while retry > 0:
webdriver.ActionChains(self.driver).double_click(
subnodes_of_server_node[
index_of_databases_node].find_element_by_xpath(
".//*[@class='aciTreeItem']")
).perform()
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_databases_node(server_name), 3):
databases_node_expanded = True
break
else:
retry -= 1
databases_node_expanded = \
self.click_to_expand_databases_node(
subnodes_of_server_node,
index_of_databases_node,
server_name)
else:
databases_node_expanded = True
else:
@ -468,11 +474,73 @@ class PgadminPage:
file=sys.stderr)
return databases_node_expanded
def click_to_expand_databases_node(self, subnodes_of_server_node,
index_of_databases_node, server_name):
"""
Method clicks on databases node of specified server to expand
:param subnodes_of_server_node:
:param index_of_databases_node:
:param server_name:
:return: True if database node click is successful & expanded
"""
retry = 5
databases_node_expanded = False
while retry > 0:
webdriver.ActionChains(self.driver).double_click(
subnodes_of_server_node[
index_of_databases_node].find_element_by_xpath(
".//*[@class='aciTreeItem']")
).perform()
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_databases_node(server_name), 3):
databases_node_expanded = True
break
else:
retry -= 1
return databases_node_expanded
def click_to_expand_database_node(self, sub_nodes_of_databases_node,
index_of_required_db_node,
name_of_database):
"""
Method clicks on specified database name from expanded databases node
of server.
:param sub_nodes_of_databases_node:
:param index_of_required_db_node:
:param name_of_database:
:return: True if particular database click is successful & expanded
"""
retry = 5
db_node_expanded_status = False
self.driver.execute_script(self.js_executor_scrollintoview_arg,
sub_nodes_of_databases_node[
index_of_required_db_node])
while retry > 0:
webdriver.ActionChains(self.driver).double_click(
sub_nodes_of_databases_node[
index_of_required_db_node]).perform()
if self.check_if_element_exist_by_xpath(
"//div[@class='ajs-header'and text()='INTERNAL SERVER "
"ERROR']", 1):
try:
self.click_modal('OK')
except Exception:
pass
retry -= 1
else:
break
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_database_node(
name_of_database)):
db_node_expanded_status = True
return db_node_expanded_status
def expand_database_node(self, server_name, server_password,
name_of_database):
"""will expand database node under databases node"""
db_node_expanded_status = False
retry = 5
if self.expand_databases_node(server_name, server_password):
sub_nodes_of_databases_node = self.find_by_xpath_list(
TreeAreaLocators.sub_nodes_of_databases_node(server_name))
@ -486,28 +554,9 @@ class PgadminPage:
server_name))[
index_of_required_db_node])
if not expansion_status:
self.driver.execute_script("arguments[0].scrollIntoView()",
sub_nodes_of_databases_node[
index_of_required_db_node])
while retry > 0:
webdriver.ActionChains(self.driver).double_click(
sub_nodes_of_databases_node[
index_of_required_db_node]).perform()
if self.check_if_element_exist_by_xpath(
"//div[@class='ajs-header'and text()='INTERNAL SERVER "
"ERROR']", 1):
try:
self.click_modal('OK')
except Exception:
pass
retry -= 1
else:
break
if self.wait_for_elements_to_appear(
self.driver, TreeAreaLocators.
sub_nodes_of_database_node(
name_of_database)):
db_node_expanded_status = True
db_node_expanded_status = self.click_to_expand_database_node(
sub_nodes_of_databases_node, index_of_required_db_node,
name_of_database)
else:
db_node_expanded_status = True
else:
@ -533,7 +582,7 @@ class PgadminPage:
index_of_schemas_node])
if not expansion_status:
self.driver.execute_script(
"arguments[0].scrollIntoView()",
self.js_executor_scrollintoview_arg,
sub_nodes_db_node[index_of_schemas_node])
webdriver.ActionChains(self.driver).double_click(
sub_nodes_db_node[index_of_schemas_node]).perform()
@ -570,7 +619,7 @@ class PgadminPage:
index_of_schema_node])
if not expansion_status:
self.driver.execute_script(
"arguments[0].scrollIntoView()",
self.js_executor_scrollintoview_arg,
sub_nodes_schemas_node[index_of_schema_node])
webdriver.ActionChains(self.driver).double_click(
sub_nodes_schemas_node[index_of_schema_node]).perform()
@ -606,7 +655,7 @@ class PgadminPage:
expansion_status = self.get_expansion_status_of_node_element(
sub_nodes_of_schema_node_exp_status[index_of_tables_node])
if not expansion_status:
self.driver.execute_script("arguments[0].scrollIntoView()",
self.driver.execute_script(self.js_executor_scrollintoview_arg,
sub_nodes_of_schema_node[
index_of_tables_node])
webdriver.ActionChains(self.driver).double_click(
@ -778,7 +827,7 @@ class PgadminPage:
item_with_text = self.find_by_xpath(
TreeAreaLocators.specified_tree_node.format(tree_item_text))
self.driver.execute_script("arguments[0].scrollIntoView()",
self.driver.execute_script(self.js_executor_scrollintoview_arg,
item_with_text)
if item_with_text.find_element_by_xpath(
@ -1170,33 +1219,46 @@ class PgadminPage:
switch_box_element = self.find_by_xpath(switch_box)
if required_status == 'Yes':
if 'off' in switch_box_element.get_attribute("class"):
switch_box_element.click()
time.sleep(1)
if 'success' in switch_box_element.get_attribute("class"):
status_changed_successfully = True
else:
print(
"(set_switch_box_status)Clicked the "
"element to change its status but "
"it did not changed",
file=sys.stderr)
elif 'success' in switch_box_element.get_attribute("class"):
status_changed_successfully = True
status_changed_successfully = \
self.toggle_switch_box(switch_box_element,
expected_attr_in_class_tag='success',
unexpected_attr_in_class_tag='off')
else:
if 'success' in switch_box_element.get_attribute("class"):
switch_box_element.click()
if 'off' in switch_box_element.get_attribute("class"):
status_changed_successfully = True
else:
print(
"(set_switch_box_status)Clicked the element to "
"change its status but it did not changed",
file=sys.stderr)
elif 'off' in switch_box_element.get_attribute("class"):
status_changed_successfully = True
status_changed_successfully = \
self.toggle_switch_box(switch_box_element,
expected_attr_in_class_tag='off',
unexpected_attr_in_class_tag='success')
return status_changed_successfully
def toggle_switch_box(self, switch_box_ele, expected_attr_in_class_tag,
unexpected_attr_in_class_tag):
"""
Method toggles switch box status using attributes from class tag
:param switch_box_ele:
:param expected_attr_in_class_tag: e.g. 'off', success
:param unexpected_attr_in_class_tag: e.g. 'off', success
:return: True if class tag attribute is to expected attribute value
in class tag.
"""
status_changed = False
if unexpected_attr_in_class_tag in switch_box_ele.get_attribute(
"class"):
switch_box_ele.click()
time.sleep(1)
if expected_attr_in_class_tag in switch_box_ele.get_attribute(
"class"):
status_changed = True
else:
print(
"(set_switch_box_status)Clicked the "
"element to change its status but "
"it did not changed",
file=sys.stderr)
elif expected_attr_in_class_tag in switch_box_ele.get_attribute(
"class"):
status_changed = True
return status_changed
def retry_click(self, click_locator, verify_locator):
click_status = False
attempt = 0

View File

@ -214,53 +214,7 @@ def get_test_modules(arguments):
exclude_pkgs.extend(['resql'])
if not test_utils.is_parallel_ui_tests(args):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import \
DesiredCapabilities
default_browser = 'chrome'
# Check default browser provided through command line. If provided
# then use that browser as default browser else check for the
# setting provided in test_config.json file.
if (
'default_browser' in arguments and
arguments['default_browser'] is not None
):
default_browser = arguments['default_browser'].lower()
elif (
test_setup.config_data and
"default_browser" in test_setup.config_data
):
default_browser = test_setup.config_data[
'default_browser'].lower()
if default_browser == 'firefox':
cap = DesiredCapabilities.FIREFOX
cap['requireWindowFocus'] = True
cap['enablePersistentHover'] = False
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.disable_beforeunload", True)
driver = webdriver.Firefox(capabilities=cap,
firefox_profile=profile)
driver.implicitly_wait(1)
else:
options = Options()
if test_setup.config_data and \
'headless_chrome' in test_setup.config_data and \
test_setup.config_data['headless_chrome']:
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--window-size=1280,1024")
options.add_argument("--disable-infobars")
options.add_experimental_option('w3c', False)
driver = webdriver.Chrome(chrome_options=options)
# maximize browser window
driver.maximize_window()
driver = setup_webdriver_specification(arguments)
app_starter = AppStarter(driver, config)
app_starter.start_app()
@ -268,6 +222,76 @@ def get_test_modules(arguments):
# Register cleanup function to cleanup on exit
atexit.register(handle_cleanup)
# Load Test modules
module_list = load_modules(arguments, exclude_pkgs)
return module_list
def setup_webdriver_specification(arguments):
"""
Method return web-driver object set up according to values passed
in arguments
:param arguments:
:return: webdriver object
"""
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import \
DesiredCapabilities
default_browser = 'chrome'
# Check default browser provided through command line. If provided
# then use that browser as default browser else check for the
# setting provided in test_config.json file.
if (
'default_browser' in arguments and
arguments['default_browser'] is not None
):
default_browser = arguments['default_browser'].lower()
elif (
test_setup.config_data and
"default_browser" in test_setup.config_data
):
default_browser = test_setup.config_data[
'default_browser'].lower()
if default_browser == 'firefox':
cap = DesiredCapabilities.FIREFOX
cap['requireWindowFocus'] = True
cap['enablePersistentHover'] = False
profile = webdriver.FirefoxProfile()
profile.set_preference("dom.disable_beforeunload", True)
driver_local = webdriver.Firefox(capabilities=cap,
firefox_profile=profile)
driver_local.implicitly_wait(1)
else:
options = Options()
if test_setup.config_data and \
'headless_chrome' in test_setup.config_data and \
test_setup.config_data['headless_chrome']:
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-setuid-sandbox")
options.add_argument("--window-size=1280,1024")
options.add_argument("--disable-infobars")
options.add_experimental_option('w3c', False)
driver_local = webdriver.Chrome(chrome_options=options)
# maximize browser window
driver_local.maximize_window()
return driver_local
def load_modules(arguments, exclude_pkgs):
"""
Method returns list of modules which is formed by removing packages from
exclude_pkgs arguments.
:param arguments:
:param exclude_pkgs:
:return:
"""
from pgadmin.utils.route import TestsGeneratorRegistry
# Load the test modules which are in given package(i.e. in arguments.pkg)
if arguments['pkg'] is None or arguments['pkg'] == "all":
TestsGeneratorRegistry.load_generators('pgadmin', exclude_pkgs)