summaryrefslogtreecommitdiff
path: root/src/main/java/com/mavlushechka/a1qa/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/mavlushechka/a1qa/pages')
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/BaseForm.java11
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/CommentForm.java28
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/CommentsForm.java32
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/FeedPage.java19
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/HomePage.java25
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/PostForm.java67
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/ProfilePage.java41
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/ProfileWallForm.java43
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/SideBarForm.java20
-rw-r--r--src/main/java/com/mavlushechka/a1qa/pages/SignInPage.java30
10 files changed, 311 insertions, 5 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/pages/BaseForm.java b/src/main/java/com/mavlushechka/a1qa/pages/BaseForm.java
index 3ac855a..8ed6026 100644
--- a/src/main/java/com/mavlushechka/a1qa/pages/BaseForm.java
+++ b/src/main/java/com/mavlushechka/a1qa/pages/BaseForm.java
@@ -1,20 +1,21 @@
package com.mavlushechka.a1qa.pages;
-import com.mavlushechka.a1qa.elements.BaseElement;
+import aquality.selenium.elements.interfaces.IElement;
+import aquality.selenium.elements.interfaces.ILabel;
public abstract class BaseForm {
- protected final BaseElement uniqueElement;
- protected final String name;
+ private final IElement uniqueElement;
+ private final String name;
- public BaseForm(BaseElement uniqueElement, String name) {
+ public BaseForm(ILabel uniqueElement, String name) {
this.uniqueElement = uniqueElement;
this.name = name;
}
public boolean isOpened() {
- return uniqueElement.isVisible();
+ return uniqueElement.getElement().isDisplayed();
}
public String getName() {
diff --git a/src/main/java/com/mavlushechka/a1qa/pages/CommentForm.java b/src/main/java/com/mavlushechka/a1qa/pages/CommentForm.java
new file mode 100644
index 0000000..d087336
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/CommentForm.java
@@ -0,0 +1,28 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.ILabel;
+import com.mavlushechka.a1qa.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 contains(Comment comment) {
+ return Objects.equals(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/pages/CommentsForm.java b/src/main/java/com/mavlushechka/a1qa/pages/CommentsForm.java
new file mode 100644
index 0000000..4ae6a01
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/CommentsForm.java
@@ -0,0 +1,32 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import com.mavlushechka.a1qa.models.Comment;
+import com.mavlushechka.a1qa.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 contains(Comment comment) {
+ CommentForm commentForm = new CommentForm(comment);
+
+ if (nextCommentsButton.getElement().isDisplayed()) {
+ nextCommentsButton.click();
+ }
+ return commentForm.contains(comment);
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/pages/FeedPage.java b/src/main/java/com/mavlushechka/a1qa/pages/FeedPage.java
new file mode 100644
index 0000000..bebecc1
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/FeedPage.java
@@ -0,0 +1,19 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+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/pages/HomePage.java b/src/main/java/com/mavlushechka/a1qa/pages/HomePage.java
new file mode 100644
index 0000000..20339f8
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/HomePage.java
@@ -0,0 +1,25 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ITextBox;
+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/pages/PostForm.java b/src/main/java/com/mavlushechka/a1qa/pages/PostForm.java
new file mode 100644
index 0000000..dc5f8b0
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/PostForm.java
@@ -0,0 +1,67 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ILabel;
+import com.mavlushechka.a1qa.models.Comment;
+import com.mavlushechka.a1qa.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 contains(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 contains(Comment comment) {
+ return new CommentsForm(comment.post()).contains(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(this::notExists);
+ }
+
+ public boolean notExists() {
+ return !authorLabel.state().isDisplayed();
+ }
+
+}
diff --git a/src/main/java/com/mavlushechka/a1qa/pages/ProfilePage.java b/src/main/java/com/mavlushechka/a1qa/pages/ProfilePage.java
new file mode 100644
index 0000000..816517d
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/ProfilePage.java
@@ -0,0 +1,41 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import com.mavlushechka.a1qa.models.Comment;
+import com.mavlushechka.a1qa.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 contains(Post post) {
+ return profileWallForm.contains(post);
+ }
+
+ public boolean contains(Comment comment) {
+ return profileWallForm.contains(comment);
+ }
+
+ public boolean notContains(Post post) {
+ return profileWallForm.notContains(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/pages/ProfileWallForm.java b/src/main/java/com/mavlushechka/a1qa/pages/ProfileWallForm.java
new file mode 100644
index 0000000..d8ddc37
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/ProfileWallForm.java
@@ -0,0 +1,43 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import com.mavlushechka.a1qa.models.Comment;
+import com.mavlushechka.a1qa.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 contains(Post post) {
+ PostForm postForm = new PostForm(post);
+
+ if (!postForm.isOpened()) {
+ return false;
+ }
+ return postForm.contains(post);
+ }
+
+ public boolean notContains(Post post) {
+ return new PostForm(post).notExists();
+ }
+
+ public boolean contains(Comment comment) {
+ return new PostForm(comment.post()).contains(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/pages/SideBarForm.java b/src/main/java/com/mavlushechka/a1qa/pages/SideBarForm.java
new file mode 100644
index 0000000..8df8c3d
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/SideBarForm.java
@@ -0,0 +1,20 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+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/pages/SignInPage.java b/src/main/java/com/mavlushechka/a1qa/pages/SignInPage.java
new file mode 100644
index 0000000..56c16e7
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/pages/SignInPage.java
@@ -0,0 +1,30 @@
+package com.mavlushechka.a1qa.pages;
+
+import aquality.selenium.browser.AqualityServices;
+import aquality.selenium.elements.interfaces.IButton;
+import aquality.selenium.elements.interfaces.ITextBox;
+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();
+ }
+
+}