# 登陆相关的放在这里面 后面登陆功能改变了 在进行这个页面更改 # 继承这个工具类 ,直接调用这个工具类的方法 直接拿工具使用 import allure from selenium.webdriver.common.by import By from selenium import webdriver from base.WebKeys import WebKeys # 在page页面一般不进行断言 测试用例才进行断言 # 定位元素 用例里面 专门来个文件夹 保存元素定位的 from locator.AllPages import * class LoginPage(WebKeys): def login(self,username,password): with allure.step("访问浏览器"): self.open("http://novel.hctestedu.com/user/login.html") with allure.step(f"输入用户名{username}"): self.locator_with_wait(*username_loc).send_keys(username) with allure.step("输入密码{}".format(password)): self.locator_with_wait(*password_loc).send_keys(password) with allure.step("点击登陆"): self.on_click(*loginbtn_loc) def get_result_true(self,txt): result=self.text_wait(*login_assert_true,txt) return result def get_result_text(self): result=self.get_text(*login_assert_text) return result # 浏览器可以放在conftest里面是不是 if __name__ == '__main__': login_page=LoginPage(webdriver.Chrome()) sjmsg=login_page.login("15574113907","123456") print(sjmsg)