diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java index ac6a892f19c..8f68f0be2eb 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/CardTests.java @@ -2,7 +2,7 @@ import com.epam.jdi.light.angular.elements.enums.CardImageSize; import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.jdiai.tools.Timer.waitCondition; @@ -19,11 +19,11 @@ public class CardTests extends TestsInit { - @BeforeMethod + @BeforeClass public void before() { cardPage.open(); waitCondition(() -> cardPage.isOpened()); - cardPage.checkOpened(); + cardPage.checkOpened(); } @Test(description = "Test verifies that card is displayed") @@ -34,22 +34,21 @@ public void displayedBasicCardTest() { @Test(description = "Test verifies card text and image") public void attributeCardTest() { - simpleCard.is().cardText("Simple card"); - card.is().altImageAttribute("Photo of a Shiba Inu"); - card.is().srcImageAttribute("https://material.angular.io/assets/img/examples/shiba2.jpg"); + simpleCard.has().cardText("Simple card"); + card.has().altImageAttribute("Photo of a Shiba Inu"); + card.has().srcImageAttribute("https://material.angular.io/assets/img/examples/shiba2.jpg"); } @Test(description = "Test verifies that elements of the card are displayed") public void displayedCardTest() { card.show(); card.getHeader().is().displayed(); - card.getHeaderText().is().displayed(); card.getAvatar().is().displayed(); card.getTitle().is().displayed(); card.getTitle().is().text("Shiba Inu"); card.getSubtitle().is().displayed(); card.getSubtitle().is().text("Dog Breed"); - card.getImage().is().displayed(); + card.image().is().displayed(); card.getContent().is().displayed(); cardWithFooter.show(); cardWithFooter.getFooter().is().displayed(); @@ -58,7 +57,7 @@ public void displayedCardTest() { @Test(description = "Test verifies number and text of card buttons") public void cardButtonsTest() { card.show(); - card.is().numberOfButtonsOnCard(2); + card.has().numberOfButtonsOnCard(2); card.getButtonByNumber(1).is().text("LIKE"); card.getButtonByNumber(2).is().text("SHARE"); } @@ -72,17 +71,17 @@ public void cardButtonsClickTest() { @Test(description = "Test verifies that align end and start actions position") public void alignPositionTest() { cardAlignEndActions.show(); - cardAlignEndActions.is().alignEndActions(); + cardAlignEndActions.has().alignEndActions(); cardAlignStartActions.show(); - cardAlignStartActions.is().aligStartActions(); + cardAlignStartActions.has().alignStartActions(); } @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); + cardWithSmallImageSize.has().imageSize(CardImageSize.SMALL); + cardWithMediumImageSize.has().imageSize(CardImageSize.MEDIUM); + cardWithLargeImageSize.has().imageSize(CardImageSize.LARGE); + cardWithExtraLargeImageSize.has().imageSize(CardImageSize.EXTRALARGE); } } diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java index fba247c9076..ecdeddfce79 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CardAssert.java @@ -17,13 +17,13 @@ public CardAssert cardText(String value) { @JDIAction("Assert that '{name}' alt image attribute has text '{0}'") public CardAssert altImageAttribute(String value) { - jdiAssert(element().getImage().getAttribute("alt").contains(value), Matchers.is(true)); + jdiAssert(element().image().attr("alt").contains(value), Matchers.is(true)); return this; } - @JDIAction("Assert that '{name}' src image attribute has text '{0}'") + @JDIAction("Assert that '{name}' src image attribute has value '{0}'") public CardAssert srcImageAttribute(String value) { - jdiAssert(element().getImage().getAttribute("src").contains(value), Matchers.is(true)); + jdiAssert(element().image().attr("src").contains(value), Matchers.is(true)); return this; } @@ -41,14 +41,14 @@ public CardAssert alignEndActions() { } @JDIAction("Assert that '{name}' has align start actions") - public CardAssert aligStartActions() { + public CardAssert alignStartActions() { jdiAssert(element().actionsEndAlign(), Matchers.is(false), "Card actions are in end align position"); return this; } @JDIAction("Assert that {name} has image '{0}' size") - public CardAssert cardImageSize(CardImageSize size) { + public CardAssert imageSize(CardImageSize size) { final CardImageSize actualCardImageSize = element().cardImageSize(); jdiAssert(actualCardImageSize, Matchers.is(size)); return this; diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java index 1d247b27a41..09b6f8febbf 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/Card.java @@ -11,6 +11,7 @@ import com.epam.jdi.light.elements.base.UIBaseElement; import com.epam.jdi.light.elements.common.UIElement; import com.epam.jdi.light.elements.complex.WebList; +import com.epam.jdi.light.ui.html.elements.common.Image; /** * To see an example of Card web element please visit https://material.angular.io/components/card/overview. @@ -32,11 +33,6 @@ public UIElement getAvatar() { return this.find(".mat-mdc-card-avatar"); } - @JDIAction("Get '{name}' header text") - public UIElement getHeaderText() { - return this.find(".mat-mdc-card-header-text"); - } - @JDIAction("Get '{name}' title") public UIElement getTitle() { return this.find(".mat-mdc-card-title"); @@ -47,9 +43,18 @@ public UIElement getSubtitle() { return this.find(".mat-mdc-card-subtitle"); } + @JDIAction("Get if '{name}' has image") + public boolean hasImage() { + return find("//img").isExist(); + } + @JDIAction("Get '{name}' image") - public UIElement getImage() { - return this.find("//img"); + public Image image() { + if (hasImage()) { + return new Image().setCore(Image.class, find("//img")); + } else { + throw new RuntimeException("Element doesn't have image"); + } } @JDIAction("Get '{name}' content")