简体   繁体   中英

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

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.

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");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM