class Test_Add_User: def setup_class(self): self.driver = init_driver() self.add_user_obj = Page_Obj(self.driver).address_add_user() def teardown_class(self): self.driver.quit() @pytest.fixture() def add_user_btn(self): # 点击添加用户按钮 self.add_user_obj.click_add() # @pytest.fixture(scope="class") # def save_local_btn(self): # # 点击本地保存 # self.add_user_obj.click_save_local() @pytest.mark.usefixtures("add_user_btn") # @pytest.mark.usefixtures("add_user_btn", "save_local_btn") @pytest.mark.parametrize("test_num,test_name,test_phone,expect_data",yaml_data()) def test_input_user_info(self,test_num,test_name,test_phone,expect_data): self.add_user_obj.input_user_info(test_name,test_phone) print("test_001", test_num) if test_num == "test_001": assert expect_data not in self.add_user_obj.get_user_list() else: assert expect_data in self.add_user_obj.get_user_list()
class Test_Add_User: def setup_class(self): self.driver = init_driver() self.add_user_obj = Page_Obj(self.driver).return_add_user() def teardown_class(self): self.driver.quit() @allure.step(title="点击新建联系人") @pytest.fixture() def add_user_btn(self): # 添加用户 self.add_user_obj.click_add() @allure.step(title="输入用户信息") @pytest.mark.usefixtures("add_user_btn") @pytest.mark.parametrize("test_num, name, phone, expect", read_test_data()) def test_input_user_info(self, test_num, name, phone, expect): self.add_user_obj.input_user_info(name, phone) if test_num == "test_user_001": assert expect not in self.add_user_obj.get_user_list() else: assert expect in self.add_user_obj.get_user_list()
class Test_Add_Page: def setup_class(self): self.driver = init_driver() self.add_obj = Page_Obj(self.driver).return_add_page() def teardown_class(self): self.driver.quit() @pytest.fixture() def click(self): # 点击新建联系人 self.add_obj.click_add() @pytest.mark.usefixtures("click") @pytest.mark.parametrize("test_num,name,phone", yaml_add_data()) def test_add(self, test_num, name, phone): print("用例编号:", test_num) self.add_obj.input_add_click_return(name, phone) self.driver.keyevent(4)
class Test_Add_User: def setup_class(self): self.driver = init_driver() self.add_user_obj = Page_Obj(self.driver).return_add_user() def teardown_class(self): self.driver.quit() @pytest.fixture() def add_user_btn(self): # 添加用户 self.add_user_obj.click_add() @pytest.fixture(scope="class") def save_local_btn(self): # 点击本地保存 self.add_user_obj.click_save_local() @pytest.mark.usefixtures("add_user_btn", "save_local_btn") @pytest.mark.parametrize("name, phone", [("李001", "13333333333"), ("李002", "13555555555")]) def test_input_user_info(self, name, phone): self.add_user_obj.input_user_info(name, phone)