summaryrefslogtreecommitdiff
path: root/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java
blob: 80b67b9375da2edf499630f6f9bd6027c206f9a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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.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 option number.");
        String token = SiteApiUtils.generateToken(Integer.parseInt(JsonParser.parseData("testData", "variant")));

        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);
        AqualityServices.getBrowser().getDriver().manage().addCookie(new Cookie("token", token));
        AqualityServices.getBrowser().refresh();

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

}