def email_recovery(self): email = input("Enter the email you want to recovery: ") self.email_field.send_keys(email) self.submit_btn.click() test_name = "Email recovering." try: driver.find_element(By.XPATH, "//h1[contains(text(),'Help is on the way')]") print( f"Test: {test_name}\nStatus: Passed.\nTo fully pass this test you should to check your email: {email}") except: print(f"Test: {test_name}\nStatus: Failed")
def empty_name_reg(self): email_method = 'valid' password_method = 'valid' name_method = 'empty' checkbox_method = True test_name = "Registration with empty name and last name." self.registration(name_method, email_method, password_method, checkbox_method) try: result1 = driver.find_element( By.XPATH, "//li[contains(text(),'First name can') and contains(text(),'t be blank')]" ) result2 = driver.find_element( By.XPATH, "//li[contains(text(),'Last name can') and contains(text(),'t be blank')]" ) if result1 and result2: return self.check_exists_by_xpath(test_name, result1) except: return f"Test: {test_name}.\nStatus: Failed"
def too_long_name_reg(self): email_method = 'valid' password_method = 'valid' name_method = 'too_long' checkbox_method = True test_name = "Registration with too long name and last name (more than 255 symbols)." self.registration(name_method, email_method, password_method, checkbox_method) try: result1 = driver.find_element( By.XPATH, "//li[@role='alert' and contains(text(),'First name is too long')]" ) result2 = driver.find_element( By.XPATH, "//li[@role='alert' and contains(text(),'Last name is too long')]" ) if result1 and result2: return self.check_exists_by_xpath(test_name, result1) except: return f"Test: {test_name}.\nStatus: Failed"
def __init__(self, driver): driver.get("https://courses.ultimateqa.com/users/sign_up") self.driver = driver self.first_name_field = driver.find_element( By.XPATH, "//input[@placeholder='First Name']") self.last_name_field = driver.find_element( By.XPATH, "//input[@placeholder='Last Name']") self.email_field = driver.find_element( By.XPATH, "//input[@placeholder='Email']") self.new_password_field = driver.find_element( By.XPATH, "//input[@placeholder='New Password']") self.terms_checkbox = driver.find_element(By.XPATH, "//input[@type='checkbox']") self.sign_up_btn = driver.find_element(By.XPATH, "//input[@type='submit']")
def __init__(self, driver): driver.get("https://courses.ultimateqa.com/users/password/new") self.email_field = driver.find_element(By.XPATH, "//input[@type='email' and @placeholder='Email']") self.submit_btn = driver.find_element(By.XPATH, "//input[@type='submit']")
def check_exists_by_xpath(self, test_name, xpath): try: assert driver.find_element(By.XPATH, xpath) return f"Test: {test_name}.\nStatus: Passed" except: return f"Test: {test_name}.\nStatus: Failed"