def no_repo_selected(self):
     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)
     # clicking on filter funnel icon twice to close and re-open the filter by repo pannel
     utilities.click_element(self.driver, By.ID, locators.TOGGLE_ID)
     utilities.wait(1)
     utilities.click_element(self.driver, By.ID, locators.TOGGLE_ID)
     utilities.wait(1)
     check_that(
         "Filter by repo section is displayed",
         utilities.find_element(
             self.driver, By.CLASS_NAME,
             locators.FILTER_BY_REPO_SECTION_CLASS_NAME).is_displayed(),
         is_true())
     check_that(
         "No results found warning message",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.NO_MODULE_RESULTS_FOUND_CSS),
         contains_string(constants.no_results_found))
     utilities.click_element(self.driver, By.XPATH,
                             locators.FILTER_BY_REPO_TOGGLE_XPATH)
     utilities.wait(1)
     utilities.click_element(self.driver, By.XPATH,
                             locators.FILTER_BY_REPO_TOGGLE_XPATH)
     utilities.wait(1)
     check_that(
         "Repository list is displayed after expanding Filter by Repo",
         utilities.find_element(self.driver, By.XPATH,
                                locators.REPO_LIST_XPATH).is_displayed(),
         is_true())
 def select_product_and_version_filter(self):
     utilities.click_element(self.driver, By.LINK_TEXT, "Search")
     utilities.wait(2)
     utilities.select_value_from_dropdown(self.driver, By.CSS_SELECTOR,
                                          locators.SELECT_PRODUCT_NAME_CSS,
                                          constants.product_name)
     utilities.select_value_from_dropdown(
         self.driver, By.CSS_SELECTOR, locators.SELECT_PRODUCT_VERSION_CSS,
         constants.product_version)
     lcc.log_info(
         "product and version selected and displayed on search page")
     utilities.find_element(
         self.driver, By.XPATH,
         locators.PRODUCT_FILTER_DISPLAY_XPATH).is_displayed()
     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)
     check_that(
         "verify that 'filter by product and version' functionality filters results correctly",
         utilities.get_text(self.driver, By.XPATH,
                            locators.PRODUCT_VERSION_DISPLAY_PAGE_XPATH),
         contains_string(constants.product_name + " " +
                         constants.product_version))
 def invalid_product_version_url_fragment(self):
     #Verify invalid input for url fragment
     utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_1)
     utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID, "#")
     check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                contains_string(constants.version_url_fragment_warning))
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)
     utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
 def create_product_blank_version(self):
     # utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_NEW_PRODUCT_LINK_TEXT)
     lcc.log_info("Product name input: %s " % product_name)
     # Reload new product to clear old values
     utilities.page_reload(self.driver)
     utilities.wait(3)
     # Fill new product form
     utilities.enter_text(self.driver, By.ID, locators.PRODUCT_NAME_TEXTBOX_ID, product_name)
     utilities.enter_text(self.driver, By.ID, locators.PRODUCT_URL_FRAGMENT_TEXTBOX_ID, constants.url_fragment)
     utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
     utilities.enter_text(self.driver, By.ID, locators.PRODUCT_VERSION_URL_FRAGMENT_ID, constants.product_version)
     utilities.enter_text(self.driver, By.ID, locators.PRODUCT_DESCRIPTION_TEXTBOX_ID, constants.new_product_description)
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS)
     check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                contains_string(constants.blank_product_name_warning))
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)
 def create_product_versions(self):
     # User adds versions to the 'Add Product versions' and verifies if the versions were added successfully.
     utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_1)
     utilities.enter_text(self.driver,By.ID,locators.VERSION_URL_FRAGMENT_ID,
                          constants.product_version_url_fragment_1)
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
     utilities.wait(3)
     utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
     utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_2)
     utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID,
                          constants.product_version_url_fragment_2)
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
     utilities.wait(3)
     utilities.find_element(self.driver, By.ID,locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
     utilities.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version_3)
     utilities.enter_text(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID,
                          constants.product_version_url_fragment_3)
     utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
     utilities.wait(3)
     utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
     versions_ul = utilities.find_element(self.driver, By.CLASS_NAME, locators.PRODUCT_VERSIONS_UL_CLASS_NAME)
     versions_list = versions_ul.find_elements_by_tag_name(locators.PRODUCT_VERSIONS_LI_TAG_NAME)
     versions = []
     for version in versions_list:
         versions.append(version.text)
     lcc.log_info("Versions added: %s" % str(versions))
     check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_1))
     check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_2))
     check_that("Product version entered is added successfully ", versions, has_item(constants.product_version_3))
    def blank_product_versions(self):
        utilities.click_element(self.driver, By.XPATH, locators.MENU_PRODUCTS_LINK_XPATH)
        utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_PRODUCT_LISTING_LINK_TEXT)
        # User clicks on 'Product details' button for the product created above.
        lcc.log_info("Product name to add versions for: %s " % product_name)
        utilities.wait(10)
        products = utilities.find_elements_by_class_name(self.driver, locators.PRODUCT_NAMES_LIST_CLASS_NAME)
        lcc.log_info("Number of products found in the list %s" % str(len(products)))
        for product in products:
            if product_name in product.text:
                lcc.log_info("Adding versions to %s" % product.text)
                product.find_element_by_class_name("pf-c-options-menu").click()
                lcc.log_info("Clicking on the dropdown to add product details")
                product.find_element_by_class_name(locators.PRODUCT_DETAILS_BUTTON_CLASS_NAME).click()
                break

        #Verify blank product version and url fragment
        utilities.find_element(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID).clear()
        utilities.find_element(self.driver, By.ID, locators.VERSION_URL_FRAGMENT_ID).clear()
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.PRODUCT_VERSION_SAVE_BUTTON_CSS)
        check_that("Warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS),
                   contains_string(constants.blank_product_name_warning))
        utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)
 def modules_bulk_unpublish(self):
     poll(lambda: len(
         utilities.find_elements_by_css_selector(self.driver, locators.
                                                 MODULES_LIST_CSS)) == 4,
          ignore_exceptions=[NoSuchElementException],
          timeout=5,
          step=0.5)
     utilities.wait(3)
     utilities.click_element(self.driver, By.XPATH,
                             locators.MODULES_SELECT_ALL_TITLE_XPATH)
     utilities.wait(3)
     # Deselect first title
     utilities.click_element(self.driver, By.XPATH,
                             locators.FIRST_MODULE_CHECKBOX_XPATH)
     utilities.wait(2)
     bulk_unpublish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                             locators.BULK_UNPUBLISH_CSS)
     bulk_unpublish.click()
     check_that(
         "Confirmation modal title",
         utilities.get_text(self.driver,
                            By.CSS_SELECTOR, locators.MODAL_TITLE_CSS),
         equal_to("Unpublish"))
     check_that(
         "Count of modules being unpublished",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.TITLES_FOR_UNPUBLISH_CSS),
         contains_string("3"))
     utilities.click_element(self.driver, By.CSS_SELECTOR,
                             locators.CONFIRM_BUTTON_CSS)
     poll(lambda: utilities.get_text(self.driver, By.CSS_SELECTOR, locators.
                                     PROGRESS_SUCCESS_STATUS) == "100%",
          ignore_exceptions=[NoSuchElementException],
          timeout=20,
          step=1)
     utilities.click_element(self.driver, By.XPATH,
                             locators.VIEW_DETAILS_LINK)
     modules_updated = utilities.find_elements_by_css_selector(
         self.driver, locators.UPDATED_TITLES_LIST_CSS)
     check_that("Count of successfully updated modules",
                len(modules_updated), equal_to(3))
     check_that(
         "Failed modules section text",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FAILED_TITLES_LIST_CSS),
         equal_to("n/a"))
     utilities.click_element(self.driver, By.XPATH,
                             locators.CLOSE_DETAILS_XPATH)
     utilities.click_element(self.driver, By.CSS_SELECTOR,
                             locators.CLOSE_STATUS_ALERT)
def open_module_display_page(driver, title):
    print("Inside open module display page")
    try:
        print("Title::" + title)
        utilities.wait(3)
        ele = utilities.find_element(driver, By.LINK_TEXT, title)
        print(ele.get_attribute("href"))
        ele.click()
        utilities.wait(5)
    except Exception as e:
        print("In except...")
        # If the title is not found on the first page, search for the title and then click
        lcc.log_info(e)
        lcc.log_info(
            "Module not listed on listed in the results after applying module type filter."
        )
        lcc.log_info("Searching for the module title now...")
        search_beta_page.search_module_and_click(driver, title)
 def published_title_add_metadata(self):
     utilities.click_element(self.driver, By.XPATH,
                             locators.FIRST_MODULE_CHECKBOX_XPATH)
     utilities.wait(2)
     bulk_edit_metadata = utilities.find_element(
         self.driver, By.XPATH, locators.BULK_EDIT_METADATA_XPATH)
     bulk_edit_metadata.click()
     utilities.wait(2)
     search_beta_page.add_bulk_metadata(self.driver)
     utilities.wait(2)
     check_that(
         "Alert message displayed when trying to add metadata to published title",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.ALERT_TITLE_CSS),
         equal_to(constants.error_message_on_edit_metadata))
     utilities.click_element(self.driver, By.XPATH,
                             locators.CLOSE_DETAILS_XPATH)
     utilities.wait(15)
     lcc.log_info("End of tests, executing teardown")
Esempio n. 10
0
 def no_product_info_publish_module(self):
     utilities.click_element(self.driver, By.LINK_TEXT, "Search")
     utilities.page_reload(self.driver)
     # # Click on the title if it is displayed on the first page
     utilities.wait(5)
     # search_page.search_for_module_and_click(self.driver, constants.unpublished_module)
     search_beta_page.select_repo(self.driver, fixture.repo_name)
     search_beta_page.search_module_and_click(self.driver,
                                              constants.unpublished_module)
     utilities.wait(5)
     tooltip_icon = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                           locators.NO_URL_TOOLTIP_ICON)
     check_that("No url tooltip icon is displayed",
                tooltip_icon.is_displayed(), is_true())
     utilities.click_element(self.driver, By.ID,
                             locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
     check_that(
         "Button contains text",
         utilities.get_text(self.driver, By.ID,
                            locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID),
         contains_string("Publish"))
    def select_repo_filter(self):
        search_beta_page.select_repo(self.driver, self.repo_name)
        utilities.wait(1)
        utilities.find_element(self.driver, By.CSS_SELECTOR,
                               locators.REPOSITORY_CHECKBOX_CSS).is_selected()
        check_that(
            "Repository name displayed correctly on right side panel",
            utilities.get_text(self.driver, By.XPATH,
                               locators.REPOSITORY_NAME_XPATH),
            equal_to(self.repo_name))
        check_that(
            "Modules section has data displayed for selected repo",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.MODULES_CSS).is_displayed(),
            is_true())
        check_that(
            "Assemblies section has data displayed for selected repo",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.ASSEMBLY_CSS).is_displayed(),
            is_true())

        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        check_that(
            "Modules section is collapsible",
            utilities.find_element(
                self.driver, By.XPATH,
                locators.MODULE_ASSEMBLY_TOGGLE_XPATH).is_displayed(),
            is_true())
        utilities.click_element(self.driver, By.XPATH,
                                locators.MODULES_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.ASSEMBLY_TOGGLE_BUTTON_XPATH)
        utilities.wait(1)
        check_that(
            "Assemblies section is collapsible",
            utilities.find_element(
                self.driver, By.XPATH,
                locators.MODULE_ASSEMBLY_TOGGLE_XPATH).is_displayed(),
            is_true())
        utilities.wait(1)
        utilities.click_element(self.driver, By.XPATH,
                                locators.ASSEMBLY_TOGGLE_BUTTON_XPATH)
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)
 def filters_on_search_page(self):
     utilities.click_element(self.driver, By.CLASS_NAME,
                             locators.STATUS_FILTER_CLASS_NAME)
     utilities.click_element(self.driver, By.CLASS_NAME,
                             locators.DRAFT_STATUS_CLASS_NAME)
     check_that(
         "Draft Status filter chip is displayed on search page",
         utilities.find_element(
             self.driver, By.CLASS_NAME,
             locators.STATUS_TOOLBAR_CHIP_CLASS_NAME).is_displayed(),
         is_true())
     last_published_date_list = utilities.find_elements_by_XPATH(
         self.driver, locators.LAST_PUBLISHED_DATE_XPATH)
     published_date_list = []
     for i in last_published_date_list:
         published_date_list.append(i.text)
     for i in published_date_list:
         check_that(
             "Published date for all titles should be '-' when draft status filter is selected",
             i, contains_string("-"))
     utilities.click_element(self.driver, By.CSS_SELECTOR,
                             locators.CLEAR_ALL_FILTER_CSS)
     utilities.wait(1)
     search_beta_page.search_module_and_click(self.driver,
                                              constants.publish_module)
     utilities.wait(1)
     display_module_page.add_metadata_and_publish(self.driver)
     utilities.wait(2)
     utilities.click_element(self.driver, By.LINK_TEXT, "Search")
     search_beta_page.select_repo(self.driver, self.repo_name)
     utilities.wait(2)
     utilities.click_element(self.driver, By.CLASS_NAME,
                             locators.STATUS_FILTER_CLASS_NAME)
     utilities.click_element(self.driver, By.CLASS_NAME,
                             locators.PUBLISHED_STATUS_CLASS_NAME)
     utilities.wait(2)
     check_that(
         "Published module is filtered",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FIRST_MODULE_LISTED_CSS),
         contains_string(constants.publish_module))
     check_that(
         "Green check is displayed for published module",
         utilities.find_element(
             self.driver, By.CLASS_NAME,
             locators.GREEN_CHECK_CLASS_NAME).is_displayed(), is_true())
     utilities.wait(3)
     utilities.click_element(self.driver, By.CSS_SELECTOR,
                             locators.CLEAR_ALL_FILTER_CSS)
     utilities.wait(1)
     utilities.click_element(self.driver, By.CLASS_NAME,
                             locators.CONTENT_TYPE_CLASS_NAME)
     utilities.click_element(
         self.driver, By.CLASS_NAME,
         locators.CONCEPT_CONTENT_TYPE_FILTER_CLASS_NAME)
     check_that(
         "Content Type filter chip is displayed on search page",
         utilities.find_element(
             self.driver, By.CLASS_NAME,
             locators.STATUS_TOOLBAR_CHIP_CLASS_NAME).is_displayed(),
         is_true())
     utilities.wait(3)
     check_that(
         "'Concept' content type filter is selected",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FIRST_MODULE_LISTED_CSS),
         contains_string("Concept"))
     utilities.wait(1)
     utilities.click_element(
         self.driver, By.CLASS_NAME,
         locators.CONCEPT_CONTENT_TYPE_FILTER_CLASS_NAME)
     utilities.click_element(
         self.driver, By.CLASS_NAME,
         locators.PROCEDURE_CONTENT_TYPE_FILTER_CLASS_NAME)
     utilities.wait(3)
     check_that(
         "'Procedure' content type filter is selected",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FIRST_MODULE_LISTED_CSS),
         contains_string("Procedure"))
     utilities.wait(1)
     utilities.click_element(
         self.driver, By.CLASS_NAME,
         locators.PROCEDURE_CONTENT_TYPE_FILTER_CLASS_NAME)
     utilities.click_element(
         self.driver, By.CLASS_NAME,
         locators.REFERENCE_CONTENT_TYPE_FILTER_CLASS_NAME)
     utilities.wait(3)
     check_that(
         "'Reference' content type filter is selected",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FIRST_MODULE_LISTED_CSS),
         contains_string("Reference"))
     utilities.wait(2)
 def modules_bulk_edit_metadata(self):
     utilities.click_element(self.driver, By.LINK_TEXT,
                             locators.MENU_SEARCH_PAGE_LINK_TEXT)
     utilities.page_reload(self.driver)
     search_beta_page.select_repo(self.driver, fixture.repo_name)
     search_beta_page.search_titles(self.driver,
                                    constants.bulk_operations_modules)
     poll(lambda: len(
         utilities.find_elements_by_css_selector(self.driver, locators.
                                                 MODULES_LIST_CSS)) == 4,
          ignore_exceptions=[NoSuchElementException],
          timeout=5,
          step=0.5)
     utilities.click_element(self.driver, By.XPATH,
                             locators.MODULES_SELECT_ALL_TITLE_XPATH)
     bulk_edit_metadata = utilities.find_element(
         self.driver, By.XPATH, locators.BULK_EDIT_METADATA_XPATH)
     bulk_publish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                           locators.BULK_PUBLISH_CSS)
     bulk_unpublish = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                             locators.BULK_UNPUBLISH_CSS)
     check_that("Edit metadata button is enabled after selecting modules",
                bulk_edit_metadata.get_attribute("aria-disabled"),
                equal_to("false"))
     check_that("Publish button is enabled after selecting modules",
                bulk_publish.get_attribute("aria-disabled"),
                equal_to("false"))
     check_that("Unpublish button is enabled after selecting modules",
                bulk_unpublish.get_attribute("aria-disabled"),
                equal_to("false"))
     bulk_edit_metadata.click()
     check_that(
         "Edit metadata modal title",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.EDIT_METADATA_MODAL_TITLE),
         equal_to("Edit Metadata"))
     check_that(
         "Count of selected titles",
         utilities.get_text(self.driver, By.ID,
                            locators.SELECTED_MODULES_COUNT_ID),
         contains_string("4"))
     search_beta_page.add_bulk_metadata(self.driver)
     poll(lambda: utilities.get_text(self.driver, By.CSS_SELECTOR, locators.
                                     PROGRESS_SUCCESS_STATUS) == "100%",
          ignore_exceptions=[NoSuchElementException],
          timeout=20,
          step=1)
     utilities.wait(3)
     utilities.click_element(self.driver, By.XPATH,
                             locators.VIEW_DETAILS_LINK)
     utilities.wait(3)
     modules_updated = utilities.find_elements_by_css_selector(
         self.driver, locators.UPDATED_TITLES_LIST_CSS)
     check_that("Count of successfully updated modules",
                len(modules_updated), equal_to(4))
     check_that(
         "Skipped modules section text",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.SKIPPED_TITLE_LIST_CSS),
         equal_to("n/a"))
     check_that(
         "Failed modules section text",
         utilities.get_text(self.driver, By.CSS_SELECTOR,
                            locators.FAILED_TITLES_LIST_CSS),
         equal_to("n/a"))
     utilities.click_element(self.driver, By.XPATH,
                             locators.CLOSE_DETAILS_XPATH)
     utilities.click_element(self.driver, By.CSS_SELECTOR,
                             locators.CLOSE_STATUS_ALERT)
    def upload_repo_again(self):
        lcc.log_info("Uploaded the repo again")
        os.chdir(fixture.project_dir_git)
        repo = Repo(fixture.project_dir_git)
        git = repo.git
        git.checkout("at-uploader2")
        subprocess.check_call(
            ('pantheon --user={} --password={} --server={} push'.format(
                uploader_username, uploader_password, url)),
            shell=True)
        # search_page.search_for_module_and_click(self.driver, constants.published_module)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.assembly_new_draft_version + " 2")
        check_that(
            "Draft card is displayed",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.DRAFT_CARD).is_displayed(),
            is_true())
        check_that(
            "Published card is displayed",
            utilities.find_element(self.driver, By.CSS_SELECTOR,
                                   locators.PUBLISHED_CARD).is_displayed(),
            is_true())

        # Modify the datetime string to be in same format as datetime.now()
        draft_date1 = (utilities.find_element(
            self.driver, By.CSS_SELECTOR,
            locators.UPLOAD_TIME_ON_DRAFT_CARD).text)
        draft_date2 = draft_date1.split("GMT")
        pub_date1 = (utilities.find_element(
            self.driver, By.CSS_SELECTOR,
            locators.UPLOAD_TIME_ON_PUBLISHED_CARD).text)
        pub_date2 = pub_date1.split("GMT")
        print("Date time now::", self.now)
        draft_date = datetime.strptime(draft_date2[0].strip(),
                                       '%a %b %d %Y %H:%M:%S')
        draft_date = draft_date.replace(tzinfo=pytz.utc)
        pub_date = datetime.strptime(pub_date2[0].strip(),
                                     '%a %b %d %Y %H:%M:%S')
        pub_date = pub_date.replace(tzinfo=pytz.utc)
        print("Type of date is now::", draft_date)
        lcc.log_info("pub_date::%s" % pub_date)
        lcc.log_info("draft_date::%s" % draft_date)

        check_that(
            "Draft text displayed on card",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.DRAFT_CARD_TITLE), equal_to("Draft"))
        check_that(
            "Published text displayed on card",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.PUBLISHED_CARD_TITLE),
            equal_to("Published"))
        check_that("Draft upload date in expected range",
                   self.check_date_in_range(draft_date), is_true())
        check_that("Uploaded date for published card in expected range",
                   self.check_date_in_range(pub_date), is_true())
        check_that(
            "Uploaded date for published card should be less than draft uploaded date",
            pub_date < draft_date, is_true())
        draft_card = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                            locators.DRAFT_CARD)
        published_card = utilities.find_element(self.driver, By.CSS_SELECTOR,
                                                locators.PUBLISHED_CARD)
        check_that(
            "Add metadata link present of draft card",
            draft_card.find_element(
                By.XPATH, locators.ADD_METADATA_BUTTON_XPATH).is_displayed(),
            is_true())
        check_that(
            "Add metadata link present of published card",
            published_card.find_element(
                By.XPATH, locators.ADD_METADATA_BUTTON_XPATH).is_displayed(),
            is_true())
        check_that(
            "Preview link present of draft card",
            draft_card.find_element(
                By.CSS_SELECTOR,
                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS).is_displayed(),
            is_true())
        check_that(
            "Preview link present of published card",
            published_card.find_element(
                By.CSS_SELECTOR,
                locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS).is_displayed(),
            is_true())
        check_that(
            "Publish button displayed on draft card",
            draft_card.find_element(
                By.ID,
                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID).is_displayed(),
            is_true())
        check_that(
            "Unpublish button displayed on published card",
            published_card.find_element(
                By.ID,
                locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID).is_displayed(),
            is_true())
        check_that(
            "Attributes file path on draft card",
            draft_card.find_element(By.CSS_SELECTOR,
                                    locators.ATTRIBUTE_FILE_CSS).text,
            equal_to("enterprise/meta/attributes.adoc"))
        check_that(
            "Attributes file path on published card",
            published_card.find_element(By.CSS_SELECTOR,
                                        locators.ATTRIBUTE_FILE_CSS).text,
            equal_to("enterprise/meta/attributes.adoc"))
Esempio n. 16
0
    def publish_module(self):
        utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        utilities.page_reload(self.driver)
        # search_page.search_for_module_and_click(self.driver, constants.module_to_be_published)
        search_beta_page.select_repo(self.driver, fixture.repo_name)
        search_beta_page.search_module_and_click(
            self.driver, constants.module_to_be_published)
        utilities.wait(10)

        pre_live_url = utilities.find_element(self.driver, By.LINK_TEXT,
                                              "Pre-live Customer Portal URL")
        print(pre_live_url.get_attribute('href'))
        check_that("Pre-live URL link is displayed",
                   pre_live_url.is_displayed(), is_true())
        copy_pre_live_url = utilities.find_element(self.driver, By.LINK_TEXT,
                                                   "Copy pre-live URL")
        check_that("Copy Pre-live URL is displayed",
                   copy_pre_live_url.is_displayed(), is_true())

        utilities.click_element(self.driver, By.ID,
                                locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID)
        utilities.wait(20)
        print("Clicked publish")
        # The page needs a refresh because of an existing bug about the "View on Customer Portal not appearing"
        self.driver.refresh()
        utilities.find_element(self.driver, By.PARTIAL_LINK_TEXT,
                               "View on Customer Portal")
        check_that(
            "Button contains text",
            utilities.get_text(self.driver, By.ID,
                               locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID),
            contains_string("Unpublish"))
        check_that(
            "Button contains text",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS),
            contains_string("Preview"))
        check_that(
            "Copy permanent url link is displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.COPY_URL_LINK_CSS),
            contains_string(constants.copy_url_link))
        check_that(
            "View on portal link is displayed",
            utilities.get_text(self.driver, By.CSS_SELECTOR,
                               locators.VIEW_ON_PORTAL_LINK_CSS),
            contains_string(constants.view_on_portal_link))

        # get UPLOADED date in variable and covert into desired format- (DD Month YYYY)
        self.first_pub_date_details_page = (utilities.get_text(
            self.driver, By.CSS_SELECTOR,
            locators.FIRST_PUB_DATE_MODULE_PAGE_CSS))
        lcc.log_info("captured 1st published date from module info page : " +
                     self.first_pub_date_details_page)

        # get published date in variable and convert into desired format-(DD Month YYYY)
        self.last_pub_date_details_page = (utilities.get_text(
            self.driver, By.CSS_SELECTOR,
            locators.LAST_PUB_DATE_MODULE_PAGE_CSS))
        lcc.log_info("captured last published date from module info page : " +
                     test_publish_module.last_pub_date_details_page)

        # adding checks if the module is displayed on the UI
        utilities.click_element(self.driver, By.CSS_SELECTOR,
                                locators.VIEW_ON_PORTAL_LINK_CSS)
        utilities.wait(5)
        try:
            utilities.switch_to_latest_tab(self.driver)
            utilities.wait(10)
            check_that("View on Portal URL path", self.driver.current_url,
                       contains_string(constants.view_on_portal_page_url))
        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)
    def git_import_for_sample_repo(self):
        git_import_page.import_git_repo(self.driver, git_import_repo_URL,
                                        git_import_repo_branch)
        utilities.verify_and_accept_confirmation_modal(
            self.driver, locators.GIT_IMPORT_REQUEST_SUBMITTED_TITLE,
            constants.git_import_submitted_modal_title,
            locators.GIT_IMPORT_REQUEST_SUBMITTED_YES)
        utilities.wait(20)
        # utilities.click_element(self.driver, By.LINK_TEXT, "Search")
        poll(lambda: utilities.find_element(
            self.driver, By.CSS_SELECTOR, locators.GIT_IMPORT_SUCCESS_ALERT_CSS
        ).is_displayed(),
             step=1,
             timeout=150)
        # screenshot_filename = "git_import" + utilities.generate_random_string(3) + ".png"
        # self.driver.save_screenshot(screenshot_filename)
        # lcc.save_attachment_file(screenshot_filename)
        text = utilities.get_text(self.driver, By.CSS_SELECTOR,
                                  locators.GIT_IMPORT_SUCCESS_ALERT_CSS)
        print(text)
        check_that("Git import successful alert", text,
                   contains_string(constants.success_alert_message))
        check_that(
            "Git import successfully uploaded files count", text,
            contains_string(constants.success_alert_files_uploaded +
                            number_of_files_imported))
        utilities.page_reload(self.driver)
        repo_list = utilities.find_elements_by_css_selector(
            self.driver, locators.LIST_OF_REPOS_CSS)
        name = []
        for i in repo_list:
            name.append(i.text)

        check_that("Git import repo is listed on search page", name,
                   has_item(git_import_repo_Name))

        # utilities.page_reload(self.driver)
        search_url = fixture.url + 'pantheon/internal/modules.json?repo=' + fixture.git_import_repo \
                     + '&search=' + module_title_prefix + '&key=Updated&direction=desc'

        lcc.log_info("Git import functionality verified using endpoint: %s" %
                     search_url)
        lcc.log_info(
            "Trying to poll the endpoint until we get the required number of search results as"
            " per the test data ...")
        req = requests.get(search_url)
        print(req.content)
        # poll(lambda: requests.get(search_url).json()["size"] == 9, step=5, timeout=120)

        imported_modules_request = requests.get(search_url)
        imported_modules = imported_modules_request.json()
        lcc.log_info(str(imported_modules))
        total_modules = imported_modules["size"]

        lcc.log_info(
            "Number of modules listed with the similar title name: %s" %
            str(total_modules))
        lcc.log_info(
            "Capturing the number of modules uploaded from the repo: %s ..." %
            git_import_repo_Name)
        results = imported_modules["results"]
        imported_modules_array = []
        for result in results:
            if result["pant:transientSourceName"] == git_import_repo_Name:
                imported_modules_array.append(result["jcr:title"])
        lcc.log_info(
            "Modules imported successfully via git import: %s with title prefix"
            % str(imported_modules_array))
        lcc.log_info(
            "Number of modules imported successfully from repo: %s is %s" %
            (git_import_repo_URL, str(len(imported_modules_array))))
        check_that("Count of modules uploaded using git import",
                   len(imported_modules_array),
                   equal_to(int(number_of_modules)))