Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created April 11, 2024 05:20
Show Gist options
  • Save SarahElson/0aeac69fb33058d64bfde00b8c77d1ed to your computer and use it in GitHub Desktop.
Save SarahElson/0aeac69fb33058d64bfde00b8c77d1ed to your computer and use it in GitHub Desktop.
How To Retry Failed Tests Using IRetryAnalyzer In TestNG
package io.github.mfaisal, the expected text is updated tostatic io.github.mfaisalkhatri.drivers.DriverManager.getDriver;
import static org.testng.Assert.assertEquals;
import io.github.mfaisalkhatri.listeners.Retry;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.HomePage;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.LoginPage;
import io.github.mfaisalkhatri.pages.lambdatestecommerce.SearchResultPage;
import io.github.mfaisalkhatri.tests.base.BaseSuiteSetup;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class RetryFailedTests extends BaseSuiteSetup {
private HomePage homePage;
@BeforeClass
public void setupTests () {
final String website = "https://ecommerce-playground.lambdatest.io/";
getDriver ().get (website);
this.homePage = new HomePage ();
}
@Test (retryAnalyzer = Retry.class)
public void testNavigationToLoginPage () {
final LoginPage loginPage = this.homePage.navigateToLoginPage ();
assertEquals (loginPage.loginBoxTitle (), "Returning Customesr");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment