def onetime_setup(request,browser): print("Running one time setup") wdf=WebDriverFactory(browser) driver=wdf.getWebdriverInstance() lp = LP(driver) lp.loginsuccess('*****@*****.**', 'abcabc') if request.cls is not None: request.cls.driver=driver yield driver cp=CP(driver) cp.click_logout_CP_summed() sleep(2) driver.close()
class Test_login(): @pytest.fixture(autouse=True) def classlevelsetup(self,onetime_setup): self.lp=LP(self.driver) self.npc=NPC(self.driver) self.ts=TS(self.driver) @pytest.mark.skip def test2_validLogin(self): self.lp.loginsuccess('*****@*****.**','abcabc') @pytest.mark.run(order=1) def test1_invalid1(self): self.npc.click_log_out_Nav() sleep(3) self.lp.getLoginLink_click() self.lp.getEmailField_EnterID('*****@*****.**') self.lp.getLoginButton_click() result=self.lp.new_Assert_check(self.lp._failedloginerror,self.lp._locatorytype6) self.ts.mark_final(result,'test1_invalid1')
def test1_validlogin(setup): lp = LP(setup) lp.loginsuccess('*****@*****.**', 'abcabc')