def retrieve_version(self): """ Method used to retrieve the last python version from the table available in All releases """ self.driver = SeleniumLibraryExt._driver() self.retrieve_table_version() all_releases = self.driver.find_element_by_xpath("//*[@id='content']/div/section/div[2]/ol") versions = all_releases.find_elements_by_tag_name("li") release_list = [] for version in versions: version_dict = {'release_version': None, 'release_date': None} header = version.find_element_by_class_name("release-number") header_2 = version.find_element_by_class_name("release-date") version_dict['release_version'] = self.string_parse(header.text) version_dict['release_date'] = self.date_parse(header_2.text) if version_dict['release_date'] > self.first_release: if self.last_active_version in version_dict['release_version']: release_list.append(version_dict) if len(release_list) > 0: print("Yes, there are {} versions newer than the {} version".format(len(release_list), self.last_active_version)) print("The versions are:") for elem in release_list: print(str(elem['release_version']) + " released on: " + elem['release_date'].strftime("%Y-%b-%d")) else: print("There are no versions newer than the {} version".format(self.last_active_version))
def search(self, search_string): """ Method used to search in the search bar of the site and press Enter to find results """ self.driver = SeleniumLibraryExt._driver() search_bar = self.driver.find_element_by_name("q") search_bar.clear() search_bar.send_keys(search_string) search_bar.send_keys(Keys.RETURN)
def navigate_menu_submenu(self, menu, submenu): self.driver = SeleniumLibraryExt._driver() position = self.driver.find_element_by_xpath( f"//ul[@class='navigation menu']//li[contains(@class,'tier-1 element-')]/a[text()='{menu}']" ) ac = ActionChains(self.driver) ac.move_to_element(position).perform() self.driver.find_element_by_xpath( "//ul[@class='navigation menu']//ul[@class='subnav menu']//li[contains(@class,'tier-2 element-')]//a[" f"text()='{submenu}']").click()
def retrieve_table_version(self): self.driver = SeleniumLibraryExt._driver() last_python_version = self.driver.find_element_by_xpath("//ol[@class='list-row-container menu']//li//span[" "text()='3.9']") last_active_version = last_python_version.text self.last_active_version = last_active_version release_active_version = self.driver.find_element_by_xpath("//ol[@class='list-row-container menu']//li//span[" "text()='2020-10-05']") header = release_active_version.text first_release = self.date_parse_2(header) self.first_release = first_release
def get_first_result(self, result): """ Method used to click on the first result from the search list """ self.driver = SeleniumLibraryExt._driver() results_view = WebDriverWait(self.driver, 10).until( ec.presence_of_element_located( (By.XPATH, "//ul[@class='list-recent-events " "menu']"))) first_result = results_view.find_element_by_xpath( f"//a[text()='{result}']") ac = ActionChains(self.driver) ac.move_to_element(first_result).click(first_result).perform()
def open_content_examples(self): """ Method used to click on the Examples submenu from the Contents menu """ self.driver = SeleniumLibraryExt._driver() content_view = WebDriverWait(self.driver, 10).until( ec.presence_of_element_located( (By.XPATH, "//article[@class='text']"))) content_view_example = content_view.find_element_by_xpath( "//ul[@class='simple']//a[text()='Examples']") ac2 = ActionChains(self.driver) ac2.move_to_element(content_view_example).click( content_view_example).perform()
def verify_example_count(self): """ Verify the number of examples presented in the Examples paragraph of the page :return: True if the number of examples in the Example sections is 5, False otherwise """ self.driver = SeleniumLibraryExt._driver() self.open_content_examples() examples_view = self.driver.find_element_by_xpath( "//div[@id='examples']//ol[@class='arabic']") examples_list = examples_view.find_elements_by_tag_name("li") if len(examples_list) == 5: print("Yes, there are {} examples".format(str(len(examples_list)))) else: print("No, there are {} examples".format(str(len(examples_list))))