Skip to content

Commit

Permalink
4914_cardRefacInterm1
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Dec 4, 2023
1 parent 167f204 commit eb655f7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -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();
Expand All @@ -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");
}
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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");
Expand All @@ -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")
Expand Down

0 comments on commit eb655f7

Please sign in to comment.