package com.mavlushechka.a1qa.project; import aquality.selenium.browser.AqualityServices; import com.mavlushechka.a1qa.framework.BaseTest; import com.mavlushechka.a1qa.framework.utils.JsonParser; import com.mavlushechka.a1qa.framework.utils.LoggerUtils; import com.mavlushechka.a1qa.project.constants.Project; import com.mavlushechka.a1qa.project.models.User; import com.mavlushechka.a1qa.project.pages.ProjectsPage; import com.mavlushechka.a1qa.project.utils.SiteApiUtils; import org.openqa.selenium.Cookie; import org.testng.Assert; import org.testng.annotations.Test; import java.io.IOException; public class TestCase1 extends BaseTest { @Test public void test1() throws IOException { LoggerUtils.step("Query the api to retrieve the token according to the variant number."); int variant = Integer.parseInt(JsonParser.parseData("testData", "variant")); String token = SiteApiUtils.generateToken(variant); Assert.assertNotEquals(token, null, "The token is null."); ProjectsPage projectsPage = new ProjectsPage(); User user = JsonParser.convertToObject(JsonParser.parseObject("testData", "user"), User.class); LoggerUtils.step("Go to the website. Complete the necessary authorisation." + "Transfer the token (parameter token) generated in step 1 using a cookie. Refresh the page."); projectsPage.performAuthorization(user); Assert.assertTrue(projectsPage.state().waitForDisplayed(), "The %s page is not opened.".formatted(projectsPage.getName())); AqualityServices.getBrowser().getDriver().manage().addCookie(new Cookie("token", token)); AqualityServices.getBrowser().refresh(); Assert.assertEquals(projectsPage.getVersion(), variant, "The variant is not correct."); LoggerUtils.step("Go to the Nexage project page. Query the api to get a list of tests in JSON/XML format."); projectsPage.openProject(Project.NEXAGE); String testsJson = SiteApiUtils.getTestsJson(Project.NEXAGE.id); } }