class TestContact: def setup(self): self.main_page = LoginPage().scan_login() def test_get_members(self): """ 1.进入首页--点击通讯录跳转通讯录页面--获取成员列表 :return: """ print(self.main_page.goto_contacts().get_member_list()) print("hello") @pytest.mark.parametrize('phones', [['13411111116', '13411111114']]) def test_del_members(self, phones): member_list_before = self.main_page.goto_contacts().get_member_list() tip_locator = (By.ID, "js_tips") contact_page = self.main_page.goto_contacts().del_members(phones) WebDriverWait(self.main_page.driver, 10).until(expected_conditions.invisibility_of_element(tip_locator)) # tip_text = self.main_page.driver.find_element(By.ID, "js_tips").text tip_text = self.main_page.driver.execute_script("el = document.getElementById('js_tips');return el.textContent") member_list_after = contact_page.get_member_list() print("member_list_before=%s,长度=%d" % (member_list_before, len(member_list_before))) print("member_list_after=%s,长度=%d" % (member_list_after, len(member_list_after))) print("tip_text=%s" % tip_text) pytest.assume(len(member_list_before)-len(phones) == len(member_list_after)) pytest.assume(tip_text == "删除成功")
class TestDepart: def setup(self): self.contact_page = LoginPage().scan_login().goto_contacts() @pytest.mark.parametrize('depart_name, parent_depart_name', [('test022', 'test02')]) def test_add_depart(self, depart_name, parent_depart_name): self.contact_page.goto_add_depart().add_department( depart_name, parent_depart_name) assert "新建部门成功" == self.contact_page.driver.find_element( By.CSS_SELECTOR, '#js_tips').text assert depart_name in self.contact_page.get_depart_list() def test_get_depart_list(self): print(self.contact_page.get_depart_list())
def goto_login_page(self): """ 点击企业登录 :return:跳转登录页面 """ login_locator = (By.CSS_SELECTOR, ".index_top_operation_loginBtn") self.wait_and_click(login_locator) return LoginPage(self.driver)
def test_login2(self): main_page = LoginPage().scan_login()
def setup(self): self.contact_page = LoginPage().scan_login().goto_contacts()
def setup(self): self.main_page = LoginPage().scan_login()
class TestMainPage: def setup_class(self): self.main_page = LoginPage().scan_login() def test_goto_contacts(self): self.main_page.goto_contacts()