diff options
Diffstat (limited to 'src')
4 files changed, 45 insertions, 1 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/project/models/User.java b/src/main/java/com/mavlushechka/a1qa/project/models/User.java new file mode 100644 index 0000000..b3f3ea2 --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/project/models/User.java @@ -0,0 +1,4 @@ +package com.mavlushechka.a1qa.project.models; + +public record User(String login, String password) { +} diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java new file mode 100644 index 0000000..ae56c9a --- /dev/null +++ b/src/main/java/com/mavlushechka/a1qa/project/pages/ProjectsPage.java @@ -0,0 +1,24 @@ +package com.mavlushechka.a1qa.project.pages; + +import aquality.selenium.browser.AqualityServices; +import aquality.selenium.forms.Form; +import com.mavlushechka.a1qa.framework.utils.JsonParser; +import com.mavlushechka.a1qa.project.models.User; +import org.openqa.selenium.By; + +public class ProjectsPage extends Form { + + + private final String url = JsonParser.parseData("config", "browser.url") + "/web/projects"; + + + public ProjectsPage() { + super(By.xpath("//*[contains(@class, 'panel')]"), "Projects"); + } + + public void performAuthorization(User user) { + AqualityServices.getBrowser().goTo("%s:%s@%s".formatted(user.login(), user.password(), url.split("http://")[1])); + AqualityServices.getBrowser().goTo(url); + } + +} diff --git a/src/main/resources/testData.json b/src/main/resources/testData.json index b72cf8f..449804e 100644 --- a/src/main/resources/testData.json +++ b/src/main/resources/testData.json @@ -1,3 +1,7 @@ { - "variant": "2" + "variant": "2", + "user": { + "login": "login", + "password": "password" + } }
\ No newline at end of file diff --git a/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java b/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java index e50f89b..722b0da 100644 --- a/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java +++ b/src/test/java/com/mavlushechka/a1qa/project/TestCase1.java @@ -1,9 +1,13 @@ 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.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; @@ -14,6 +18,14 @@ public class TestCase1 extends BaseTest { 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(); } } |