-
Notifications
You must be signed in to change notification settings - Fork 47
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
4935 test refactoring element sidenav #5375
base: angular_rework_development
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package io.github.com.pages; | ||
|
||
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.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; | ||
|
||
@UI("#open-close-behavior mat-checkbox") | ||
public static Checkbox sideNavOpened; | ||
|
||
@UI("#open-close-behavior button") | ||
public static Button sideNavToggle; | ||
|
||
public static SideNav configurableMode; | ||
|
||
@UI("#configurable-mode .mat-sidenav button") | ||
public static Button sideToggle; | ||
|
||
@UI("#configurable-mode .mat-sidenav-content button") | ||
public static Button contentToggle; | ||
|
||
@UI("#configurable-mode .mat-sidenav .mat-mdc-radio-group") | ||
public static RadioGroup sideNavRadioGroup; | ||
@UI("#mat-select-position") | ||
public static MaterialSelectorContainer sideNavPosition; | ||
|
||
@UI("#mat-select-focus-on-the-first-item") | ||
public static MaterialSelectorContainer sideNavFocusSelection; | ||
|
||
@UI("#configurable-mode .mat-sidenav-content .mat-mdc-radio-group") | ||
public static RadioGroup contentRadioGroup; | ||
|
||
public static SideNav 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; | ||
|
||
@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; | ||
|
||
@UI("#fixed-position mat-checkbox") | ||
public static Checkbox fixSideNav; | ||
|
||
@UI("#fixed-position .mat-sidenav-content button") | ||
public static Button toggleFixedSideNav; | ||
|
||
@UI("#fixed-position .mat-sidenav-content mat-form-field input[formcontrolname='top']") | ||
public static TextField topGap; | ||
|
||
@UI("#fixed-position .mat-sidenav-content mat-form-field input[formcontrolname='bottom']") | ||
public static TextField bottomGap; | ||
|
||
public static SideNavSection sidenavBackdropDrawer; | ||
|
||
public static SideNav responsiveContent; | ||
|
||
@UI("//*[@id='responsive-content']/preceding-sibling::mat-toolbar/button") | ||
public static Button toolbarToggle; | ||
|
||
@UI("#mat-drawer-open-button") | ||
public static Button backDropToggle; | ||
|
||
@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')]") | ||
public static Button firstElementFocused; | ||
|
||
@UI("//button[.//span[contains(@class, 'mdc-button__label') and text()='Second Element']]") | ||
public static Button secondElement; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,46 @@ | |
|
||
import com.epam.jdi.light.elements.common.UIElement; | ||
import io.github.epam.TestsInit; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Ignore; | ||
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 io.github.com.StaticSite.angularPage; | ||
import static io.github.com.pages.sections.SideNavSection.*; | ||
import static io.github.epam.site.steps.States.shouldBeLoggedIn; | ||
import static com.jdiai.tools.Timer.waitCondition; | ||
import static io.github.com.StaticSite.sideNavPage; | ||
import static io.github.com.pages.SideNavPage.autoSizeSideNav; | ||
import static io.github.com.pages.SideNavPage.backDropToggle; | ||
import static io.github.com.pages.SideNavPage.basicDrawer; | ||
import static io.github.com.pages.SideNavPage.basicSideNav; | ||
import static io.github.com.pages.SideNavPage.bottomGap; | ||
import static io.github.com.pages.SideNavPage.configurableMode; | ||
import static io.github.com.pages.SideNavPage.contentRadioGroup; | ||
import static io.github.com.pages.SideNavPage.contentToggle; | ||
import static io.github.com.pages.SideNavPage.customEscapeBackdrop; | ||
import static io.github.com.pages.SideNavPage.firstElementFocused; | ||
import static io.github.com.pages.SideNavPage.fixSideNav; | ||
import static io.github.com.pages.SideNavPage.fixedPosition; | ||
import static io.github.com.pages.SideNavPage.implicitMainContent; | ||
import static io.github.com.pages.SideNavPage.openCloseBehavior; | ||
import static io.github.com.pages.SideNavPage.openSideNav; | ||
import static io.github.com.pages.SideNavPage.responsiveContent; | ||
import static io.github.com.pages.SideNavPage.sideNavFocusSelection; | ||
import static io.github.com.pages.SideNavPage.sideNavOpened; | ||
import static io.github.com.pages.SideNavPage.sideNavPosition; | ||
import static io.github.com.pages.SideNavPage.sideNavRadioGroup; | ||
import static io.github.com.pages.SideNavPage.sideNavToggle; | ||
import static io.github.com.pages.SideNavPage.sideToggle; | ||
import static io.github.com.pages.SideNavPage.sidenavBackdropContainer; | ||
import static io.github.com.pages.SideNavPage.sidenavBackdropDrawer; | ||
import static io.github.com.pages.SideNavPage.toggleAutoNav; | ||
import static io.github.com.pages.SideNavPage.toggleExtraText; | ||
import static io.github.com.pages.SideNavPage.toggleFixedSideNav; | ||
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 org.hamcrest.Matchers.containsString; | ||
|
||
// TODO Move to the new page | ||
@Ignore | ||
|
||
public class SideNavTests extends TestsInit { | ||
|
||
public static final String SIDE_NAV_CONTENT = "Sidenav content"; | ||
|
@@ -26,13 +53,14 @@ public class SideNavTests extends TestsInit { | |
public static final String MODE = "mode"; | ||
public static final String SIDE = "side"; | ||
|
||
@BeforeMethod(alwaysRun = true) | ||
@BeforeClass(alwaysRun = true) | ||
public void before() { | ||
shouldBeLoggedIn(); | ||
angularPage.shouldBeOpened(); | ||
sideNavPage.open(); | ||
waitCondition(() -> sideNavPage.isOpened()); | ||
sideNavPage.checkOpened(); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify that the basic sideNav is displayed") | ||
public void verifyBasicSideNavTest() { | ||
basicSideNav.show(); | ||
basicSideNav.is().displayed(); | ||
|
@@ -41,7 +69,7 @@ public void verifyBasicSideNavTest() { | |
basicSideNav.getContent().has().text(MAIN_CONTENT); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify that the basicDrawer sideNav is displayed") | ||
public void verifyBasicDrawerTest() { | ||
basicDrawer.show(); | ||
basicDrawer.is().displayed(); | ||
|
@@ -50,7 +78,37 @@ public void verifyBasicDrawerTest() { | |
basicDrawer.getMatDrawerContent().has().text(MAIN_CONTENT); | ||
} | ||
|
||
@Test | ||
@Test(description = "Tests confirm menu position changes for 'start' or 'end' selector options.") | ||
public void verifyPositionSelectionDrawerWithExplicitBackdropSettingSideNavTest() { | ||
sidenavBackdropContainer.show(); | ||
sidenavBackdropContainer.is().displayed(); | ||
sidenavBackdropContainer.is().enabled(); | ||
|
||
sideNavPosition.click(); | ||
sideNavPosition.select("End"); | ||
|
||
backDropToggle.click(); | ||
sidenavBackdropDrawer.is().displayed(); | ||
sidenavBackdropContainer.has().sideNavSectionOnTheRight(sidenavBackdropDrawer.getLocation()); | ||
} | ||
|
||
@Test(description = "Test verifies first menu item focus when 'true' is selected") | ||
public void verifyFocusSelectionDrawerWithExplicitBackdropSettingSideNavTest() { | ||
sidenavBackdropContainer.show(); | ||
sidenavBackdropContainer.is().displayed(); | ||
sidenavBackdropContainer.is().enabled(); | ||
|
||
sideNavFocusSelection.click(); | ||
sideNavFocusSelection.select("True"); | ||
|
||
backDropToggle.click(); | ||
|
||
firstElementFocused.base().timer().wait(() -> firstElementFocused.has().cssClass("cdk-program-focused")); | ||
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"); | ||
|
@@ -69,8 +127,9 @@ public void verifyImplicitMainContentWithTwoSideNavTest() { | |
implicitMainContent.getContent().is().enabled(); | ||
} | ||
|
||
@Test | ||
@Test(description = "Tests the opening and closing functionality of the component") | ||
public void verifyOpenCloseBehaviorTest() { | ||
refresh(); | ||
openCloseBehavior.show(); | ||
openCloseBehavior.getContent().is().displayed(); | ||
openCloseBehavior.getContent().is().enabled(); | ||
|
@@ -80,46 +139,49 @@ public void verifyOpenCloseBehaviorTest() { | |
|
||
sideNavOpened.click(); | ||
openCloseBehavior.base().timer().wait(() -> openCloseBehavior.isEnabled()); | ||
openCloseBehavior.getEvents().has().text("open!\nclose!"); | ||
openCloseBehavior.base().timer().wait(() -> openCloseBehavior.getEvents().has().text("open!\nclose!")); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify SideNav with with configurable mode") | ||
public void toggleConfigurableSideNavTest() { | ||
refresh(); | ||
configurableMode.show(); | ||
contentToggle.click(); | ||
configurableMode.base().timer().wait(() -> configurableMode.visualValidation(".mat-sidenav")); | ||
configurableMode.base().timer().wait(() -> configurableMode.getSideNav().has().attr(STYLE, STYLE_VISIBLE)); | ||
configurableMode.getSideNav().has().attr(STYLE, STYLE_VISIBLE); | ||
|
||
sideToggle.click(); | ||
configurableMode.base().timer().wait(() -> configurableMode.visualValidation(".mat-sidenav")); | ||
configurableMode.base().timer().wait(() -> configurableMode.getSideNav().has().attr(STYLE, STYLE_HIDDEN)); | ||
configurableMode.getSideNav().has().attr(STYLE, STYLE_HIDDEN); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify side radio group buttons") | ||
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: 258px;"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;"); | ||
|
||
sideNavRadioGroup.click("Push"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 258px; margin-right: -258px;"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;"); | ||
} | ||
|
||
@Test | ||
@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: 258px;"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 299px;"); | ||
|
||
contentRadioGroup.click("Push"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 258px; margin-right: -258px;"); | ||
configurableMode.getContent().has().attr(STYLE, "margin-left: 300px; margin-right: -300px;"); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify toggle button") | ||
public void closeByToggleTest() { | ||
refresh(); | ||
customEscapeBackdrop.show(); | ||
|
@@ -128,43 +190,41 @@ public void closeByToggleTest() { | |
customEscapeBackdrop.getContent().has().text(containsString("toggle button")); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify backdrop click behavior") | ||
public void closeByBackdropTest() { | ||
openSideNav.click(); | ||
customEscapeBackdrop.core().click(); | ||
customEscapeBackdrop.getContent().has().text(containsString("backdrop")); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify auto size SideNav") | ||
public void verifyAutoSizeSideNav() { | ||
autoSizeSideNav.show(); | ||
toggleAutoNav.click(); | ||
toggleExtraText.click(); | ||
autoSizeSideNav.getMatDrawer().has().text(containsString("Toggle extra text")); | ||
autoSizeSideNav.getMatDrawerContent().has().attr(STYLE, "margin-left: 294px;"); | ||
autoSizeSideNav.getMatDrawerContent().has().attr(STYLE, "margin-left: 303px;"); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify fixed sideNav") | ||
public void fixedSideNavTest() { | ||
String testValue = "100"; | ||
fixedPosition.show(); | ||
topGap.click(); | ||
topGap.clear(); | ||
topGap.sendKeys(testValue); | ||
bottomGap.click(); | ||
topGap.setValue(testValue); | ||
bottomGap.clear(); | ||
bottomGap.sendKeys(testValue); | ||
bottomGap.setValue(testValue); | ||
fixSideNav.click(); | ||
fixedPosition.getSideNav().has().attr(STYLE, "transform: none; visibility: visible; top: 100px; bottom: " + | ||
"100px;"); | ||
"100px;"); | ||
|
||
toggleFixedSideNav.click(); | ||
fixedPosition.base().timer().wait(() -> fixedPosition.visualValidation(".mat-sidenav-content")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. очень плохо, что нам нужно использовать классы в тестах, значит, что не сделан метод There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. исправил |
||
fixedPosition.getSideNav().has().attr(STYLE, "top: 100px; bottom: 100px; box-shadow: none; visibility: " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не надо проверять style, это не стабильно и базовый функционал, который проверяется в html пакете There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. убрал There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. все еще на месте |
||
"hidden;"); | ||
"hidden;"); | ||
} | ||
|
||
@Test | ||
@Test(description = "Verify toggle responsive sideNave") | ||
public void toggleResponsiveSideNavTest() { | ||
int[] testValues = {1, 3}; | ||
responsiveContent.show(); | ||
|
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.complex.SideNav; | ||
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 SideNaveAssert extends UIAssert<SideNaveAssert, SideNav> { | ||
|
||
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)); | ||
return this; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не надо вообще это проверять, оно еще и на разных разрешениях экранов может поехать
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрал