I have an automation framework TestNG + Selenide which runs jobs on Jenkins and provides Allure reports. I've added a test class with some simple tests. One test occasionally fails when trying to click an element, but rerunning fixes the problem, so naturally I wanted to introduce retries for this test.
Here comes the problem - failed tests are not retried. I've tried IRetryAnalyzer/RetryAnalyzerCount added via annotation transformer or adding retryAnalyzer to @Test annotation, but no success.
My current configuration:
public class RetryAnalyzer extends RetryAnalyzerCount {
private static final int MAX_RETRY_ATTEMPTS = 3;
public RetryAnalyzer() {
setCount(MAX_RETRY_ATTEMPTS);
}
@Override
public boolean retryMethod(ITestResult iTestResult) {
return true;
}
}
public class AnnotationTransformer implements IAnnotationTransformer {
private final Logger logger = LoggerFactory.getLogger(AnnotationTransformer.class);
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
annotation.setRetryAnalyzer(RetryAnalyzer.class);
logger.debug("SET RETRY ANALYZER FOR TEST {}", testMethod.getName());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="E2 widget tests" thread-count="6" parallel="classes" data-provider-thread-count="3">
<listeners>
<listener class-name="framework.AnnotationTransformer"/>
</listeners>
<test name="E2 widgets - chrome">
<parameter name="browser" value="chrome"/>
<parameter name="width" value="1366"/>
<parameter name="height" value="786"/>
<packages>
<package name="tests.other.e2widgets" />
</packages>
</test>
</suite>
My test + dataprovider it's using
@DataProvider(name = "countries-with-odds-widget-enabled", parallel = true)
public Object[][] countriesWithOddsWidgetEnabled() {
List<String> oddsWidgetCountries = sevWidgetSteps.getOddsWidgetCountries(configUrl);
List<Object[]> parameters = oddsWidgetCountries.stream().map(country -> new Object[]{country}).collect(Collectors.toList());
return parameters.toArray(new Object[1][parameters.size()]);
}
@Test(description = "Check odds widget for all countries",
dataProvider = "countries-with-odds-widget-enabled"
)
public void checkOddsWidgetsForEnabledCountries(String country) {
...some code...
// here test fails because of ElementClickInterceptedException
$(By.id("3__match-calendar-link")).click();
proxy.stop();
softly.assertAll();
}
Error I see in the allure report:
Invalid element state [[id*='match-calendar-link'][3]]: element click intercepted: Element <a id="3__match-calendar-link" class="zh Eh">...</a> is not clickable at point (690, 296). Other element would receive the click: <div class="Mg"></div>
Screenshot: file:/Users/jenkins/workspace/UI-SANDBOX/build/reports/tests/1653409276041.25.png
Page source: file:/Users/jenkins/workspace/UI-SANDBOX/build/reports/tests/1653409276041.25.html
Timeout: 10 s.
Caused by: ElementClickInterceptedException: element click intercepted: Element <a id="3__match-calendar-link" class="zh Eh">...</a> is not clickable at point (690, 296). Other element would receive the click: <div class="Mg"></div>
I expect the test to be retried if that click method fails, but in allure report I can see no retries, though if method doesn't fail at this point but later due to assertion - it will be retried. Hope somebody can help me to figure this out, thanks in advance