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 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
示例#3
0
    def teardown_class(self):

        '''
        Will be run once when all tests are complete
        '''

        Tools.log("CTA module test run complete.")
示例#4
0
    def test_c18521044(self):

        test_case_number = "18521044"

        web_driver = self.fetch_webdriver()

        try:
            web_element = SeleniumActions.find_by_xpath(
                web_driver, BannerModuleData.ADD_BANNER_CANCEL_BUTTON)
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(3)

            element_path = BannerModuleData.GALLERY_BANNER_TITLE
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18521044 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#5
0
    def test_c18521018(self):

        test_case_number = "18521018"

        web_driver = self.fetch_webdriver()

        try:
            click_add_banner = \
                SeleniumActions.fetch_web_element(web_driver, BannerModuleData.BANNER_MODULE_CONTENT_ADD_BANNER_BUTTON)
            SeleniumActions.click_element(web_driver, click_add_banner)

            Tools.sleep(5)

            element_path = BannerModuleData.BANNER_MODULE_CONTENT_ADD_BANNER
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            add_banner_text = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (add_banner_text == "ADD BANNER")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18521018 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#6
0
    def test_c18521045(self):

        test_case_number = "18521045"

        web_driver = self.fetch_webdriver()

        try:
            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'edit_item-')]")
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(3)

            banner_title = SeleniumActions.fetch_web_element(
                web_driver, BannerModuleData.BANNER_TITLE)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, banner_title))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18521045 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
    def fetch_web_element(web_driver, element_path):
        """Fetches a web element object from a object path. Uses multiple methods to allows for different kinds of paths
        
        :param WebDriver web_driver: 
        :param str element_path:

        :rtype: WebElement
        :return: WebElement
        """
        if Tools.object_has_value(element_path):

            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            if web_element is None:
                web_element = SeleniumActions.find_by_css_path(
                    web_driver, element_path)
            '''
            if web_element is None:
                web_element = SeleniumActions.find_by_id(web_driver, element_path)
    
            if web_element is None:
                web_element = SeleniumActions.find_by_class_name(web_driver, element_path)
            '''

            if web_element is not None:
                return web_element
            else:
                error = "No web element"
                Tools.raise_exception(error)
                return None
        else:
            error = "No element path"
            Tools.raise_exception(error)
            return None
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)
示例#9
0
    def test_c18521041(self):

        test_case_number = "18521041"

        web_driver = self.fetch_webdriver()

        try:
            # CTA Button 1
            element_path = BannerModuleData.BANNER_MODULE_CONTENT_ADD_LINK_TYPE
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            SeleniumActions.select_by_index(web_element, "1")

            Tools.sleep(2)

            element_path = BannerModuleData.BANNER_MODULE_CONTENT_ADD_LINK_PAGE_URL_LABEL
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            link_page_element = SeleniumActions.read_web_element_text(
                web_element)

            # CTA Button 2
            element_path = BannerModuleData.BANNER_MODULE_CONTENT_ADD_LINK_TYPE_TWO
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            SeleniumActions.select_by_index(web_element, "1")

            Tools.sleep(2)

            element_path = BannerModuleData.BANNER_MODULE_CONTENT_ADD_LINK_PAGE_URL_LABEL_TWO
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            link_page_element_two = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (link_page_element == "URL *"
                        and link_page_element_two == "URL *")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18521041 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#10
0
    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 refresh_page(web_driver):
        """Refreshes the page
        
        :param WebDriver web_driver:

        :rtype: bool
        :return: boolean 
        """
        try:
            web_driver.navigate().refresh()
            Tools.sleep(1)
            return True
        except Exception as error:
            return False
示例#12
0
    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 test_select():
    web_driver = SeleniumDriver.fetch_chrome_webdriver()
    url = "http://the-internet.herokuapp.com/dropdown"
    web_driver.get(url)
    element_path = "//select[@id='dropdown']"
    web_element = SeleniumActions.find_by_xpath(web_driver, element_path)

    Tools.sleep(2)
    select_1 = Select(web_element)
    print(len(select_1.options))

    select_1.select_by_visible_text('Option 1')
    Tools.sleep(3)
    print("**")
    select_2 = Select(web_element)
    select_2.select_by_index(2)
    Tools.sleep(3)
    print("--")
    select_3 = Select(web_element)
    select_3.select_by_value("1")
    text = select_3.first_selected_option.text
    print(text)

    Tools.sleep(5)
    web_driver.close()
示例#14
0
    def test_c18521046(self):

        test_case_number = "18521046"

        web_driver = self.fetch_webdriver()

        try:
            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'delete_item-')]")
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(2)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, BannerModuleData.DELETE_BANNER_CONFIRMATION)
            SeleniumActions.element_is_visible(web_driver, web_element)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, BannerModuleData.DELETE_BANNER_CANCEL_BUTTON)
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(2)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'item_item-')]")
            SeleniumActions.element_is_visible(web_driver, web_element)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'delete_item-')]")
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(2)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, BannerModuleData.DELETE_BANNER_OK_BUTTON)
            SeleniumActions.click_element(web_driver, web_element)

            Tools.sleep(4)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'item_item-')]")
            new_banner_test = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (new_banner_test == "Title: Title\nCaption")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

            self.case_teardown()

        except:
            print("C18521230 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#15
0
    def test_c18527976(self):

        test_case_number = "18527976"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()
            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_TITLE)

            click_module_info = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_MODULE_INFORMATION)
            SeleniumActions.click_element(web_driver, click_module_info)

            SeleniumActions.element_is_not_visible(web_element)

            click_module_info = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_MODULE_INFORMATION)
            SeleniumActions.click_element(web_driver, click_module_info)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18527976 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
    def module_open(web_driver):
        web_driver.switch_to.frame(
            web_driver.find_element_by_xpath(
                MartindalePageData.MARTINDALE_IFRAME))

        add_module = SeleniumActions.fetch_web_element(
            web_driver, MartindalePageData.ADD_MODULE_BUTTON)
        SeleniumActions.click_element(web_driver, add_module)

        # Select module button
        if CommonSetup.selected_module == "banner":
            select_banner_module = \
                SeleniumActions.fetch_web_element(web_driver, MartindalePageData.BANNER_MODULE_BUTTON)
            SeleniumActions.click_element(web_driver, select_banner_module)
        elif CommonSetup.selected_module == "blade":
            select_blade_module = \
                SeleniumActions.fetch_web_element(web_driver, MartindalePageData.BLADE_MODULE_BUTTON)
            SeleniumActions.click_element(web_driver, select_blade_module)
        elif CommonSetup.selected_module == "cta":
            select_cta_module = \
                SeleniumActions.fetch_web_element(web_driver, MartindalePageData.CTA_MODULE_BUTTON)
            SeleniumActions.click_element(web_driver, select_cta_module)
        elif CommonSetup.selected_module == "featured":
            select_featured_block_module = \
                SeleniumActions.fetch_web_element(web_driver, MartindalePageData.FEATURED_BLOCKS_MODULE_BUTTON)
            SeleniumActions.click_element(web_driver,
                                          select_featured_block_module)
        else:
            print("Error: Module not found.")

        click_module_radio = \
            SeleniumActions.fetch_web_element(web_driver, MartindalePageData.SAVED_MODULE_RADIO_BUTTON)
        SeleniumActions.click_element(web_driver, click_module_radio)

        element_path = MartindalePageData.MODULE_NAME_DROP_DOWN
        web_element = SeleniumActions.find_by_xpath(web_driver, element_path)

        Tools.sleep(2)

        SeleniumActions.select_by_text(web_element, "automation_only")

        click_submit_button = \
            SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MODULE_SUBMIT_BUTTON)
        SeleniumActions.click_element(web_driver, click_submit_button)

        Tools.sleep(5)
示例#17
0
    def test_c18527977(self):

        test_case_number = "18527977"

        web_driver = self.fetch_webdriver()

        try:
            web_element = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_SELECT_FROM_GALLERY)

            click_module_info = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_MANAGE_CONTENT)
            SeleniumActions.click_element(web_driver, click_module_info)

            Tools.sleep(2)

            try:
                SeleniumActions.element_is_not_visible(web_element)
                test_one = "Passed"
            except:
                test_one = "Failed"

            click_module_info = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_MANAGE_CONTENT)
            SeleniumActions.click_element(web_driver, click_module_info)

            Tools.sleep(2)

            try:
                SeleniumActions.element_is_not_visible(web_element)
                test_two = "Passed"
            except:
                test_two = "Failed"

            if test_one == "Passed" and test_two == "Passed":
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            else:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18527977 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#18
0
    def test_c18521230(self):

        test_case_number = "18521230"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(web_driver, CtaModuleData.CTA_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_cta_settings_button_two = \
                SeleniumActions.fetch_web_element(web_driver, CtaModuleData.CTA_SETTINGS_SHOW_BUTTON_TWO)
            SeleniumActions.click_element(web_driver, click_cta_settings_button_two)

            click_content_tab = SeleniumActions.fetch_web_element(web_driver, CtaModuleData.CTA_CONTENT_TAB)
            SeleniumActions.click_element(web_driver, click_content_tab)

            element_path = CtaModuleData.CTA_MODULE_TWO_LINK_APPEARANCE
            web_element = SeleniumActions.find_by_xpath(web_driver, element_path)

            try:
                assert(SeleniumActions.element_is_visible(web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number, TestRailStatus().PASS, '')
            except AssertionError:
                CommonSetup.report_test_rail(self, test_case_number, TestRailStatus().FAIL, '')

        except:
            print("C18521230 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#19
0
    def test_c18521043(self):

        test_case_number = "18521043"

        web_driver = self.fetch_webdriver()

        try:
            banner_title = SeleniumActions.fetch_web_element(
                web_driver, BannerModuleData.BANNER_TITLE)
            SeleniumActions.clearTextField(web_driver, banner_title)
            SeleniumActions.write_to_element(web_driver, banner_title,
                                             "Automated")

            banner_caption = SeleniumActions.fetch_web_element(
                web_driver, BannerModuleData.BANNER_CAPTION)
            SeleniumActions.clearTextField(web_driver, banner_caption)
            SeleniumActions.write_to_element(web_driver, banner_caption,
                                             "Test")

            click_save_button = \
                SeleniumActions.fetch_web_element(web_driver, BannerModuleData.ADD_BANNER_SAVE_BUTTON)
            SeleniumActions.click_element(web_driver, click_save_button)
            Tools.sleep(4)

            web_element = SeleniumActions.find_by_xpath(
                web_driver, "//*[contains(@id, 'item_item-')]")
            new_banner_test = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (new_banner_test == "Title: Automated\nTest")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18521043 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#20
0
    def test_c18678387(self):

        test_case_number = "18678387"

        web_driver = self.fetch_webdriver()

        try:
            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_DESKTOP_MODULE)

            click_module_visibility = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_MODULE_VISIBILITY)
            SeleniumActions.click_element(web_driver, click_module_visibility)

            Tools.sleep(1)

            SeleniumActions.element_is_not_visible(web_element)

            click_module_visibility = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_MODULE_VISIBILITY)
            SeleniumActions.click_element(web_driver, click_module_visibility)

            Tools.sleep(1)

            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_DESKTOP_MODULE)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678387 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#21
0
    def test_c18678386(self):

        test_case_number = "18678386"

        web_driver = self.fetch_webdriver()

        try:
            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_SWAP_MEDIA_TEXT)

            click_blade_settings = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SETTINGS)
            SeleniumActions.click_element(web_driver, click_blade_settings)

            Tools.sleep(1)

            SeleniumActions.element_is_not_visible(web_element)

            click_blade_settings = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SETTINGS)
            SeleniumActions.click_element(web_driver, click_blade_settings)

            Tools.sleep(1)

            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_SWAP_MEDIA_TEXT)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678386 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#22
0
    def test_c18678391(self):

        test_case_number = "18678391"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)
            click_show_read_more = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_READ_MORE)
            SeleniumActions.click_element(web_driver, click_show_read_more)

            click_show_cta_button_one = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_CTA_ONE)
            SeleniumActions.click_element(web_driver,
                                          click_show_cta_button_one)
            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))

            element_path = BladeModuleData.BLADE_IFRAME_CTA_BUTTON_TWO
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)
            read_cta_button = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (read_cta_button == "CTA TWO")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678391 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#23
0
    def test_c18527973(self):

        test_case_number = "18527973"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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 = BladeModuleData.BLADE_TITLE
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            blade_text = SeleniumActions.read_web_element_text(web_element)

            try:
                assert (blade_text == "BLADE MODULE")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18527973 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
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
示例#25
0
    def login_to_app(web_driver):

        try:
            # Login
            login_username = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MARTINDALE_LOGIN_USERNAME)
            SeleniumActions.write_to_element(web_driver, login_username, MartindalePageData.MARTINDALE_LOGIN_EMAIL)

            login_password = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MARTINDALE_LOGIN_PASSWORD)
            SeleniumActions.write_to_element(web_driver, login_password, MartindalePageData.MARTINDALE_LOGIN_PASS)

            button_login = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.MARTINDALE_LOGIN_BUTTON)
            SeleniumActions.click_element(web_driver, button_login)

            Tools.sleep(2)

            click_pages_tab = SeleniumActions.fetch_web_element(web_driver, MartindalePageData.PAGES_TAB_BUTTON)
            SeleniumActions.click_element(web_driver, click_pages_tab)

            Tools.sleep(2)

            if MartindalePageData.MARTINDALE_URL == "http://my.stg-martindalenolo.com/0004973/site/editor/cms":
                click_automation_edit = \
                    SeleniumActions.fetch_web_element(web_driver, MartindalePageData.AUTOMATION_PAGE_EDIT_BUTTON)
                SeleniumActions.click_element(web_driver, click_automation_edit)
            else:
                click_automation_edit = \
                    SeleniumActions.fetch_web_element(web_driver, MartindalePageData.AUTOMATION_PAGE_EDIT_BUTTON_TWO)
                SeleniumActions.click_element(web_driver, click_automation_edit)

            Tools.sleep(4)

            web_driver.close()
            web_driver.switch_to_window(web_driver.window_handles[0])

        except:
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#26
0
    def test_c18527975(self):

        test_case_number = "18527975"

        web_driver = self.fetch_webdriver()

        try:
            click_content_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_TAB)
            SeleniumActions.click_element(web_driver, click_content_tab)

            Tools.sleep(2)

            write_new_title = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_TITLE)
            SeleniumActions.clearTextField(web_driver, write_new_title)
            SeleniumActions.write_to_element \
                (web_driver, write_new_title, "Blade")

            write_new_caption = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_CAPTION)
            SeleniumActions.clearTextField(web_driver, write_new_caption)
            SeleniumActions.write_to_element \
                (web_driver, write_new_caption, "Runner")

            write_new_alt_text = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_CONTENT_ALT_TEXT)
            SeleniumActions.clearTextField(web_driver, write_new_alt_text)
            SeleniumActions.write_to_element \
                (web_driver, write_new_alt_text, "alt")

            write_new_image_title = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_IMAGE_TITLE)
            SeleniumActions.clearTextField(web_driver, write_new_image_title)
            SeleniumActions.write_to_element \
                (web_driver, write_new_image_title, "image")

            write_new_cta_one_link_text = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_CTA_ONE_LINK_TEXT)
            SeleniumActions.clearTextField(web_driver,
                                           write_new_cta_one_link_text)
            SeleniumActions.write_to_element \
                (web_driver, write_new_cta_one_link_text, "CTA One")

            write_new_cta_two_link_text = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_CONTENT_CTA_TWO_LINK_TEXT)
            SeleniumActions.clearTextField(web_driver,
                                           write_new_cta_two_link_text)
            SeleniumActions.write_to_element \
                (web_driver, write_new_cta_two_link_text, "CTA Two")

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))

            element_path = BladeModuleData.BLADE_IFRAME_TITLE
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            blade_iframe_title = SeleniumActions.read_web_element_text(
                web_element)

            element_path = BladeModuleData.BLADE_IFRAME_CAPTION
            web_element = SeleniumActions.find_by_xpath(
                web_driver, element_path)

            blade_iframe_caption = SeleniumActions.read_web_element_text(
                web_element)

            try:
                assert (blade_iframe_title == "Blade"
                        and blade_iframe_caption == "Runner")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18527975 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#27
0
    def test_c18678393(self):

        test_case_number = "18678393"

        web_driver = self.fetch_webdriver()

        try:
            click_swap_setting = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SWAP_MEDIA_TEXT)
            SeleniumActions.click_element(web_driver, click_swap_setting)

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))
            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_IFRAME_IMAGE_LEFT)

            SeleniumActions.element_is_visible(web_driver, web_element)

            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_swap_setting = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SWAP_MEDIA_TEXT)
            SeleniumActions.click_element(web_driver, click_swap_setting)

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))
            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_IFRAME_IMAGE_RIGHT)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678393 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#28
0
    def test_c18678385(self):

        test_case_number = "18678385"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_show_cta_button_two = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_CTA_TWO)
            SeleniumActions.click_element(web_driver,
                                          click_show_cta_button_two)

            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_TITLE)

            click_element_visibility = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_ELEMENT_VISIBILITY)
            SeleniumActions.click_element(web_driver, click_element_visibility)

            Tools.sleep(1)

            SeleniumActions.element_is_not_visible(web_element)

            click_element_visibility = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_ELEMENT_VISIBILITY)
            SeleniumActions.click_element(web_driver, click_element_visibility)

            Tools.sleep(1)

            web_element = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_TITLE)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678385 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#29
0
    def test_c18678390(self):

        test_case_number = "18678390"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_show_banner_caption = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_CAPTION)
            SeleniumActions.click_element(web_driver,
                                          click_show_banner_caption)

            click_show_read_more = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_READ_MORE)
            SeleniumActions.click_element(web_driver, click_show_read_more)

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))

            if SeleniumActions.check_element_exists \
                        (web_driver, "//*[@id=\"ple_column-0\"]/div[3]/div/div/div/div/div[1]/div[2]/a"):
                blade_title_existence = "true"
            else:
                blade_title_existence = "false"

            try:
                assert (blade_title_existence == "false")
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            except:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678390 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)
示例#30
0
    def test_c18678389(self):

        test_case_number = "18678389"

        web_driver = self.fetch_webdriver()

        try:
            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_show_banner_title = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_TITLE)
            SeleniumActions.click_element(web_driver, click_show_banner_title)

            click_show_banner_caption = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_CAPTION)
            SeleniumActions.click_element(web_driver,
                                          click_show_banner_caption)

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))

            try:
                assert (SeleniumActions.check_element_exists(
                    web_driver,
                    "//*[@id=\"ple_column-0\"]/div[3]/div/div/div/div/div[1]/div[1]/h4"
                ))
                test_one = "Failed"
            except:
                test_one = "Passed"

            click_blade_module = SeleniumActions.fetch_web_element(
                web_driver, MartindalePageData.MODULE)
            SeleniumActions.click_element(web_driver, click_blade_module)

            Tools.sleep(2)

            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()

            click_settings_tab = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_SETTINGS_TAB)
            SeleniumActions.click_element(web_driver, click_settings_tab)

            click_show_banner_title = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_TITLE)
            SeleniumActions.click_element(web_driver, click_show_banner_title)

            click_show_banner_caption = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_SETTINGS_SHOW_BLADE_CAPTION)
            SeleniumActions.click_element(web_driver,
                                          click_show_banner_caption)

            click_done_button = SeleniumActions.fetch_web_element(
                web_driver, BladeModuleData.BLADE_DONE_BUTTON)
            SeleniumActions.click_element(web_driver, click_done_button)

            Tools.sleep(5)

            web_driver.switch_to.frame(
                web_driver.find_element_by_xpath(
                    MartindalePageData.MARTINDALE_IFRAME))

            Tools.sleep(2)

            web_element = \
                SeleniumActions.fetch_web_element(web_driver, BladeModuleData.BLADE_IFRAME_CAPTION)

            try:
                assert (SeleniumActions.element_is_visible(
                    web_driver, web_element))
                test_two = "Passed"
            except:
                test_two = "Failed"

            if test_one == "Passed" and test_two == "Passed":
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().PASS, '')
            else:
                CommonSetup.report_test_rail(self, test_case_number,
                                             TestRailStatus().FAIL, '')

        except:
            print("C18678389 Not Tested")
            e = sys.exc_info()[0]
            print("<p>Error: %s</p>" % e)