Skip to content

Commit

Permalink
4914_cardTestsRefImageSizeAdded
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Nov 28, 2023
1 parent dbb38a2 commit c0c7f4b
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ public class CardPage extends NewAngularPage {
@UI("#card-with-alignment-align-end")
public static Card cardAlignEndActions;

@UI("#card-with-media-size-sm-image")
public static Card cardWithSmallImageSize;

@UI("#card-with-media-size-md-image")
public static Card cardWithMediumImageSize;

@UI("#card-with-media-size-lg-image")
public static Card cardWithLargeImageSize;

@UI("#card-with-media-size-xl-image")
public static Card cardWithExtraLargeImageSize;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.epam.angular.tests.elements.complex;

import com.epam.jdi.light.angular.elements.enums.CardImageSize;
import io.github.epam.TestsInit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Expand All @@ -9,7 +10,11 @@
import static io.github.com.pages.CardPage.card;
import static io.github.com.pages.CardPage.cardAlignEndActions;
import static io.github.com.pages.CardPage.cardAlignStartActions;
import static io.github.com.pages.CardPage.cardWithExtraLargeImageSize;
import static io.github.com.pages.CardPage.cardWithFooter;
import static io.github.com.pages.CardPage.cardWithLargeImageSize;
import static io.github.com.pages.CardPage.cardWithMediumImageSize;
import static io.github.com.pages.CardPage.cardWithSmallImageSize;
import static io.github.com.pages.CardPage.simpleCard;


Expand Down Expand Up @@ -71,4 +76,13 @@ public void alignPositionTest() {
cardAlignStartActions.show();
cardAlignStartActions.is().aligStartActions();
}

@Test(description = "Test verifies image size of the card")
public void sizeOfCardImageTest() {
cardWithSmallImageSize.has().cardImageSize(CardImageSize.SMALL);
cardWithMediumImageSize.has().cardImageSize(CardImageSize.MEDIUM);
cardWithLargeImageSize.has().cardImageSize(CardImageSize.LARGE);
cardWithExtraLargeImageSize.has().cardImageSize(CardImageSize.EXTRALARGE);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.complex.Card;
import com.epam.jdi.light.angular.elements.enums.CardImageSize;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -45,4 +46,11 @@ public CardAssert aligStartActions() {
"Card actions are in end align position");
return this;
}

@JDIAction("Assert that {name} has image '{0}' size")
public CardAssert cardImageSize( CardImageSize size) {
final CardImageSize actualCardImageSize = element().cardImageSize();
jdiAssert(actualCardImageSize, Matchers.is(size));
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package com.epam.jdi.light.angular.elements.complex;

import static com.epam.jdi.light.angular.elements.enums.CardImageSize.EXTRALARGE;
import static com.epam.jdi.light.angular.elements.enums.CardImageSize.LARGE;
import static com.epam.jdi.light.angular.elements.enums.CardImageSize.MEDIUM;
import static com.epam.jdi.light.angular.elements.enums.CardImageSize.SMALL;

import com.epam.jdi.light.angular.asserts.CardAssert;
import com.epam.jdi.light.angular.elements.enums.CardImageSize;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.common.UIElement;
Expand Down Expand Up @@ -71,13 +77,37 @@ public UIElement getButtonByNumber(int number) {
return this.getButtons().get(number);
}

@JDIAction("Get if {nave} has align end actions")
@JDIAction("Get if {name} has align end actions")
public boolean actionsEndAlign() {
return finds("mat-card-actions").hasClass("mat-mdc-card-actions-align-end");
return finds("mat-card-actions")
.hasClass("mat-mdc-card-actions-align-end");
}

@JDIAction("Get '{name}' size")
public CardImageSize cardImageSize() {
UIElement e = core().find("//img");
if (e.hasClass("mat-mdc-card-xl-image")) {
return EXTRALARGE;
}
if (e.hasClass("mat-mdc-card-lg-image")) {
return LARGE;
}
if (e.hasClass("mat-mdc-card-md-image")) {
return MEDIUM;
}
if (e.hasClass("mat-mdc-card-sm-image")) {
return SMALL;
}
return CardImageSize.UNKNOWN;
}

@Override
public CardAssert is() {
return new CardAssert().set(this);
}

@Override
public CardAssert has() {
return is();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.epam.jdi.light.angular.elements.enums;

public enum CardImageSize {

EXTRALARGE,
LARGE,
MEDIUM,
SMALL,
UNKNOWN;
}

0 comments on commit c0c7f4b

Please sign in to comment.