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 setup_suite(self): utilities.wait(5) # Navigate to search page # Select repo and search for the assembly # Add metadata and publish the assembly using api endpoints and wait for the unpublish button to display utilities.click_element(self.driver, By.LINK_TEXT, "Search") utilities.page_reload(self.driver) # 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) display_module_page.add_metadata_and_publish(self.driver) utilities.wait_for_element(self.driver, By.ID, locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID) # Navigate to search page # Select repo and search for the module # Add metadata and publish the module using api endpoints and wait for the unpublish button to display utilities.click_element(self.driver, By.LINK_TEXT, "Search") # 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.module_new_draft_version) display_module_page.add_metadata_and_publish(self.driver) utilities.wait_for_element(self.driver, By.ID, locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID)
def authenticated_user_view_unpublished_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.unpublished_module) search_beta_page.select_repo(self.driver, fixture.repo_name) search_beta_page.search_module_and_click(self.driver, constants.unpublished_module) check_that( "Button", utilities.get_text(self.driver, By.ID, locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID), contains_string("Publish")) check_that( "Button", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.MODULE_DISPLAY_PREVIEW_BUTTON_CSS), contains_string("Preview")) check_that( "First Published date", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.MODULE_DISPLAY_FIRST_PUBLISHED_CSS), contains_string("--")) check_that( "Last Published date", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.MODULE_DISPLAY_LAST_PUBLISHED_CSS), contains_string("--")) check_that( "Module display page title", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.MODULE_DISPLAY_TITLE_CSS), contains_string(constants.unpublished_module))
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 setup_suite(self): # Add metadata utilities.wait(5) utilities.click_element(self.driver, By.LINK_TEXT, "Search") utilities.page_reload(self.driver) # 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.published_module) display_module_page.add_metadata_and_publish(self.driver) utilities.wait_for_element(self.driver, By.ID, locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID)
def add_metadata_and_publish(driver): # f = fixture() # lcc.log_info("Added following product information to the module::\nProduct name:" + f.product_name +"\nProduct version:"+constants.product_version+"\nUse case:"+constants.use_case) string = driver.current_url str = string.split("?") lcc.log_info(str[0]) if "module" in str[0]: path = (str[0].replace("pantheon/#/module", "content")) elif "assembly" in str[0]: path = (str[0].replace("pantheon/#/assembly", "content")) else: lcc.log_info("Invalid url!!!") var = str[1].split("=") metadata_path = path + "/en_US/variants/" + var[1] + "/draft/metadata" product_uuid = fixture.get_product_id() body = { "productVersion": product_uuid, "documentUsecase": "Deploy", "urlFragment": "", "searchKeywords": "" } # Add metadata from api add_metadata = requests.post(url=metadata_path, data=body, auth=(username, api_auth)) lcc.log_info("Added metadata to::") lcc.log_info(path) utilities.wait(2) # print(add_metadata.content) utilities.page_reload(driver) # utilities.click_element(driver, By.XPATH, locators.ADD_METADATA_BUTTON_XPATH) # fill_edit_metadata_form(driver, constants.product_name, constants.product_version, # constants.use_case, constants.url_fragment) body = {":operation": "pant:publish", "locale": "en_US", "variant": var[1]} publish = requests.post(url=path, data=body, auth=(username, api_auth)) lcc.log_info(publish.text) lcc.log_info("Published document::") lcc.log_info(path) # utilities.click_element(driver, By.ID, locators.MODULE_DISPLAY_PUBLISH_BUTTON_ID) # utilities.wait(10) utilities.wait(2) # print(publish.content) utilities.page_reload(driver) utilities.wait(3) assert_that( "Button contains text", utilities.get_text(driver, By.ID, locators.MODULE_DISPLAY_UNPUBLISH_BUTTON_ID), contains_string("Unpublish")) utilities.wait(5)
def search_for_module(self): utilities.click_element(self.driver, By.LINK_TEXT, "Search") utilities.page_reload(self.driver) utilities.wait(2) utilities.enter_text(self.driver, By.ID, locators.SEARCH_BOX_ID, constants.module_to_search) utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SEARCH_BUTTON_CSS) utilities.wait(3) check_that( "module is found on search page", utilities.get_text(self.driver, By.XPATH, locators.SEARCH_MODULE_XPATH), contains_string(constants.module_to_search))
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 verify_filter_by_content_type(driver, module_type): utilities.click_element(driver, By.LINK_TEXT, locators.MENU_SEARCH_PAGE_LINK_TEXT) utilities.page_reload(driver) search_beta_page.select_repo(driver, fixture.repo_name) lcc.log_info("Verifying filter by module type: %s " % module_type) search_beta_page.filter_by_content_type(driver, module_type) module_type_title_list = utilities.find_elements_by_css_selector( driver, locators.ALL_MODULE_TITLES) module_type_list = [] for i in module_type_title_list: module_type_list.append(i.text) for i in module_type_list: check_that("Module type for all titles", i, contains_string(module_type)) utilities.wait(10)
def edit_metadata_blank_data(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.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) self.driver.refresh() utilities.click_element(self.driver, By.XPATH, locators.ADD_METADATA_BUTTON_XPATH) check_that("Edit metadata modal title", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.EDIT_METADATA_MODAL_TITLE_CSS), contains_string(constants.edit_metadata_modal_title)) utilities.click_element(self.driver, By.CSS_SELECTOR, locators.EDIT_METADATA_SAVE_CSS) check_that("Warning displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS), contains_string(constants.edit_metadata_modal_warning)) utilities.wait(2)
def duplicate_product_name(self): # Navigate to New product page from Product listing page utilities.click_element(self.driver, By.XPATH, locators.MENU_PRODUCTS_LINK_XPATH) 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 page to clear old values utilities.page_reload(self.driver) # 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.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version) 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.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version) utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS) check_that("Duplicate Product warning is displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.WARNING_ALERT_CSS), contains_string(constants.duplicate_product_name_warning)) utilities.click_element(self.driver, By.CSS_SELECTOR, locators.CLOSE_WARNING_ALERT_CSS)
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 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 create_product(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 page to clear old values utilities.page_reload(self.driver) # 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.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version) 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.enter_text(self.driver, By.ID, locators.NEW_PRODUCT_VERSION_TEXTBOX_ID, constants.product_version) utilities.click_element(self.driver, By.CSS_SELECTOR, locators.SAVE_PRODUCT_BUTTON_CSS) utilities.wait(5) products = utilities.find_elements_by_css_selector(self.driver, locators.PRODUCT_NAME_LIST_CSS) lcc.log_info(str(len(products))) products_list = [] for product in products: products_list.append(product.text) check_that("Product created is listed successfully", products_list, has_item(product_name), quiet=False)
def verify_no_module_type(self): utilities.click_element(self.driver, By.LINK_TEXT, locators.MENU_SEARCH_PAGE_LINK_TEXT) utilities.page_reload(self.driver) # try: # search_page.search_for_module_and_click(self.driver, constants.no_module_type_title) # except (TimeoutException, StaleElementReferenceException) as e: # lcc.log_error("Module not listed on listed in the results after applying module type filter.") # utilities.wait(2) # search_page.search_for_module_and_click(self.driver, constants.no_module_type_title) search_beta_page.select_repo(self.driver, fixture.repo_name) search_beta_page.search_module_and_click( self.driver, constants.no_module_type_title) lcc.log_info( "Verifying no module type is displayed for modules with invalid type mentioned inside " "the asciidoc file") # Once landed on the module display page, get path to adoc from the module display page url path_to_adoc_file = display_module_page.get_path_to_adoc(self.driver) path = path_to_adoc_file + constants.path_for_module_type response = requests.get(url=url + path, auth=(fixture.username, fixture.api_auth)) check_that("Module type node in backend", response.status_code, equal_to(404))
def add_metadata(self): utilities.wait(5) utilities.click_element(self.driver, By.LINK_TEXT, "Search") utilities.page_reload(self.driver) # search_page.search_for_module_and_click(self.driver, constants.assembly_to_be_published) search_beta_page.select_repo(self.driver, fixture.repo_name) search_beta_page.search_module_and_click( self.driver, constants.assembly_to_be_published) utilities.click_element(self.driver, By.XPATH, locators.ADD_METADATA_BUTTON_XPATH) check_that( "Edit metadata modal title", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.EDIT_METADATA_MODAL_TITLE_CSS), contains_string(constants.edit_metadata_modal_title)) display_module_page.fill_edit_metadata_form(self.driver, constants.product_name, constants.product_version, constants.use_case, constants.url_fragment) check_that( "Success message displayed", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.UPDATE_SUCCESS_MESSAGE_CSS), contains_string(constants.success_message)) check_that( "Product name reflected on displayed module page", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.PRODUCT_INFO_CSS), contains_string(constants.product_name)) check_that( "Product version reflected on displayed module page", utilities.get_text(self.driver, By.CSS_SELECTOR, locators.PRODUCT_INFO_CSS), contains_string(constants.product_version)) utilities.wait(2)
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)))
def view_assembly_on_cp(self): test_repo_name = base.config_reader('test_repo', 'repo_name') try: utilities.page_reload(self.driver) 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) check_that( "URL portal is", self.driver.current_url, contains_string( "https://access.qa.redhat.com/documentation/en-us/" + constants.product_name_uri + "/" + constants.product_version + "/guide/")) assembly_title = utilities.find_shadow_dom_element( self.driver, locators.DOCUMENT_TITLE_CP, locators.MODULE_BODY_ON_PORTAL_CSS).text check_that("Assembly title", assembly_title, contains_string(constants.assembly_to_be_published)) product_name = utilities.find_shadow_dom_element( self.driver, locators.PRODUCT_NAME_ON_PREVIEW_CSS, locators.MODULE_BODY_ON_PORTAL_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_ON_PORTAL_CSS).text check_that("Product version reflected on view page", product_version, contains_string(constants.product_version)) image = utilities.find_shadow_dom_element( self.driver, locators.IMAGE_CSS, locators.MODULE_BODY_ON_PORTAL_CSS) src = image.get_attribute("src") imageasset = urlparse(src) imageasset = imageasset.path.split("/")[2] cmd = "echo " + imageasset + "|base64 -d" try: # subprocess.check_call(cmd, shell=True) path = subprocess.getoutput(cmd) print("Image file path::", path) image_file = "/content/repositories/" + test_repo_name + "/entities/enterprise/assemblies/images/" + constants.image_file_name check_that("Path to image1", path, equal_to(image_file)) except subprocess.CalledProcessError as e: lcc.log_info("Unable to decode imageasset") assembly_body = utilities.get_text( self.driver, By.CSS_SELECTOR, locators.ASSEMBLY_BODY_PREVIEW_CSS) for i in range(test_view_assembly.modules_count): check_that( "Assembly body", assembly_body, contains_string(test_view_assembly.module_titles[i])) guides_content_related = utilities.find_shadow_dom_element( self.driver, locators.CONTENT_RELATED_TO_GUIDES, locators.MODULE_BODY_ON_PORTAL_CSS) self.driver.execute_script("arguments[0].scrollIntoView();", guides_content_related) utilities.wait(20) check_that("Content related to this guide setcion", guides_content_related.is_displayed(), equal_to(True)) # utilities.click_element(self.driver, By.XPATH, "//summary[text()='Content related to this guide']") additional_res_guide = utilities.find_shadow_dom_element( self.driver, locators.CONTENT_RELATED_GUIDES_RESOURCES, locators.MODULE_BODY_ON_PORTAL_CSS) check_that( "Content related to this guide setcion to contain Addtional resources setion", additional_res_guide.is_displayed(), equal_to(True)) except Exception as e: lcc.log_error(e) finally: if (len(self.driver.window_handles) > 1): self.driver.close() utilities.switch_to_first_tab(self.driver)
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)