def get_browsers(): """Returns a dictionary of the browsers TestRail allows a user to set in a test result. Key is a browser's TestRail ID, as a string Value is the name of the browser from by TestRail. """ result_fields = get_result_fields() browser_field = {} browsers = {} # Check the result fields for the browser field for result_field in result_fields: if result_field['system_name'] == 'custom_browser': browser_field = result_field # The browsers are stored as a string, so we need to parse them out into a list browsers_string = browser_field['configs'][0]['options']['items'] browsers_list = browsers_string.split('\n') for browser in browsers_list: key_value_pair = browser.split(',') browsers[key_value_pair[0]] = key_value_pair[1] break else: Tools.log("Browsers could not be obtained from TestRail.") return browsers Tools.log(browsers)
def get_result_fields(): """Returns a list of available test result custom fields. """ request = 'get_result_fields' result = client.send_get(request) Tools.log(result) return result
def get_test_categories(): """Returns a dictionary of the custom test categories TestRail allows a user to classify tests as. Key is the test category's TestRail ID, as a string. Value is the name of the test category from TestRail. """ case_fields = get_case_fields() # case_fields is a list of dictionaries, each dictionary corresponds to a custom category # since these can change, go through each dictionary and check if it is the one for test categories test_category_field = {} test_categories = {} for field in case_fields: if field['system_name'] == 'custom_test_category': test_category_field = field categories_string = test_category_field['configs'][0]['options'][ 'items'] categories_list = categories_string.split('\n') for category in categories_list: key_value = category.split(',') test_categories[str(int(key_value[0]))] = key_value[ 1] # Explanation: String shows, 0004, but when we need the ID to check, it has to be a string of, '4'. break else: Tools.log("Test categories could not be obtained from TestRail.") return test_categories
def test_c18521173(self): test_case_number = "18521173" web_driver = self.fetch_webdriver() try: click_cta_module = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MODULE) SeleniumActions.click_element(web_driver, click_cta_module) Tools.sleep(3) click_edit_button = \ SeleniumActions.fetch_web_element(web_driver, MartindalePageData.IFRAME_EDIT_BUTTON) SeleniumActions.click_element(web_driver, click_edit_button) Tools.sleep(5) web_driver.switch_to.default_content() element_path = CtaModuleData.CTA_MODULE_HEADER web_element = SeleniumActions.find_by_xpath(web_driver, element_path) cta_text = SeleniumActions.read_web_element_text(web_element) try: assert(cta_text == "CALL TO ACTION(CTA)") CommonSetup.report_test_rail(self, test_case_number, TestRailStatus().PASS, '') except: CommonSetup.report_test_rail(self, test_case_number, TestRailStatus().FAIL, '') except: Tools.log("C18521173 Not Tested") e = sys.exc_info()[0] Tools.log("<p>Error: %s</p>" % e)
def teardown_class(self): ''' Will be run once when all tests are complete ''' Tools.log("CTA module test run complete.")
def set_up_class(self): ''' Will be run once first before any test ''' web_driver = self.fetch_webdriver() Tools.log("Executing Blade module tests...") MartindaleNavigation.navigate_to_home_page(web_driver) MartindaleLogin.login_to_app(web_driver) CommonSetup.selected_module = "blade" MartindaleModuleSetup.module_open(web_driver)
def get_test_environments(): """Returns a dictionary of the custom test environments TestRail allows a user to set in a test result. Key is an environment's TestRail ID, as a string. Value is the name of the environment from by TestRail. """ result_fields = get_result_fields() test_env_field = {} test_envs = {} for result_field in result_fields: if result_field['system_name'] == 'custom_test_env': test_env_field = result_field # The environments are stored as a string, so we need to parse them out into a list test_env_string = test_env_field['configs'][0]['options']['items'] test_env_list = test_env_string.split('\n') for test_env in test_env_list: key_value_pair = test_env.split(',') test_envs[key_value_pair[0]] = key_value_pair[1] break else: Tools.log("Test environments could not be obtained from TestRail.") return test_envs