Home > Mobile >  How to loop 10 times a single test in selenium using serenity framework
How to loop 10 times a single test in selenium using serenity framework

Time:12-15

i would like to know is there any way to run a single test of selenium for n number of times. i could do this using JMeter but my task requirement is to use selenium with serenity framework.

CodePudding user response:

You can use serenity-junit5 to achieve this goal. JUnit5 has @RepeatedTest(n) to run a test in n times. Code example:

import net.serenitybdd.junit5.SerenityJUnit5Extension;
import net.thucydides.core.annotations.Managed;
import org.junit.jupiter.api.RepeatedTest;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.WebDriver;

@ExtendWith(SerenityJUnit5Extension.class)
public class GoToGoogle {

    @Managed
    WebDriver driver;

    @RepeatedTest(2)
    void name() {
        driver.get("https://google.com");
    }
}
  • Related