def harvestChapterLinks(self, driver: WebDriver, novelPageUrl: str): """ 1) Assuming in novel page -> open "Chapters" section 2) Find div elements with chapter links 3) Get the returned list of chapter links NOTE: You NEED to be in the novel_page for this to work """ driver.get(novelPageUrl) sleep(5) driver.execute_script(self.clickElementWithInnerTextS("button", "chapters")) driver.execute_script(self.openAccordian(self.accordianText)) sleep(2) clsTuple = ("grid", "grid-cols-1", "md:grid-cols-2", "w-full") divList = driver.find_elements( By.XPATH, self.getXpathStrFrClsNames("div", *clsTuple), ) return get_hrefList(divList)
def test_nextcloud(IP: str, nc_port: str, driver: WebDriver): """ Login and assert admin page checks""" test = Test() test.new("nextcloud page") try: driver.get(f"https://{IP}:{nc_port}/index.php/settings/admin/overview") except Exception as e: test.check( e, msg= f"{tc.red}error:{tc.normal} unable to reach {tc.yellow + IP + tc.normal}" ) test.check("NextCloudPi" in driver.title, msg="NextCloudPi not found in page title!") trusted_domain_str = "You are accessing the server from an untrusted domain" test.report("trusted domain", trusted_domain_str not in driver.page_source, f"Domain '{IP}' is not trusted") try: driver.find_element(By.ID, "user").send_keys(nc_user) driver.find_element(By.ID, "password").send_keys(nc_pass) driver.find_element(By.ID, "submit-form").click() except NoSuchElementException: try: driver.find_element(By.ID, "submit").click() except NoSuchElementException: pass test.report("password", "Wrong password" not in driver.page_source, msg="Failed to login with provided password") test.new("settings config") wait = WebDriverWait(driver, 30) try: wait.until( VisibilityOfElementLocatedByAnyLocator([ (By.CSS_SELECTOR, "#security-warning-state-ok"), (By.CSS_SELECTOR, "#security-warning-state-warning"), (By.CSS_SELECTOR, "#security-warning-state-error") ])) element_ok = driver.find_element(By.ID, "security-warning-state-ok") element_warn = driver.find_element(By.ID, "security-warning-state-warning") if element_warn.is_displayed(): if driver.find_element(By.CSS_SELECTOR, "#postsetupchecks > .errors").is_displayed() \ or driver.find_element(By.CSS_SELECTOR, "#postsetupchecks > .warnings").is_displayed(): raise ConfigTestFailure("There have been errors or warnings") infos = driver.find_elements(By.CSS_SELECTOR, "#postsetupchecks > .info > li") for info in infos: if re.match( r'.*Your installation has no default phone region set.*', info.text): continue else: php_modules = info.find_elements(By.CSS_SELECTOR, "li") if len(php_modules) != 1: raise ConfigTestFailure( f"Could not find the list of php modules within the info message " f"'{infos[0].text}'") if php_modules[0].text != "imagick": raise ConfigTestFailure( "The list of php_modules does not equal [imagick]") elif not element_ok.is_displayed(): raise ConfigTestFailure( "Neither the warnings nor the ok status is displayed " "(so there are probably errors or the page is broken)") test.check(True) except Exception as e: test.check(e)