def login_success(self, user_name, password): self.user_base(user_name, password) if Login_Page.get_username_password_error() == None: return True else: return False
class BuyCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.maximize_window() self.driver.get('http://111.229.90.117/index.php?route=account/login') self.byp = Buy_Page(self.driver) self.lgp = Login_Page(self.driver) def test_buy_success(self): self.lgp.login_case('*****@*****.**', '123456') time.sleep(2) self.byp.buy_case() def tearDown(self): time.sleep(2) for method_name, error in self._outcome.errors: if error: case_name = self._testMethodName file_path = os.path.join( "D:\\Selenium_2020\\Register_Bokeyuan\\report\\" + case_name + ".png") self.driver.save_screenshot(file_path) self.driver.close()
class LoginCase(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.maximize_window() self.driver.get('http://111.229.90.117/index.php?route=account/login') self.lgp = Login_Page(self.driver) def test_login_err(self): login_err = self.lgp.login_err('*****@*****.**','123') return self.assertTrue(login_err,'fail') def test_login_success(self): self.lgp.login_case('*****@*****.**','123456') def tearDown(self): time.sleep(2) for method_name,error in self._outcome.errors: if error: case_name = self._testMethodName file_path = os.path.join("D:\\Selenium_2020\\Register_Bokeyuan\\report\\"+case_name+".png") self.driver.save_screenshot(file_path) self.driver.close()
class LoginHandle(): def __init__(self, driver): self.login_p = Login_Page(driver) #输入用户名 def send_user_name(self, user_name): self.login_p.get_user_name().send_keys(user_name) #输入密码 def send_user_password(self, password): self.login_p.get_user_password().send_keys(password) #点击dengl按钮 def click_button(self): self.login_p.get_button().click()
def setUpClass(cls): cls.driver = webdriver.Chrome() cls.l = Login_Page(cls.driver) cls.l.openbrowser()
def get_login_obj(self): return Login_Page(self.driver)
def setUpClass(cls): cls.driver = webdriver.Chrome() cls.login = Login_Page(cls.driver) cls.login.login_action() cls.b = Bugsearch_page(cls.driver)
def setUp(self): self.driver = webdriver.Chrome() self.driver.maximize_window() self.driver.get('http://111.229.90.117/index.php?route=account/login') self.adcp = AddCart_Page(self.driver) self.lgp = Login_Page(self.driver)
def __init__(self, driver): self.login_p = Login_Page(driver)
def setUpClass(cls): cls.driver=webdriver.Chrome() cls.l=Login_Page(cls.driver) cls.l.login_action()
def login(self): return Login_Page(self.driver)
def __init__(self, driver=None): self.LP = Login_Page(driver=driver)
class Login_Dandle(object): def __init__(self, driver=None): self.LP = Login_Page(driver=driver) def send_username(self, username): '''输入用户名''' self.LP.get_username_element().send_keys(username) def send_password(self, password): '''输入密码''' self.LP.get_password_element().send_keys(password) def click_button(self): '''点击登录按钮''' self.LP.get_login_button_element().click() def error_click_button(self): '''点击错误提示框按钮''' self.LP.get_error_button_element().click() def get_login_succeed_text(self): '''获取登录界面信息''' return self.LP.get_login_succeed_element() #此处用这样文本判断有问题 def user_info_text(self, info, user_info): '''获取登录成功失败文本信息''' try: if info == 'username_error': text = self.LP.get_username_element().text else: text = self.LP.get_password_element().text except: text = None return text
# 输入重现步骤 body = ''' [步骤]111111, 22222, 33333. [结果]rrrrrrr [期望]eeeee ''' self.input(self.body_loc, body) self.switch_default_frame() self.scroll_end() self.click(self.submit_loc) def sucess_result(self): return self.text_in_element(self.result_loc, self.title) if __name__ == "__main__": driver = webdriver.Chrome() a = Addbug_page(driver) l = Login_Page(driver) l.openbrowser() l.login() a.add_bug() print(a.sucess_result())