class TestSetting: def setup(self): self.driver = BaseDriver.get_driver() self.setting = PageSetting() time.sleep(1) def teardown(self): BaseDriver.quit_driver() @pytest.mark.parametrize("args", read_setting("page_setting_data", "test_setting")) def test_setting(self, args): self.setting.page_setting(args["name"])
class TestSetting(): # 初始化 def setup(self): self.driver = GetDriver().get_driver() # 获取PageSetting对象 self.setting = PageSetting(self.driver) # 结束 def teardown(self): # 错误写法,千万不能直接关闭,因为driver获取的时候使用时单例模式,而关闭必须置空操作 # 默认这种关闭方法没有置空操作 # self.driver.quit() # 正确方式 self.setting.driver.quit() # 测试方法 def test_setting(self,value="123"): self.setting.page_setting(value)
class TestSearch(): # 实例化页面对象 def setup_class(self): self.search = PageSetting(get_driver()) # 关闭驱动 def teardown_class(self): self.search.driver.quit() # 根据测试步骤调用page @pytest.mark.parametrize("text", ["123"]) def testsearch(self, text): # 点击搜索 self.search.page_search() # 输入123 self.search.page_input(text) # 点击返回 self.search.page_click() def test_o1(self): print("hahaahah") def test_02(self): print("mmmm")
class TestSetting(): def setup_class(self): self.setting = PageSetting(get_driver()) def teardown_class(self): self.setting.driver.quit() @pytest.mark.parametrize("number",["白菜"]) def test_setting(self,number): self.setting.page_click_shousuo() self.setting.page_input(number) self.setting.page_click_fanhui()
def setting(self): return PageSetting(self.driver)
def setup_class(self): self.search = PageSetting(get_driver())
def setup(self): self.driver = BaseDriver.get_driver() self.setting = PageSetting() time.sleep(1)
def setup(self): self.driver = GetDriver().get_driver() # 获取PageSetting对象 self.setting = PageSetting(self.driver)
def page_get_shezhi(self): return PageSetting(get_driver())