loginPage.py 1.4 KB

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