diff options
author | Mavlushechka <mavlushechka@gmail.com> | 2022-11-02 22:08:22 +0500 |
---|---|---|
committer | Mavlushechka <mavlushechka@gmail.com> | 2022-11-03 21:22:39 +0500 |
commit | 24a46668d6f7ca9308890b0c7133c3bc41839cfd (patch) | |
tree | 5613249f5432db65536a82a14618ecb8fdd8a1e2 /src | |
parent | ac1a4d36a14695a2284198574f198997db8fe659 (diff) |
Solve the 3rd step of the TestCase1 test case
Diffstat (limited to 'src')
4 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/project/constants/Project.java b/src/main/java/com/mavlushechka/a1qa/project/constants/Project.java new file mode 100644 index 0000000..a8c9421 --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/project/constants/Project.java @@ -0,0 +1,15 @@ +package com.mavlushechka.a1qa.project.constants; + +public enum Project { + + BERCUT(3), BRAND_ALLEY(2), ENVISIA(5), LOTA(6), MEGAFON(4), NEXAGE(1); + + + public final int id; + + + Project(int id) { + this.id = id; + } + +} diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java index ae56c9a..f0428a3 100644 --- a/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java +++ b/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java @@ -1,8 +1,10 @@ package com.mavlushechka.a1qa.project.pages; import aquality.selenium.browser.AqualityServices; +import aquality.selenium.elements.ElementType; import aquality.selenium.forms.Form; import com.mavlushechka.a1qa.framework.utils.JsonParser; +import com.mavlushechka.a1qa.project.constants.Project; import com.mavlushechka.a1qa.project.models.User; import org.openqa.selenium.By; @@ -21,4 +23,12 @@ public class ProjectsPage extends Form { AqualityServices.getBrowser().goTo(url); } + public void openProject(Project project) { + AqualityServices.getElementFactory().get( + ElementType.BUTTON, + By.xpath("//*[contains(@class, 'panel')]//*[contains(@class, 'list-group')]//a[contains(@class, 'list-group-item') and @href='allTests?projectId=%d']".formatted(project.id)), + "Project" + ).clickAndWait(); + } + } diff --git a/src/main/java/com/mavlushechka/a1qa/project/utils/SiteApiUtils.java b/src/main/java/com/mavlushechka/a1qa/project/utils/SiteApiUtils.java index 88d0b93..5579448 100644 --- a/src/main/java/com/mavlushechka/a1qa/project/utils/SiteApiUtils.java +++ b/src/main/java/com/mavlushechka/a1qa/project/utils/SiteApiUtils.java @@ -15,7 +15,11 @@ public class SiteApiUtils { } public static String generateToken(int variant) throws IOException { - return UrlConnectionManager.post("%s/token/get?variant=%s".formatted(url, variant)); + return UrlConnectionManager.post("%s/token/get?variant=%d".formatted(url, variant)); + } + + public static String getTestsJson(int projectId) throws IOException { + return UrlConnectionManager.post("%s/test/get/json?projectId=%d".formatted(url, projectId)); } } diff --git a/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java b/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java index 722b0da..80b67b9 100644 --- a/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java +++ b/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java @@ -4,6 +4,7 @@ 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; @@ -26,6 +27,10 @@ public class TestCase1 extends BaseTest { 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); } } |