Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll in direction #111

Merged
merged 8 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ POM-Framework.iml
*.iml
.DS_Store
/lib/
screenshots/
screenshots/
src/test/resources/pickleib.properties
57 changes: 44 additions & 13 deletions src/test/java/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import pages.FormsPage;
import pickleib.enums.Direction;
import pickleib.utilities.element.acquisition.ElementAcquisition;
import pickleib.web.driver.PickleibWebDriver;
import pickleib.web.driver.WebDriverFactory;
import pickleib.web.interactions.WebInteractions;
import utils.Printer;
import utils.StringUtilities;
import utils.arrays.ArrayUtilities;

import java.util.List;
import java.util.Map;

Expand All @@ -34,9 +34,9 @@ public class AppTest {
*/

@Before
public void before(){
ContextStore.loadProperties("test.properties");
WebDriverFactory.setHeadless(true);
public void before() {
ContextStore.loadProperties("test.properties", "pickleib.properties");
WebDriverFactory.setHeadless(Boolean.parseBoolean(ContextStore.get("headless", "true")));
WebDriverFactory.setUseWDM(false);
PickleibWebDriver.initialize();
this.driver = PickleibWebDriver.get();
Expand Down Expand Up @@ -69,8 +69,8 @@ public void navigateBrowserTest() {
}

@Test
public void formTitleTest(){
ElementAcquisition.Reflections< ObjectRepository > reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
public void formTitleTest() {
ElementAcquisition.Reflections<ObjectRepository> reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
List<WebElement> categories = reflections.getElementsFromPage("categories", "homePage");
WebElement forms = ElementAcquisition.acquireNamedElementAmongst(categories, "Forms");
webInteractions.clickElement(forms);
Expand All @@ -80,8 +80,8 @@ public void formTitleTest(){
}

@Test
public void completeFormSubmissionTest(){//TODO: Try soft assertions
ElementAcquisition.Reflections< ObjectRepository > reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
public void completeFormSubmissionTest() {//TODO: Try soft assertions
ElementAcquisition.Reflections<ObjectRepository> reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
List<WebElement> categories = reflections.getElementsFromPage("categories", "homePage");
WebElement forms = ElementAcquisition.acquireNamedElementAmongst(categories, "Forms");
webInteractions.clickElement(forms);
Expand Down Expand Up @@ -116,7 +116,7 @@ public void completeFormSubmissionTest(){//TODO: Try soft assertions
"Mobile", mobile,
"Date of Birth", "2024-2-23", // value format changes due to website date formatting
"Hobbies", hobbies,
"Current Address",address,
"Current Address", address,
"Gender", gender
);

Expand Down Expand Up @@ -148,17 +148,17 @@ public void completeFormSubmissionTest(){//TODO: Try soft assertions

List<WebElement> submissionEntries = reflections.getElementsFromPage("submissionEntries", "formsPage");

for (String entryKey: entries.keySet()){
for (String entryKey : entries.keySet()) {
WebElement entryValueElement = FormsPage.getEntryValue(entryKey, submissionEntries);
Assert.assertEquals("Data mismatch!", entries.get(entryKey), entryValueElement.getText());
}

log.success("The completeFormSubmissionTest() passed!");
}

@Test
public void scrollInContainerTest(){//TODO: Try soft assertions
ElementAcquisition.Reflections< ObjectRepository > reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
public void scrollInContainerTest() {//TODO: Try soft assertions
ElementAcquisition.Reflections<ObjectRepository> reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
List<WebElement> categories = reflections.getElementsFromPage("categories", "homePage");
WebElement interactions = ElementAcquisition.acquireNamedElementAmongst(categories, "Interactions");
webInteractions.clickElement(interactions);
Expand All @@ -177,6 +177,37 @@ public void scrollInContainerTest(){//TODO: Try soft assertions
log.success("scrollInContainerTest() pass!");
}

@Test
public void scrollInDirectionTest(){
ElementAcquisition.Reflections< ObjectRepository > reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
List<WebElement> categories = reflections.getElementsFromPage("categories", "homePage");
WebElement interactions = ElementAcquisition.acquireNamedElementAmongst(categories, "Interactions");
webInteractions.clickElement(interactions);
List<WebElement> tools = reflections.getElementsFromPage("tools", "interactionsPage");
WebElement dropdownTool = ElementAcquisition.acquireNamedElementAmongst(tools, "Tall Page");
webInteractions.clickElement(dropdownTool);
WebElement logo = reflections.getElementFromPage("logo", "tallPage");
Assert.assertFalse("Logo is already in view!", webInteractions.elementIsInView(logo));
webInteractions.scrollInDirection(Direction.down);
webInteractions.scrollInDirection(Direction.down);
Assert.assertTrue("Logo is not in view!", webInteractions.elementIsInView(logo));
}

@Test
public void centerElementTest(){
ElementAcquisition.Reflections< ObjectRepository > reflections = new ElementAcquisition.Reflections<>(ObjectRepository.class);
List<WebElement> categories = reflections.getElementsFromPage("categories", "homePage");
WebElement interactions = ElementAcquisition.acquireNamedElementAmongst(categories, "Interactions");
webInteractions.clickElement(interactions);
List<WebElement> tools = reflections.getElementsFromPage("tools", "interactionsPage");
WebElement dropdownTool = ElementAcquisition.acquireNamedElementAmongst(tools, "Tall Page");
webInteractions.clickElement(dropdownTool);
WebElement logo = reflections.getElementFromPage("logo", "tallPage");
Assert.assertFalse("Logo is already in view!", webInteractions.elementIsInView(logo));
webInteractions.centerElement(logo);
Assert.assertTrue("Logo is not in view!", webInteractions.elementIsInView(logo));
}

// @Test
// public void clickTest() {
// List<WebElement> categories = pageObjectReflections.getElementsFromPage("clickMeButton", "pages.PageClass");
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/common/ObjectRepository.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package common;

import pages.FormsPage;
import pages.HomePage;
import pages.InteractionsPage;
import pages.DropDownPage;
import pages.*;
import pickleib.utilities.interfaces.repository.PageRepository;

public class ObjectRepository implements PageRepository {
HomePage homePage = new HomePage();
FormsPage formsPage = new FormsPage();
InteractionsPage interactionsPage = new InteractionsPage();
DropDownPage dropDownPage = new DropDownPage();
TallPage tallPage = new TallPage();
}
14 changes: 14 additions & 0 deletions src/test/java/pages/TallPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import pickleib.web.PickleibPageObject;

public class TallPage extends PickleibPageObject {

@FindBy(id = "title")
WebElement title;

@FindBy(id = "logo")
WebElement logo;
}
3 changes: 0 additions & 3 deletions src/test/resources/pickleib.properties

This file was deleted.