summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/project/pages
diff options
context:
space:
mode:
authorMavlushechka <mavlushechka@gmail.com>2022-10-17 22:18:25 +0500
committerMavlushechka <mavlushechka@gmail.com>2022-10-17 22:18:25 +0500
commita32de03308b2246f1e7cd4c970e6f96116b41ea1 (patch)
treed20f5c41028732cb72b46dda38ec584221f542e3 /src/main/java/com/mavlushechka/a1qa/project/pages
parentb41d2c22bf3e55123a09fae8b1d548dd9548299d (diff)
Divide classes into 2 packages: framework and project
Diffstat (limited to 'src/main/java/com/mavlushechka/a1qa/project/pages')
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/CommentForm.java29
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/CommentsForm.java33
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/FeedPage.java20
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/HomePage.java26
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/PostForm.java68
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/ProfilePage.java42
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/ProfileWallForm.java44
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/SideBarForm.java21
-rw-r--r--src/main/java/com/mavlushechka/a1qa/project/pages/SignInPage.java31
9 files changed, 314 insertions, 0 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/CommentForm.java b/src/main/java/com/mavlushechka/a1qa/project/pages/CommentForm.java
new file mode 100644
index 0000000..228e34d
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/CommentForm.java
@@ -0,0 +1,29 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.ILabel;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import com.mavlushechka.a1qa.project.models.Comment;
+import org.openqa.selenium.By;
+
+import java.util.Objects;
+
+public class CommentForm extends BaseForm {
+
+ private final ILabel commentLabel;
+ private final ILabel commentText;
+
+
+ public CommentForm(Comment comment) {
+ super(AqualityServices.getElementFactory().getLabel(By.id("post" + comment.user().getId() + "_" + comment.id()), "Comment"), "Comment form");
+ String commentXpath = "//*[@id='" + "post" + comment.user().getId() + "_" + comment.id() + "']";
+ commentLabel = AqualityServices.getElementFactory().getLabel(By.xpath(commentXpath), "Comment");
+ commentText = AqualityServices.getElementFactory().getLabel(By.xpath(commentXpath + "//*[contains(@class, 'wall_reply_text')]"), "Comment");
+ }
+
+ public boolean containsComment(Comment comment) {
+ return Integer.parseInt(commentLabel.getAttribute("data-answering-id")) == comment.user().getId()
+ && Objects.equals(commentText.getText(), comment.message());
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/CommentsForm.java b/src/main/java/com/mavlushechka/a1qa/project/pages/CommentsForm.java
new file mode 100644
index 0000000..4c022a6
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/CommentsForm.java
@@ -0,0 +1,33 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import com.mavlushechka.a1qa.project.models.Comment;
+import com.mavlushechka.a1qa.project.models.Post;
+import org.openqa.selenium.By;
+
+public class CommentsForm extends BaseForm {
+
+ private final IButton nextCommentsButton;
+
+
+ public CommentsForm(Post post) {
+ super(AqualityServices.getElementFactory().getLabel(By.id("replies_wrap" + post.owner().getId() + "_" + post.id()), "Comments"),
+ "Comments form");
+ nextCommentsButton = AqualityServices.getElementFactory().getButton(
+ By.xpath("//*[@id='" + "replies_wrap" + post.owner().getId() + "_" + post.id() + "']//*[contains(@class, 'replies_next')]"),
+ "Next comments"
+ );
+ }
+
+ public boolean containsComment(Comment comment) {
+ CommentForm commentForm = new CommentForm(comment);
+
+ if (nextCommentsButton.getElement().isDisplayed()) {
+ nextCommentsButton.click();
+ }
+ return commentForm.containsComment(comment);
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/FeedPage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/FeedPage.java
new file mode 100644
index 0000000..abc0f91
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/FeedPage.java
@@ -0,0 +1,20 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import org.openqa.selenium.By;
+
+public class FeedPage extends BaseForm {
+
+ private final SideBarForm sideBarForm = new SideBarForm();
+
+
+ public FeedPage() {
+ super(AqualityServices.getElementFactory().getLabel(By.id("main_feed"), "Main feed"), "Feed");
+ }
+
+ public void clickMyProfileButton() {
+ sideBarForm.clickMyProfileButton();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/HomePage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/HomePage.java
new file mode 100644
index 0000000..a4ab95c
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/HomePage.java
@@ -0,0 +1,26 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ITextBox;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import org.openqa.selenium.By;
+
+public class HomePage extends BaseForm {
+
+ private final ITextBox phoneOrEmailTextBox = AqualityServices.getElementFactory().getTextBox(By.id("index_email"), "Phone or email");
+ private final IButton signInButton = AqualityServices.getElementFactory().getButton(
+ By.xpath("//button[contains(@class, 'VkIdForm__signInButton')]"),"Sign in"
+ );
+
+
+ public HomePage() {
+ super(AqualityServices.getElementFactory().getLabel(By.xpath("//*[contains(@class, 'IndexPageContent')]"), "Index page content"), "Home");
+ }
+
+ public void performAuthorization(String phoneOrEmail) {
+ phoneOrEmailTextBox.clearAndType(phoneOrEmail);
+ signInButton.click();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/PostForm.java b/src/main/java/com/mavlushechka/a1qa/project/pages/PostForm.java
new file mode 100644
index 0000000..a3f8972
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/PostForm.java
@@ -0,0 +1,68 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ILabel;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import com.mavlushechka.a1qa.project.models.Comment;
+import com.mavlushechka.a1qa.project.models.Post;
+import org.openqa.selenium.By;
+
+import java.util.Objects;
+
+public class PostForm extends BaseForm {
+
+ private final ILabel authorLabel;
+ private final ILabel textLabel;
+ private final ILabel imageLabel;
+ private final IButton likeButton;
+
+
+ public PostForm(Post post) {
+ super(AqualityServices.getElementFactory().getLabel(By.id("post" + post.owner().getId() + "_" + post.id()), "Post"), "Post form");
+ String postXpath = "//*[@id='" + "post" + post.owner().getId() + "_" + post.id() + "']";
+ authorLabel = AqualityServices.getElementFactory().getLabel(
+ By.xpath(postXpath + "//*[contains(@class, 'post_author')]//a[contains(@class, 'author')]"), "Post author"
+ );
+ textLabel = AqualityServices.getElementFactory().getLabel(By.xpath(postXpath + "//*[contains(@class, 'wall_post_text')]"), "Post text");
+ imageLabel = AqualityServices.getElementFactory().getLabel(
+ By.xpath(postXpath + "//*[contains(@class, 'page_post_thumb_wrap')]"), "Post image"
+ );
+ likeButton = AqualityServices.getElementFactory().getButton(By.xpath(postXpath + "//*[@data-reaction-set-id='reactions']"), "Like");
+ }
+
+ public boolean containsPost(Post post) {
+ boolean containsPost = Objects.equals(authorLabel.getText(), post.owner().getFirstName() + " " + post.owner().getLastName())
+ && Objects.equals(textLabel.getText(), post.message());
+
+ if (post.attachment() != null) {
+ containsPost &= Objects.equals(post.attachment().toString(), imageLabel.getAttribute("href").split("vk.com/")[1]);
+ } else {
+ containsPost &= !imageLabel.state().isDisplayed();
+ }
+
+ return containsPost;
+ }
+
+ public boolean containsComment(Comment comment) {
+ return new CommentsForm(comment.post()).containsComment(comment);
+ }
+
+ public void clickLikeButton() {
+ likeButton.getElement().click();
+ }
+
+ public void waitForUpdate() {
+ String text = textLabel.getText();
+ AqualityServices.getConditionalWait().waitFor(() -> !Objects.equals(textLabel.getText(), text));
+ }
+
+ public void waitForDelete() {
+ AqualityServices.getConditionalWait().waitFor(() -> !postExists());
+ }
+
+ public boolean postExists() {
+ return authorLabel.state().isDisplayed();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/ProfilePage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/ProfilePage.java
new file mode 100644
index 0000000..ae99f22
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/ProfilePage.java
@@ -0,0 +1,42 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import com.mavlushechka.a1qa.project.models.Comment;
+import com.mavlushechka.a1qa.project.models.Post;
+import org.openqa.selenium.By;
+
+public class ProfilePage extends BaseForm {
+
+ private final ProfileWallForm profileWallForm = new ProfileWallForm();
+
+
+ public ProfilePage() {
+ super(AqualityServices.getElementFactory().getLabel(By.id("profile"), "Profile"), "Profile");
+ }
+
+ public boolean containsPost(Post post) {
+ return profileWallForm.containsPost(post);
+ }
+
+ public boolean containsComment(Comment comment) {
+ return profileWallForm.containsComment(comment);
+ }
+
+ public boolean notContainsPost(Post post) {
+ return profileWallForm.notContainsPost(post);
+ }
+
+ public void clickPostLikeButton(Post post) {
+ profileWallForm.clickPostLikeButton(post);
+ }
+
+ public void waitForPostUpdate(Post post) {
+ profileWallForm.waitForPostUpdate(post);
+ }
+
+ public void waitForPostDelete(Post post) {
+ profileWallForm.waitForPostDelete(post);
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/ProfileWallForm.java b/src/main/java/com/mavlushechka/a1qa/project/pages/ProfileWallForm.java
new file mode 100644
index 0000000..120e30f
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/ProfileWallForm.java
@@ -0,0 +1,44 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import com.mavlushechka.a1qa.project.models.Comment;
+import com.mavlushechka.a1qa.project.models.Post;
+import org.openqa.selenium.By;
+
+public class ProfileWallForm extends BaseForm {
+
+ public ProfileWallForm() {
+ super(AqualityServices.getElementFactory().getLabel(By.id("profile_wall"), "Profile wall"), "Profile wall form");
+ }
+
+ public boolean containsPost(Post post) {
+ PostForm postForm = new PostForm(post);
+
+ if (!postForm.isOpened()) {
+ return false;
+ }
+ return postForm.containsPost(post);
+ }
+
+ public boolean notContainsPost(Post post) {
+ return !new PostForm(post).postExists();
+ }
+
+ public boolean containsComment(Comment comment) {
+ return new PostForm(comment.post()).containsComment(comment);
+ }
+
+ public void clickPostLikeButton(Post post) {
+ new PostForm(post).clickLikeButton();
+ }
+
+ public void waitForPostUpdate(Post post) {
+ new PostForm(post).waitForUpdate();
+ }
+
+ public void waitForPostDelete(Post post) {
+ new PostForm(post).waitForDelete();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/SideBarForm.java b/src/main/java/com/mavlushechka/a1qa/project/pages/SideBarForm.java
new file mode 100644
index 0000000..01973ec
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/SideBarForm.java
@@ -0,0 +1,21 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import org.openqa.selenium.By;
+
+public class SideBarForm extends BaseForm {
+
+ private final IButton myProfileButton = AqualityServices.getElementFactory().getButton(By.id("l_pr"), "My profile");
+
+
+ public SideBarForm() {
+ super(AqualityServices.getElementFactory().getLabel(By.id("side_bar"), "Side bar"), "Side bar form");
+ }
+
+ public void clickMyProfileButton() {
+ myProfileButton.click();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/project/pages/SignInPage.java b/src/main/java/com/mavlushechka/a1qa/project/pages/SignInPage.java
new file mode 100644
index 0000000..872f87f
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/project/pages/SignInPage.java
@@ -0,0 +1,31 @@
+package com.mavlushechka.a1qa.project.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ITextBox;
+import com.mavlushechka.a1qa.framework.pages.BaseForm;
+import org.openqa.selenium.By;
+
+public class SignInPage extends BaseForm {
+
+ private final ITextBox passwordTextBox = AqualityServices.getElementFactory().getTextBox(
+ By.xpath("//input[contains(@name, 'password')]"), "Password"
+ );
+ private final IButton continueButton = AqualityServices.getElementFactory().getButton(
+ By.xpath("//*[contains(@class, 'vkc__EnterPasswordNoUserInfo__buttonWrap')]//button[contains(@class, 'vkuiButton')]"), "Continue"
+ );
+
+
+ public SignInPage() {
+ super(
+ AqualityServices.getElementFactory().getLabel(By.xpath("//form[contains(@class, 'vkc__EnterPasswordNoUserInfo__content')]"),
+ "Password form"), "Sign in"
+ );
+ }
+
+ public void performAuthorization(String password) {
+ passwordTextBox.clearAndType(password);
+ continueButton.click();
+ }
+
+}