def test_password_input_7(self, registerPage:RegisterPage): '''注册-密码框输入文本:123456,显示******''' registerPage.input_password("123456") assert registerPage.get_password_attr(attr="value") == "123456" # 判断输入框显示***** assert registerPage.get_password_attr(attr="type") == "password"
def test_empty_password(self): register_page = RegisterPage(self.driver) register_page.enter_email(Variables.VALID_EMAIL) register_page.accept_privacy_policy() register_page.click_register_button() register_page.error_should_be_visible(Variables.NO_PASSWORD_MESSAGE)
def test_not_checked_privacy_policy(self): register_page = RegisterPage(self.driver) register_page.enter_email(Variables.VALID_EMAIL) register_page.enter_password_confirm(Variables.VALID_PASSWORD) register_page.enter_password_confirm(Variables.VALID_PASSWORD) register_page.click_register_button() register_page.error_should_be_visible(Variables.ACCEPT_PRIVACY_MESSAGE)
def test_login_input_field_short_length( self, browser ): # должна быть не меньше 8 символов и не больше 18 символов page = RegisterPage(browser, register_url) page.open() page.enter_login_non_valid(login_less_then_8) page.take_a_screenshot(browser)
def login(driver, username, password): welcome(driver) navigation = Navigation(driver) navigation.account_btn().click() account_page = AccountPage(driver) account_page.click_login().click() register_page = RegisterPage(driver) register_page.login_btn().click() login_page = LoginPage(driver) login_page.login(username, password)
class Register(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.register = RegisterPage(self.driver) self.homepage = HomePage(self.driver) self.dashboard = DashboardPage(self.driver) def test_register(self): self.driver.get('http://stage.edx.org/') self.assertTrue(self.homepage.is_browser_on_the_page()) self.homepage.click_register() self.assertTrue(self.register.is_browser_on_the_page()) self.register.fill_form() self.register.submit_form() self.assertTrue(self.dashboard.is_browser_on_the_page()) def tearDown(self): self.driver.close()
def setUp(self): self.logger = Log() self.logger.info( '##################### START ######################') warnings.simplefilter('ignore', ResourceWarning) driver = init_driver() self.driver = driver self.loginPage = LoginPage(self.driver) self.registerPage = RegisterPage(self.driver) self.settingPage = SettingPage(self.driver)
def __init__(self, driver, base_url): self.driver = driver self.driver.get(base_url) self.driver.maximize_window() self.login_page = LoginPage(driver, base_url) self.internal_page = InternalPage(driver, base_url) self.main_page = MainPage(driver, base_url) self.movie_page = MoviePage(driver, base_url) self.register_page = RegisterPage(driver, base_url) self.edit_page = EditPage(driver, base_url) self.cart_page = CartPage(driver, base_url) self.wait = WebDriverWait(driver, 10)
class EdxRegister(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.register = RegisterPage(self.driver) self.dashboard = Dashboard(self.driver) self.select = SelectPage(self.driver) def test_register(self): self.driver.get('https://courses.edx.org/register') self.register.fill_form('*****@*****.**', 'Test 131', 'Tan3211t', 'Tk123@arbisoft') self.select.select_country() self.register.create_account() self.dashboard.go_to_course_page() def tearDown(self): self.driver.close()
def setUpClass(cls): logger.info("开始执行测试类") cls.desired = cls.conf.read_alone cls.desired["app"] = APK_PATH cls.driver = webdriver.Remote( command_executor="http://192.168.1.103:4723/wd/hub", desired_capabilities=cls.desired) cls.home_page = HomePage(cls.driver) cls.login_page = LoginPage(cls.driver) cls.loan_page = LoanPage(cls.driver) cls.user_page = UserPage(cls.driver) cls.invest_page = InvestPage(cls.driver) cls.register_page = RegisterPage(cls.driver)
def test_email_input_6(self, registerPage:RegisterPage): '''注册-邮箱输入框,输入文本:[email protected],再清空文本,输入框为空''' registerPage.input_email("*****@*****.**") assert registerPage.get_email_attr(attr="value") == "*****@*****.**" # 清空输入框 registerPage.clear_email() assert registerPage.get_email_attr(attr="value") == ""
def test_email_2(self, registerPage:RegisterPage): ''' 注册-邮箱格式不正确,密码为空, 点提交按钮,邮箱输入框红色提示(class 属性包含errorput)''' # registerPage.open("/users/register/") registerPage.input_email("1234") registerPage.input_password("") registerPage.click_register_btn() # 实际结果 actual_result = registerPage.get_email_class() print("实际结果", actual_result) # 断言 assert "errorput" in actual_result
def test_password_5(self, registerPage:RegisterPage): ''' 注册-邮箱格式正确([email protected]), 密码大于20位, 点提交按钮,密码框提示红色(class属性errorput) :return: ''' # registerPage.open("/users/register/") registerPage.input_email("*****@*****.**") registerPage.input_password("1234567890123456789012") registerPage.click_register_btn() # 实际结果 actual_result = registerPage.get_password_class() print("实际结果", actual_result) # 断言 assert "errorput" in actual_result
def test_register_success(self, driver, base_url, delete_user): '''测试注册成功案例 数据清理账号''' register = RegisterPage(driver, base_url) register.open("/users/register/") # 操作步骤 register.input_email("*****@*****.**") register.input_password("123456") register.click_register_btn() # 实际结果 actual_result = register.register_success_text() # 断言 assert actual_result == "尊敬的用户,您好,账户已激活成功!"
def open_register(self, registerPage:RegisterPage): registerPage.open("/users/register/")
def setUp(self): self.driver = webdriver.Firefox() self.register = RegisterPage(self.driver) self.homepage = HomePage(self.driver) self.dashboard = DashboardPage(self.driver)
def test_should_be_registration_button(self, browser): page = RegisterPage(browser, register_url) page.open() page.should_be_register_btn() page.take_a_screenshot(browser)
class RegisterBusiness(): def __init__(self, driver): self.driver = driver self.driver.get("http://www.5itest.cn/register") self.driver.maximize_window() self.register_p = RegisterPage(self.driver) def base_reg(self, email, name, password, code): try: self.register_p.get_email_element().send_keys(email) self.register_p.get_name_element().send_keys(name) self.register_p.get_password_element().send_keys(password) self.register_p.get_code_element().send_keys(code) self.register_p.get_register_button().click() except Exception: self.driver.save_screenshot('1.png') return None def reg_email_err(self, email, name, password, code): self.base_reg(email, name, password, code) if self.register_p.get_error_element("email_error"): text = self.register_p.get_error_element("email_error").text else: text = None print(text) return text def reg_name_err(self, email, name, password, code): self.base_reg(email, name, password, code) if self.register_p.get_error_element("name_error"): text = self.register_p.get_error_element("name_error").text else: text = None print(text) return text
def test_register_email_existed(self, driver, base_url): '''重复注册,注册失败''' register = RegisterPage(driver, base_url) register.open("/users/register/") # 操作步骤 register.input_email("*****@*****.**") register.input_password("123456") register.click_register_btn() # 实际结果 actual_result = register.register_success_text() # 断言 assert actual_result != "尊敬的用户,您好,账户已激活成功!"
def test_correct_registration(self): home_page = HomePage(self.driver) home_page._verify_page() home_page = HomePage(self.driver) home_page.click_choose_local() home_page.click_choose_katowice() katowice_page = KatowicePage(self.driver) katowice_page.click_reserv_button() register_page = RegisterPage(self.driver) register_page.add_name_field(td.valid_name) register_page.add_lastname_field(td.valid_lastname) register_page.add_email_field(td.valid_email) register_page.add_phone_field(td.valid_phone) register_page.add_peoplenb_field(td.valid_peoplenb) register_page.add_hour_field(td.valid_hour) register_page.add_minutes_field(td.valid_minutes) register_page.add_endhour_field(td.valid_endhour) register_page.add_endminutes_field(td.valid_endminutes) register_page.click_date_field() register_page.click_datechosen_field() register_page.click_reserve_field() conf_page = ConfPage(self.driver) conf_page.check_registration()
def step_impl(context): global page page.click_register_button() # global page is now an instance of RegisterPage page = RegisterPage(context.browser)
def test_incorrect_password(self): home_page = HomePage(self.driver) home_page.click_sign_in_btn() time.sleep(2) login_page = LoginPage(self.driver) login_page.click_registration_btn() register_page = RegisterPage(self.driver) register_page.fill_name_field(td.valid_name) register_page.fill_surname_field(td.valid_surname) register_page.choose_gender(td.gender) register_page.fill_phone_number_country_code_field(td.valid_country) register_page.fill_phone_field(td.valid_phone) register_page.fill_email_field(td.valid_email) register_page.fill_password_field(td.invalid_password) register_page.fill_country_field(td.valid_country) register_page.select_privacy_policy() register_page.click_register_btn() error_notices = self.driver.find_elements(*RegisterPageLocators.ERROR_NOTICES) visible_error_notices = [] for error in error_notices: if error.is_displayed(): visible_error_notices.append(error) self.assertEqual(len(visible_error_notices),1) self.assertEqual(visible_error_notices[0].get_attribute('innerText'),u"Wpisz hasło") time.sleep(5)
def test_login_input_valid(self, browser): page = RegisterPage(browser, register_url) page.open() page.enter_login_valid(login) page.take_a_screenshot(browser)
def test_login_input_long_length(self, browser): page = RegisterPage(browser, register_url) page.open() page.enter_login_non_valid(login_more_then_18) page.take_a_screenshot(browser)
def test_incorrect_email(self): """Test rejestracji nowego użytkownika - błędny e-mail""" # Tworzę instancję klasy HomePage, dzięki czemu zyskuję możliwość # korzystania z metod w niej zawartych hp = HomePage(self.driver) hp.click_zaloguj_btn() lp = LoginPage(self.driver) lp.click_register_btn() rp = RegisterPage(self.driver) # Wpisz imię rp.fill_name("Przemek") # Wpisz nazwisko rp.fill_surname("Nowak") # Wybierz płeć rp.choose_gender("M") # Wybierz kod kraju rp.choose_country_code("+48") # Wpisz numer telefonu rp.fill_telephone('321321321') # Wpisz niepoprawny e-mail rp.fill_email('dddd.pl') # Wpisz hasło rp.fill_password('Qwessdry123@') # Wybierz narodowość rp.choose_nationality("Polska") # Zaznacz "Akceptuję Informację o polityce prywatności" rp.accept_privacy_policy() # Kliknij ZAREJESTRUJ [ NIE STOSOWAĆ DLA PRZYPADKU POZYTYWNEGO !!!!] # Sprawdź poprawność wyświetlanych błędów rp.verify_visible_errors(1, ["Nieprawidłowy adres e-mail"]) time.sleep(2)
def test_register_link_11(self, registerPage:RegisterPage, base_url): '''注册-点页面“注册”按钮,点击跳转到登陆页/users/register/''' link = registerPage.get_link_href('//*[text()="[注册]"]') print("实际结果:%s" % link) assert link == base_url+"/users/register/"
login_page.browser_alert.accept() # Username field with correct login credentials (valid login) login_page.password_input.clear() login_page.repeat_password_input.clear() login_page.password_input.enter_text(Valid.password()) login_page.repeat_password_input.enter_text(Valid.password()) login_page.login_button.click() assert login_page.browser_alert.text == expected_successful_login_alert login_page.browser_alert.accept() # Register Form Test Scenario register_page = RegisterPage(driver=browser) register_page.go() # Expected results # Labels expected_userid_label_txt = 'User id:' expected_password_label_txt = 'Password:'******'Name:' expected_address_label_txt = 'Address:' expected_country_selection_label_txt = 'Country:' expected_zipcode_label_txt = 'ZIP Code:' expected_email_label_txt = 'Email:' expected_sex_selection_label_txt = 'Sex:' expected_english_checkbox_label_txt = 'English:' expected_about_label_txt = 'About:'
def test_register_link_12(self, registerPage:RegisterPage, base_url): '''注册-点页面“立即登陆”按钮,点击跳转到登陆页/users/login/''' link = registerPage.get_link_href('//*[text()="[立即登录]"]') print("实际结果:%s" % link) assert link == base_url+"/users/login/"
def __init__(self, driver): self.driver = driver self.driver.get("http://www.5itest.cn/register") self.driver.maximize_window() self.register_p = RegisterPage(self.driver)
def test_register_link_9(self, registerPage:RegisterPage, base_url): '''注册-点页面“logo图片”按钮,点击跳转到首页/''' link = registerPage.get_link_href('//*[@class="index-logo"]') print("实际结果:%s" % link) # http://49.235.92.12:8200/ assert link == base_url+"/"