1 回答

TA貢獻1883條經驗 獲得超3個贊
因此,我假設您的登錄頁面的URL與實際應用程序中的任何頁面的URL不同。如果您還沒有 testng @BeforeTest則可以創建一個方法,并在新的或現有的測試前方法中包含以下內容:
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
}
一種稍微光滑的方法(我認為)是實現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;
}
}
添加回答
舉報