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