K
K
koryapin2021-11-29 11:59:50
Java
koryapin, 2021-11-29 11:59:50

How to make tests in a test?

Rivet, a question on the structure of autotests.

now autotests are performed as follows:

1 test:
authorization on the site
add an item to the cart
close the site

2 test:
authorization on the site
increase the number of items in the basket
close the site

3 test:
authorization on the site
remove an item from the basket
close the site

How to log in 1 time, perform the necessary tests (3 pcs) and close the site 1 time?

Or tell me what to google I

use Java Selenium WD JUnit

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
koryapin, 2021-11-30
@koryapin

In short, everything was easy

public abstract class BaseUITest1 {

    protected static WebDriver driver;

    @BeforeAll
    public static void setUp() {
        WebDriverManager.chromedriver().setup();

        ChromeOptions options = new ChromeOptions();
        options.addArguments("--disable-notifications");
        options.addArguments("--disable-popup-blocking");
        options.addArguments("--start-maximized");
        options.setPageLoadStrategy(PageLoadStrategy.NORMAL);

        driver = new ChromeDriver(options);

        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.get(BASE_URL);

        new AuthorizationPage(driver)
             .AuthoriseScenario(Configuration.LOGIN, Configuration.PASSWORD)
             .clickFirstAssistantCard();
    }

    @AfterAll
    public static void tearDown() {
        driver.quit();
    }
    
}

package Features.Interface;

import Base.BaseUITest;
import Base.BaseUITest1;
import Common.Configuration;
import Pages.AuthorizationPage;
import Pages.ConductorPage;
import io.qameta.allure.Feature;
import io.qameta.allure.Severity;
import io.qameta.allure.SeverityLevel;
import org.junit.jupiter.api.*;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@Feature("Conductor")

public class ConductorTest extends BaseUITest1 {



    @Test
    @Order(1)
    @DisplayName("Добавление навыка")
    @Severity(SeverityLevel.CRITICAL)
    public void AddingSkill() {
        new ConductorPage(driver)
                .hoverMouseSkillsSection()
                .clickPlusButtonSkill()
                .clickNameNavElement()
                .clearNameNavElement()
                .pause(1)
                .inputNameNavElement("Навык тест")
                .pushEnter()
                .pause(3)
                .checkAssertSkill();
    }

    @Test
    @Order(2)
    @DisplayName("Переименование навыка")
    @Severity(SeverityLevel.TRIVIAL)
    public void RenamingSkill() {
        new ConductorPage(driver)
                .pushRightMouseButtonExplorer()
                .clickContextButton2()
                .inputNewNameElement("Навык тест новый")
                .pushEnterRename()
                .pause(3)
                .checkNewNameSkill();
    }
}

B
BorLaze, 2021-11-29
@BorLaze

@BeforeClass @AfterClass Executed
once before/after all tests in the class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question