class TestSearch: def setup_class(self): self.home = HomePage(self.driver) self.driver = Driver().get_driver() def teardown(self): self.driver.quit() def test_search_us(self): self.home.geto_search().select().get_price() def test_search_us_other(self): self.home.geto_search().select().getname() @pytest.mark.parametrize("search_name,expect", [("alibaba", "阿里巴巴"), ("xiaomi", "小米集团")]) def test_search(self, search_name, expect): text = self.home.geto_search().search(search_name).select().get_name() assert expect in text def test_add_optional(self): text = self.home.geto_search().search( "alibaba").add_optional().get_hint() assert text in "添加成功" def test_sure_optional(self): text = self.home.geto_search().search( "alibaba").add_optional().get_optional() assert text in "已添加" def test_delete_optional(self): pass
class TestPorfile: def setup(self): self.driver = Driver().get_driver() self.homepage = HomePage(self.driver) def teardown(self): time.sleep(3) self.driver.quit() def test_delete(self): text = self.homepage.goto_optional().delete() assert text in "已从自选删除"
class TestPorfile: def setup(self): self.driver = Driver().get_driver() self.homepage = HomePage(self.driver) def teardown(self): time.sleep(3) self.driver.quit() def test_login_wrong_phone(self): assert self.homepage.goto_profile().Login("1321312", "3123113") in "手机号码填写错误" def test_login_wrong_account(self): assert self.homepage.goto_profile().Login("13510234567", "3123113") in "用户名或密码错误"
class HomePage(BasePage): _optional = (By.XPATH, "//*[@text='自选' and contains(@resource-id,'tab_name')]") def __int__(self): self.driver = Driver().get_driver() def geto_search(self): self.driver.find_element(By.ID, "home_search").click() return SearchPage(self.driver) def goto_profile(self): self.driver.find_element( By.XPATH, "//*[contains(@resource-id,'user_profile_icon') and contains(@class,'ImageView')]" ).click() return ProfilePage(self.driver) def goto_optional(self): WebDriverWait(self.driver, 15).until( expected_conditions.text_to_be_present_in_element( self._optional, "自选")) self.driver.find_element(*self._optional).click() TouchAction(self.driver).tap(x=400, y=800, count=5).release().perform() return Option(self.driver)
def setup_class(self): self.home = HomePage(self.driver) self.driver = Driver().get_driver()
def setup(self): self.driver = Driver().get_driver() self.homepage = HomePage(self.driver)
def __int__(self): self.driver = Driver().get_driver()