Ejemplo n.º 1
0
 def view_on_portal_link_test(self):
     try:
         utilities.wait(5)
         utilities.click_element(self.driver, By.CSS_SELECTOR,
                                 locators.VIEW_ON_PORTAL_LINK_CSS)
         utilities.wait(5)
         utilities.switch_to_latest_tab(self.driver)
         utilities.wait(7)
         lcc.log_info(
             "Find the CP preview in the attachment below for debugging purposes"
         )
         self.driver.save_screenshot("cp_preview_module.png")
         lcc.save_attachment_file("cp_preview_module.png")
         check_that("View on Portal URL path", self.driver.current_url,
                    contains_string(constants.view_on_portal_page_url))
         module_id_regex = re.compile(
             r'^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$'
         )
         current__module_id = self.driver.current_url.split("/topic/")[1]
         check_that("View on Portal URL id", current__module_id,
                    match_pattern(module_id_regex))
         # content_body_on_portal = utilities.find_element(self.driver, By.CSS_SELECTOR, locators.MODULE_BODY_ON_PORTAL_CSS)
     except (TimeoutException, StaleElementReferenceException,
             NoSuchElementException) as e:
         lcc.log_error("Error finding element!!!")
         lcc.log_error(e)
     finally:
         if (len(self.driver.window_handles) > 1):
             self.driver.close()
             utilities.switch_to_first_tab(self.driver)
Ejemplo n.º 2
0
def find_elements_by_css_selector(driver, locator):
    try:
        elements_list_by_css_selector = driver.find_elements(
            By.CSS_SELECTOR, locator)
    except NoSuchElementException as e:
        lcc.log_error(str(e))
    return elements_list_by_css_selector
Ejemplo n.º 3
0
 def product_info_on_customer_portal(self):
     utilities.wait(5)
     utilities.page_reload(self.driver)
     utilities.click_element(self.driver, By.PARTIAL_LINK_TEXT,
                             "View on Customer Portal")
     try:
         utilities.wait(5)
         utilities.switch_to_latest_tab(self.driver)
         utilities.wait(6)
         updated_date_on_portal = utilities.find_shadow_dom_element(
             self.driver, locators.UPDATED_DATE_ON_PORTAL_CSS,
             locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                 "textContent")
         check_that("updated date reflected on view page",
                    updated_date_on_portal,
                    contains_string(self.first_pub_date_details_page))
         published_date_on_portal = utilities.find_shadow_dom_element(
             self.driver, locators.PUBLISHED_DATE_ON_PORTAL_CSS,
             locators.MODULE_BODY_ON_PORTAL_CSS).get_attribute(
                 "textContent")
         check_that("published date reflected on view page",
                    published_date_on_portal,
                    contains_string(self.last_pub_date_details_page))
     except (TimeoutException, StaleElementReferenceException,
             NoSuchElementException) as e:
         lcc.log_error(
             "Some problem accessing the Customer Portal, please check.")
         lcc.log_error(e)
     finally:
         if (len(self.driver.window_handles) > 1):
             self.driver.close()
             utilities.switch_to_first_tab(self.driver)
 def search_for_body_of_module(self):
     try:
         utilities.find_elements_by_id(self.driver,
                                       locators.SEARCH_BOX_ID).clear()
         utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID,
                              constants.body_of_module_search)
         utilities.click_element(self.driver, By.CSS_SELECTOR,
                                 locators.SEARCH_BUTTON_CSS)
         utilities.wait(2)
         utilities.click_element(self.driver, By.XPATH,
                                 locators.SEARCH_MODULE_XPATH)
         utilities.wait(2)
         utilities.click_element(self.driver, By.CSS_SELECTOR,
                                 locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
         utilities.wait(2)
         utilities.switch_to_latest_tab(self.driver)
         body_of_module_on_preview = utilities.find_shadow_dom_element(
             self.driver, locators.SEARCH_BODY_ON_PREVIEW_CSS,
             locators.MODULE_BODY_CSS).text
         check_that("content of module is displayed",
                    body_of_module_on_preview,
                    contains_string(constants.body_of_module_search))
         utilities.wait(2)
     except (TimeoutException, StaleElementReferenceException,
             NoSuchElementException) as e:
         lcc.log_error("Error finding element: %s" % e)
         lcc.log_error(e)
     finally:
         self.driver.close()
         utilities.switch_to_first_tab(self.driver)
Ejemplo n.º 5
0
def find_elements_by_class_name(driver, locator):
    try:
        elements_list_by_class = WebDriverWait(driver, 30).until(
            ec.visibility_of_all_elements_located((By.CLASS_NAME, locator)))
    except TimeoutException as e:
        lcc.log_error("Element not found after 30 sec wait!!!")
        lcc.log_error(str(e))
    return elements_list_by_class
Ejemplo n.º 6
0
def get_shadow_root(driver, shadow_root_parent):
    try:
        shadow_host = find_element(driver, By.CSS_SELECTOR, shadow_root_parent)
    except (TimeoutException, NoSuchElementException) as e:
        lcc.log_error(e)
    else:
        root_ele = driver.execute_script("return arguments[0].shadowRoot",
                                         shadow_host)
        return root_ele
Ejemplo n.º 7
0
 def setup_suite(self):
     # Check status of connection
     lcc.set_step("Open connection")
     if self.__ws is not None:
         lcc.log_url(ECHO_DEV)
         lcc.log_info("Connection successfully created")
         self.__login_echo()
     else:
         lcc.log_error("Connection not established")
Ejemplo n.º 8
0
 def _login_status(response):
     # Check authorization status
     try:
         if response["result"]:
             lcc.log_info("Login successful")
         else:
             lcc.log_info("Login failed")
     except KeyError:
         lcc.log_error("Login failed")
Ejemplo n.º 9
0
def wait_for_element(driver, locator_type, locator_value):
    try:
        wait = WebDriverWait(driver, 45)
        element = wait.until(
            ec.visibility_of_element_located((locator_type, locator_value)))
    except TimeoutException or StaleElementReferenceException as e:
        lcc.log_error(str(e))
        raise NoSuchElementException(
            "Element not displayed on page for the locator::" + locator_type +
            "->" + locator_value)
    else:
        return element
Ejemplo n.º 10
0
    def product_info_on_view_page(self):
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS)
        try:
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(2)
            product_name = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_NAME_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            check_that("Product name reflected on view page", product_name,
                       contains_string(constants.product_name))
            product_version = utilities.find_shadow_dom_element(
                self.driver, locators.PRODUCT_VERSION_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text
            check_that("Product version reflected on view page",
                       product_version,
                       contains_string(constants.product_version))
            updated_date_view_page = utilities.find_shadow_dom_element(
                self.driver, locators.UPDATED_DATE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text.strip("Updated ")
            check_that("updated date reflected on view page",
                       updated_date_view_page,
                       contains_string(self.first_pub_date_details_page))
            published_date_view_page = utilities.find_shadow_dom_element(
                self.driver, locators.PUBLISHED_DATE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS).text.strip("Published ")
            check_that("published date reflected on view page",
                       published_date_view_page,
                       contains_string(self.last_pub_date_details_page))
            legal_notice = utilities.find_shadow_dom_element(
                self.driver, locators.LEGAL_NOTICE_ON_PREVIEW_CSS,
                locators.MODULE_BODY_CONTENT_CSS)
            check_that(
                "legal notice is displayed at the bottom of preview page",
                legal_notice.text,
                contains_string("Legal Notices for Trademarks"))
            legal_notice_href = legal_notice.get_attribute("href")
            check_that("verify legal notice link", legal_notice_href,
                       contains_string(constants.legal_notice_link))

        except (TimeoutException, StaleElementReferenceException,
                NoSuchElementException) as e:
            lcc.log_error("Element could not be located!!!")
            lcc.log_error(e)
        finally:
            if (len(self.driver.window_handles) > 1):
                self.driver.close()
                utilities.switch_to_first_tab(self.driver)
Ejemplo n.º 11
0
 def prepare_attach_to_report(kind, filename, file_description, data):
     try:
         if kind == "file":
             lcc.set_step("Prepare attachment file")
             with lcc.prepare_attachment(filename, file_description) \
                     as file:
                 with open(file, "w") as fh:
                     fh.write(data)
         elif kind == "image":
             lcc.set_step("Prepare image attachment")
             with lcc.prepare_image_attachment(filename, file_description) \
                     as file:
                 with open(file, "w") as fh:
                     fh.write(data)
     except FileNotFoundError:
         lcc.log_error("File or image does not exist!")
Ejemplo n.º 12
0
 def add_file_to_report(self, kind, filename, file_description, data=None):
     try:
         if kind == "file" and data is None:
             lcc.set_step("Attachment file")
             lcc.save_attachment_file(
                 self.get_file_attachment_path(filename), file_description)
         elif kind == "image" and data is None:
             lcc.set_step("Image attachment")
             lcc.save_image_file(self.get_file_attachment_path(filename),
                                 file_description)
         elif kind == "file" and data is not None:
             lcc.set_step("Attachment file content")
             lcc.save_attachment_content(data, filename, file_description)
         elif kind == "image" and data is not None:
             lcc.set_step("Image attachment content")
             lcc.save_image_content(data, filename, file_description)
     except FileNotFoundError:
         lcc.log_error("File or image does not exist!")
Ejemplo n.º 13
0
 def __call_method(self, method, call_back=None):
     # Returns the api method call
     self.__api_id += 1
     call_template = self.get_template()
     try:
         if call_back is None:
             call_template["id"] = self.__api_id
             call_template["params"] = method
             return call_template
         else:
             call_template["id"] = self.__api_id
             call_template["params"].append(call_back)
             for i in range(1, len(method)):
                 try:
                     call_template["params"].append(method[i])
                 except IndexError:
                     lcc.log_error("This index does not exist!")
             return call_template
     except KeyError:
         lcc.log_error("That key does not exist!")
 def help_doc(self):
     try:
         utilities.wait(2)
         utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_SEARCH_PAGE_LINK_TEXT)
         utilities.page_reload(self.driver)
         utilities.wait(1)
         utilities.click_element(self.driver, By.CSS_SELECTOR, locators.HELP_ICON_CLASS_NAME)
         utilities.click_element(self.driver, By.LINK_TEXT, locators.USER_GUIDE_LINK_TEXT)
         utilities.wait(2)
         utilities.switch_to_latest_tab(self.driver)
         lcc.log_info(self.driver.current_url)
         check_that("page url", self.driver.current_url, contains_string(constants.help_user_guide_url))
         title_of_user_guide = utilities.find_shadow_dom_element(self.driver,
                                                                 locators.TITLE_OF_USER_GUIDE_CSS,
                                                                 locators.USER_GUIDE_PARENT_CSS).text
         check_that("title of the page", title_of_user_guide, contains_string("Help"))
     except (TimeoutException, NoSuchElementException) as e:
         lcc.log_error(e)
     finally:
         self.driver.close()
         utilities.switch_to_first_tab(self.driver)
def filter_by_content_type(driver, module_type):
    module_type = module_type.upper()
    if module_type == "CONCEPT":
        locator = locators.CONCEPT_CHECKBOX_ID
    elif module_type == "PROCEDURE":
        locator = locators.PROCEDURE_CHECKBOX_ID
    elif module_type == "REFERENCE":
        locator = locators.REFERENCE_CHECKBOX_ID
    else:
        lcc.log_error("Invalid module type!!!")
    utilities.wait(2)
    utilities.click_element(driver, By.CSS_SELECTOR,
                            locators.MODULE_TYPE_DROPDOWN_CSS)
    utilities.click_element(driver, By.ID, locator)
    # utilities.select_value_from_dropdown(driver, By.CSS_SELECTOR, locators.MODULE_TYPE_DROPDOWN_CSS, module_type)
    chips = get_filter_chip_list(driver)
    print(chips)
    print(module_type)
    check_that("Filter chips listed", chips, has_item(module_type))
    poll(lambda: utilities.find_element(driver, By.CSS_SELECTOR, locators.
                                        NO_ASSEMBLY_RESULTS_FOUND_CSS).
         is_displayed() == True,
         step=0.5,
         timeout=10)
Ejemplo n.º 16
0
 def fixt():
     yield
     lcc.log_error("some error")
Ejemplo n.º 17
0
 def fixt():
     lcc.log_error("some error")
Ejemplo n.º 18
0
 def teardown_suite(self):
     lcc.log_error("something bad happened")
Ejemplo n.º 19
0
 def setup_suite(self):
     lcc.log_error("something bad happened")
Ejemplo n.º 20
0
 def test_2(self):
     lcc.log_error("some error message")
Ejemplo n.º 21
0
 def func():
     check_that("value", "foo", equal_to("foo"))
     lcc.log_error("something")
Ejemplo n.º 22
0
 def func():
     lcc.log_error("something")
Ejemplo n.º 23
0
 def third_test(self):
     lcc.log_error("something goes wrong")
Ejemplo n.º 24
0
 def teardown_suite(self):
     lcc.log_error("some error")
Ejemplo n.º 25
0
 def setup_suite(self):
     lcc.log_error("some error")
Ejemplo n.º 26
0
 def test1(self):
     lcc.log_error("some error")
Ejemplo n.º 27
0
 def test_2(self):
     lcc.log_error("error")
Ejemplo n.º 28
0
 def mytest1(self):
     lcc.log_error("failure")
Ejemplo n.º 29
0
def find_elements_by_id(driver, locator):
    try:
        element_list = driver.find_elements_by_id(locator)
    except NoSuchElementException as e:
        lcc.log_error(str(e))
    return element_list
Ejemplo n.º 30
0
def find_elements_by_XPATH(driver, locator):
    try:
        elements_list_by_XPATH = driver.find_elements(By.XPATH, locator)
    except NoSuchElementException as e:
        lcc.log_error(str(e))
    return elements_list_by_XPATH