searchPage.py 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. from selenium.webdriver.common.by import By
  2. from base.WebKeys import WebKeys
  3. class SearchPage(WebKeys):
  4. def search_book(self,book,url=None):
  5. if url:
  6. self.open(url)
  7. # 功能 搜索书籍的目的是为了知道 我的列表有没有这个本书
  8. self.locator_with_wait(By.ID,"searchKey").send_keys(book)
  9. self.locator_with_wait(By.ID,"btnSearch").click()
  10. # 加载我的书籍列表
  11. book_list=self.locator_with_wait(By.ID,"bookList")
  12. # 获得书
  13. book_rows=book_list.find_elements(By.TAG_NAME,"tr")
  14. # 获得书名
  15. book_found=[]
  16. for row in book_rows:
  17. # 循环了每一本书
  18. book_name_ele=row.find_element(By.CSS_SELECTOR,".name>a")
  19. book_name=book_name_ele.text
  20. book_found.append(book_name)
  21. return book_found
  22. # 断言 我输入的书名 在不在 书籍列表
  23. # 作业:测试报告写全一点 page也可以多写点流程 pom实现一下代码 生成测试报告
  24. # 有问题1 没问题 2