Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.github.com.enums;

public enum ConfigurableMode {

OVER("over"),
SIDE("side"),
PUSH("push");

private final String mode;

ConfigurableMode(String mode) {
this.mode = mode;
}

public String getMode() {
return mode;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

обычно еще делают метод получения Enum по строковому значению

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@

import com.epam.jdi.light.angular.elements.common.Button;
import com.epam.jdi.light.angular.elements.common.Checkbox;
import com.epam.jdi.light.angular.elements.complex.SideNav;
import com.epam.jdi.light.angular.elements.complex.radiobuttons.RadioGroup;
import com.epam.jdi.light.angular.elements.composite.MaterialSelectorContainer;
import com.epam.jdi.light.angular.elements.composite.SideNavContainer;
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
import com.epam.jdi.light.ui.html.elements.common.TextField;
import io.github.com.pages.sections.SideNavSection;

public class SideNavPage extends NewAngularPage {

public static SideNav basicSideNav;
public static SideNav basicDrawer;
public static SideNav sidenavBackdropContainer;
public static SideNav implicitMainContent;
public static SideNav openCloseBehavior;
public static SideNavContainer basicSideNav;
public static SideNavContainer basicDrawer;
public static SideNavContainer sidenavBackdropContainer;
public static SideNavContainer implicitMainContent;
public static SideNavContainer openCloseBehavior;

@UI("#open-close-behavior mat-checkbox")
public static Checkbox sideNavOpened;

@UI("#open-close-behavior button")
public static Button sideNavToggle;

public static SideNav configurableMode;
public static SideNavContainer configurableMode;

@UI("#configurable-mode .mat-sidenav button")
public static Button sideToggle;
Expand All @@ -42,23 +42,23 @@ public class SideNavPage extends NewAngularPage {
@UI("#configurable-mode .mat-sidenav-content .mat-mdc-radio-group")
public static RadioGroup contentRadioGroup;

public static SideNav customEscapeBackdrop;
public static SideNavContainer customEscapeBackdrop;

@UI("#custom-escape-backdrop .mat-sidenav button")
public static Button toggleSideNav;

@UI("#custom-escape-backdrop .mat-sidenav-content button")
public static Button openSideNav;

public static SideNav autoSizeSideNav;
public static SideNavContainer autoSizeSideNav;

@UI("#auto-size-side-nav .mat-drawer-content button")
public static Button toggleAutoNav;

@UI("#auto-size-side-nav .mat-drawer button")
public static Button toggleExtraText;

public static SideNav fixedPosition;
public static SideNavContainer fixedPosition;

@UI("#fixed-position mat-checkbox")
public static Checkbox fixSideNav;
Expand All @@ -74,7 +74,7 @@ public class SideNavPage extends NewAngularPage {

public static SideNavSection sidenavBackdropDrawer;

public static SideNav responsiveContent;
public static SideNavContainer responsiveContent;

@UI("//*[@id='responsive-content']/preceding-sibling::mat-toolbar/button")
public static Button toolbarToggle;
Expand All @@ -85,7 +85,8 @@ public class SideNavPage extends NewAngularPage {
@UI("//button[.//span[contains(@class, 'mdc-button__label') and text()='First Element']]")
public static Button firstElement;

@UI("//button[.//span[contains(@class, 'mdc-button__label') and text()='First Element'] and contains(@class, 'cdk-focused')]")
// @UI("//button[.//span[contains(@class, 'mdc-button__label') and text()='First Element'] and contains(@class, 'cdk-focused')]")
@UI("//button[contains(@class, 'cdk-focused') and contains(@class, 'cdk-program-focused') and //span[contains(@class, 'mdc-button__label') and text()='First Element']]")
public static Button firstElementFocused;

@UI("//button[.//span[contains(@class, 'mdc-button__label') and text()='Second Element']]")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package io.github.epam.angular.tests.elements.complex;

import com.epam.jdi.light.elements.common.UIElement;
import com.epam.jdi.light.angular.elements.complex.SideNav;
import io.github.epam.TestsInit;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import static com.epam.jdi.light.elements.composite.WebPage.refresh;
import static com.jdiai.tools.StringUtils.format;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.sideNavPage;
import static io.github.com.enums.ConfigurableMode.OVER;
import static io.github.com.enums.ConfigurableMode.PUSH;
import static io.github.com.enums.ConfigurableMode.SIDE;
import static io.github.com.pages.SideNavPage.autoSizeSideNav;
import static io.github.com.pages.SideNavPage.backDropToggle;
import static io.github.com.pages.SideNavPage.basicDrawer;
Expand Down Expand Up @@ -39,6 +41,7 @@
import static io.github.com.pages.SideNavPage.toggleSideNav;
import static io.github.com.pages.SideNavPage.toolbarToggle;
import static io.github.com.pages.SideNavPage.topGap;
import static java.lang.String.format;
import static org.hamcrest.Matchers.containsString;


Expand All @@ -51,7 +54,6 @@ public class SideNavTests extends TestsInit {
public static final String STYLE_VISIBLE = "transform: none; visibility: visible;";
public static final String STYLE_HIDDEN = "box-shadow: none; visibility: hidden;";
public static final String MODE = "mode";
public static final String SIDE = "side";

@BeforeClass(alwaysRun = true)
public void before() {
Expand Down Expand Up @@ -103,24 +105,24 @@ public void verifyFocusSelectionDrawerWithExplicitBackdropSettingSideNavTest() {

backDropToggle.click();

firstElementFocused.base().timer().wait(() -> firstElementFocused.has().cssClass("cdk-program-focused"));
firstElementFocused.has().text("First Element");
firstElementFocused.is().displayed();
firstElementFocused.is().focused();
}

@Test(description = "Verify main content is properly displayed alongside two side navigation panels")
public void verifyImplicitMainContentWithTwoSideNavTest() {
implicitMainContent.show();
UIElement startSideNav = implicitMainContent.getSideNav("start");
UIElement endSideNav = implicitMainContent.getSideNav("end");
SideNav start = implicitMainContent.getSideNav("start");
SideNav end = implicitMainContent.getSideNav("end");

startSideNav.has().attr(MODE, SIDE);
startSideNav.has().attr(STYLE, STYLE_VISIBLE);
startSideNav.has().text("Start content");
start.has().attr(MODE, SIDE.getMode());
start.has().attr(STYLE, STYLE_VISIBLE);
start.has().text("Start content");

endSideNav.has().attr(MODE, SIDE);
endSideNav.has().attr(STYLE, STYLE_VISIBLE);
endSideNav.has().text("End content");
end.has().attr(MODE, SIDE.getMode());
end.has().attr(STYLE, STYLE_VISIBLE);
end.has().text("End content");

implicitMainContent.getContent().has().text("Implicit main content");
implicitMainContent.getContent().is().displayed();
Expand All @@ -138,8 +140,8 @@ public void verifyOpenCloseBehaviorTest() {
openCloseBehavior.getSideNav().has().text(SIDE_NAV_CONTENT);

sideNavOpened.click();
openCloseBehavior.base().timer().wait(() -> openCloseBehavior.isEnabled());
openCloseBehavior.base().timer().wait(() -> openCloseBehavior.getEvents().has().text("open!\nclose!"));
openCloseBehavior.isEnabled();
openCloseBehavior.getEvents().has().text("open!\nclose!");
}

@Test(description = "Verify SideNav with with configurable mode")
Expand All @@ -159,26 +161,31 @@ public void toggleConfigurableSideNavTest() {
public void sideRadioGroupTest() {
refresh();
contentToggle.click();
configurableMode.getContent().has().attr(STYLE, "");

sideNavRadioGroup.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content"));
sideNavRadioGroup.click("Side");
configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;");
sideNavRadioGroup.show();
configurableMode.getContent().is().displayed();
configurableMode.getMatDrawer().has().configurableMode(OVER.getMode());

sideNavRadioGroup.click("Push");
configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;");
sideNavRadioGroup.click(SIDE.getMode());
configurableMode.getContent().is().displayed();
configurableMode.getMatDrawer().has().configurableMode(SIDE.getMode());

sideNavRadioGroup.click(PUSH.getMode());
configurableMode.getContent().is().displayed();
configurableMode.getMatDrawer().has().configurableMode(PUSH.getMode());
}

@Test(description = "Verify content radio group buttons")
public void contentRadioButtonsTest() {
refresh();
contentToggle.click();
sideNavRadioGroup.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content"));
sideNavRadioGroup.click("Side");
configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;");
sideNavRadioGroup.show();

sideNavRadioGroup.click(SIDE.getMode());
configurableMode.getMatDrawer().has().configurableMode(SIDE.getMode());

contentRadioGroup.click("Push");
configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;");
contentRadioGroup.click(PUSH.getMode());
configurableMode.getMatDrawer().has().configurableMode(PUSH.getMode());
}

@Test(description = "Verify toggle button")
Expand All @@ -203,7 +210,6 @@ public void verifyAutoSizeSideNav() {
toggleAutoNav.click();
toggleExtraText.click();
autoSizeSideNav.getMatDrawer().has().text(containsString("Toggle extra text"));
autoSizeSideNav.getMatDrawerContent().has().attr(STYLE, "margin-left: 303px;");
}

@Test(description = "Verify fixed sideNav")
Expand All @@ -219,7 +225,8 @@ public void fixedSideNavTest() {
"100px;");

toggleFixedSideNav.click();
fixedPosition.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content"));

fixedPosition.base().timer().wait(() -> fixedPosition.getSideNav().is().hidden());
fixedPosition.getSideNav().has().attr(STYLE, "top: 100px; bottom: 100px; box-shadow: none; visibility: " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не надо проверять style, это не стабильно и базовый функционал, который проверяется в html пакете

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрал

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

все еще на месте

"hidden;");
}
Expand All @@ -230,7 +237,7 @@ public void toggleResponsiveSideNavTest() {
responsiveContent.show();
toolbarToggle.click();
for (int value : testValues) {
responsiveContent.getSideNavLinks().get(value).click();
responsiveContent.getSideNav().getSideNavLinks().get(value).click();
responsiveContent.getResponsiveResults().get(value).has().text(format("Selected Nav Item %d", value));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.composite.SideNavContainer;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
import org.openqa.selenium.Point;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;

public class SideNavContainerAssert extends UIAssert<SideNavContainerAssert, SideNavContainer> {

private static final String LOCATION_ERROR_MESSAGE = "SideNavSection with location %s isn't on the right side";

@JDIAction(value = "Assert that '{name}' has section with location '{0}' on the right side", isAssert = true)
public SideNavContainerAssert sideNavSectionOnTheRight(Point locationOfSection) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем нам проверять, что-то по координатам?

jdiAssert(element().isSectionInRightPart(locationOfSection), Matchers.is(true),
String.format(LOCATION_ERROR_MESSAGE, locationOfSection));
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.complex.SideNav;
import com.epam.jdi.light.asserts.generic.ITextAssert;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.openqa.selenium.Point;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;
import static java.lang.String.format;

public class SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> {
public class SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> implements ITextAssert<SideNaveAssert> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public class SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> implements ITextAssert<SideNaveAssert> {
public class SideNavAssert extends UIAssert<SideNaveAssert, SideNav> implements ITextAssert<SideNaveAssert> {

private static final String MAT_DRAWER_TEMPLATE = "mat-drawer-%s";

private static final String LOCATION_ERROR_MESSAGE = "SideNavSection with location %s isn't on the right side";

@JDIAction(value = "Assert that '{name}' has section with location '{0}' on the right side", isAssert = true)
public SideNaveAssert sideNavSectionOnTheRight(Point locationOfSection) {
jdiAssert(element().isSectionInRightPart(locationOfSection), Matchers.is(true),
String.format(LOCATION_ERROR_MESSAGE, locationOfSection));
@JDIAction(value = "Assert that '{name}' text {0}", isAssert = true)
@Override
public SideNaveAssert text(Matcher<String> condition) {
jdiAssert(element().getSideNaveText(), condition);
return this;
}

@JDIAction(value = "Assert that '{name}' text is '{0}'", isAssert = true)
@Override
public SideNaveAssert text(String text) {
return text(Matchers.is(text));
}

@JDIAction(value = "Assert that '{name}' has class '{0}'", isAssert = true)
public void configurableMode(String mode) {
this.cssClass(format(MAT_DRAWER_TEMPLATE, mode.toLowerCase()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ public SideNaveAssert has() {
return is();
}

@JDIAction("Get '{name}' side nav")
public UIElement getSideNav() {
return this.find(".mat-sidenav");
}

@JDIAction("Get '{name}' side nav content")
public UIElement getContent() {
return this.find(".mat-sidenav-content");
}

/*for several side navs*/
@JDIAction("Get '{name}' side nav by '{0}' position value")
public UIElement getSideNav(String position) {
Expand All @@ -46,40 +36,23 @@ public UIElement getSideNav(String position) {
return element;
}

@JDIAction("Get '{name}' side nav content")
public UIElement getEvents() {
return getContent().find(".example-events");
}

@JDIAction("Get '{name}' side nav content")
public WebList getSideNavLinks() {
return getSideNav().finds("a");
}

@JDIAction("Get '{name}' side nav content")
public WebList getResponsiveResults() {
return getContent().finds("p");
return this.finds("a");
}

@JDIAction("Get '{name}' side nav items")
private WebList getSideNavItems() {
return this.finds(".mat-sidenav");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it is possible to have sidenav inside sidenav?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

/*mat-drawer*/
@JDIAction("Get '{name}' mat drawer")
public UIElement getMatDrawer() {
return this.find(".mat-drawer");
}

@JDIAction("Get '{name}' mat drawer content content")
public UIElement getMatDrawerContent() {
return this.find(".mat-drawer-content");
}

@JDIAction("Is '{name}' side nav has section with location '{0}' on right side")
public boolean isSectionInRightPart(Point locationOfSection) {
int containerCenterX = this.getLocation().getX() + this.getSize().getWidth() / 2;
return locationOfSection.getX() >= containerCenterX;
}

public String getSideNaveText() {
return core().text();
}
}
Loading