1 回答

TA貢獻(xiàn)1883條經(jīng)驗(yàn) 獲得超3個(gè)贊
因此,我假設(shè)您的登錄頁面的URL與實(shí)際應(yīng)用程序中的任何頁面的URL不同。如果您還沒有 testng @BeforeTest則可以創(chuàng)建一個(gè)方法,并在新的或現(xiàn)有的測試前方法中包含以下內(nèi)容:
if (driver.getCurrentUrl() == "whatever.yourLoginPageUrl.is") {
//call login method or do whatever you have to do to login
//If you want to rerun the previous test that probably failed, do that here
}
一種稍微光滑的方法(我認(rèn)為)是實(shí)現(xiàn)IRetryAnalyzer接口并覆蓋重試功能,例如
public class MyRetry implements IRetryAnalyzer {
@Override
public boolean retry(ITestResult result) {
if (driver.getCurrentUrl() == "loginPageUrl") {
//call login function or do whatever you need to to login
return true;
}
return false;
}
}
添加回答
舉報(bào)