def test_login2(init_test): print("222222222222") time.sleep(20) loginPage = LoginPage() loginPage.switch_tologin() time.sleep(3) loginPage.switch_cleakUser() loginPage.switch_cleakDelete() time.sleep(3) loginPage.input_user() time.sleep(3)
def login_fixture(): """登录功能的前置后置""" # 前置条件 log.info("开始执行登录的用例") driver = webdriver.Chrome() login_page = LoginPage(driver) login_page.click_re_mobile() index_page = IndexPage(driver) yield login_page, index_page # 后置条件 driver.quit() log.info("登录的用例执行完毕")
def quit_fixture(): # 用来测试退出课堂用例的前置 log.info("----------开始执行测试退出课堂用例---------") driver = webdriver.Chrome() driver.implicitly_wait(15) # 先登录 login_page = LoginPage(driver) userinfo_page = UserInfoPage(driver) # 登录 login_page.login(user=conf.get('test_data', 'user'), pwd=conf.get('test_data', 'pwd')) userinfo_page.close_welcome() # 进行加入课堂 userinfo_page.join_class(conf.get('test_data', 'join_code')) yield userinfo_page driver.quit()
def fixture(): log.info("--------------开始执行登录的用例----------") driver = webdriver.Chrome() login_page = LoginPage(driver) userInfo_page = UserInfoPage(driver) yield login_page, userInfo_page driver.quit() log.info("---------------登录的测试用例执行完毕-------")
def pre_method(): log.info("----------开始执行登录的用例--------") driver = webdriver.Chrome() login_page=LoginPage(driver) index_page=IndexPage(driver) yield login_page,index_page driver.quit() log.info("-----------登录的用例执行完毕---------")
def invest_fixture(): # 前置条件 driver = Chrome() # 创建登录页面 login_page = LoginPage(driver) # 登录 login_page.login(user=conf.get('test_data', 'mobile'), pwd=conf.get('test_data', 'pwd')) # 创建首页对象 index_page = IndexPage(driver) # 点击抢标 index_page.click_bid() # 创建投资页面 invest_page = InvestPage(driver) yield invest_page # 后置条件 driver.quit()
def test_login(init_test): print("1111111111111111") time.sleep(20) loginPage = LoginPage() loginPage.switch_tologin() time.sleep(3) loginPage.switch_cleakUser() loginPage.switch_cleakDelete() time.sleep(5)
def op_fixture(): # 前置需要 登录 log.info("---------开始执行用户页面操作的用例----------") driver = webdriver.Chrome() driver.implicitly_wait(15) # 需要先登录进入用户主界面 login_page = LoginPage(driver) userinfo_page = UserInfoPage(driver) # 登录 login_page.login(user=conf.get('test_data', 'user'), pwd=conf.get('test_data', 'pwd')) userinfo_page.close_welcome() yield userinfo_page # 每次用例执行结束之后将课程退出,保证环境纯净 userinfo_page.exit_class(leave_pwd=conf.get("test_data", 'pwd')) time.sleep(1) log.info("---------结束----------") driver.quit()
def invest_flxure(): log.info("----------开始执行登录的用例--------") #设置driver以无头浏览器的模式运行 option = webdriver.ChromeOptions() option.add_argument("--headless") driver = webdriver.Chrome(options=option) # 创建登录页面 # driver.maximize_window() driver.implicitly_wait(15) login_page = LoginPage(driver) # 登录 login_page.login(user=conf.get('test_data', 'mobile'), pwd=conf.get('test_data', 'pwd')) # 创建首页对调用点击 index_page = IndexPage(driver) index_page.click_invest_btn() # 点击之后进入投资页面 invest_page = InvestPage(driver) # 需要使用到 用户页面进行用例执行 user_page = UserPage(driver) yield invest_page, user_page driver.quit()
class HandleLogin: def __init__(self, i): self.login_page = LoginPage(i) def send_username(self, username): self.login_page.get_username().send_keys(username) def send_password(self, password): self.login_page.get_password().send_keys(password) def click_agree(self): self.login_page.get_agree().click() def click_login_button(self): self.login_page.get_login_button().click() def get_error_info(self, msg): message = self.login_page.get_error_info().text if msg == message: return True else: return False
def setUpClass(cls): #只打开一次浏览器 cls.driver = webdriver.Firefox() #实例化page_login中的LoginPage类 cls.login_driver = LoginPage(cls.driver) cls.driver.open(login_url)
def __init__(self, i): self.login_page = LoginPage(i)