diff --git a/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ComparisonDialogOverlay.java b/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ComparisonDialogOverlay.java index 5ebb505d0..71f0be8b1 100644 --- a/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ComparisonDialogOverlay.java +++ b/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ComparisonDialogOverlay.java @@ -1,5 +1,6 @@ package io.testerra.report.test.pages.report.methodReport; +import eu.tsystems.mms.tic.testframework.pageobjects.AbstractComponent; import eu.tsystems.mms.tic.testframework.pageobjects.Check; import eu.tsystems.mms.tic.testframework.pageobjects.Page; import eu.tsystems.mms.tic.testframework.pageobjects.PreparedLocator; @@ -10,59 +11,72 @@ import java.util.HashMap; -public class ComparisonDialogOverlay extends Page implements AssertProvider { +public class ComparisonDialogOverlay extends AbstractComponent implements AssertProvider { @Check - private final UiElement contrastIcon = findIconInDialog("compare"); + private final UiElement contrastIcon = find(By.xpath("//mdc-icon[text() = 'compare']")); @Check - private final UiElement switchIcon = findIconInDialog("compare_arrows"); + private final UiElement switchIcon = find(By.xpath("//mdc-icon[text() = 'compare_arrows']")); @Check private final UiElement leftSelection = find(By.xpath("//mdc-select[@label='Left']")); @Check private final UiElement rightSelection = find(By.xpath("//mdc-select[@label='Right']")); @Check private final UiElement slider= find(By.xpath("//div[contains(@class,'slider')]")); - private final UiElement selectedItemLeft = leftSelection.find(By.xpath("//span[contains(@class,'selected-text')]")); - private final UiElement selectedItemRight = rightSelection.find(By.xpath("//span[contains(@class,'selected-text')]")); - PreparedLocator itemLocator = LOCATE.prepare("//span[text()='%s']"); +// private final UiElement selectedItemLeft = leftSelection.find(By.xpath("//span[contains(@class,'selected-text')]")); +// private final UiElement selectedItemRight = rightSelection.find(By.xpath("//span[contains(@class,'selected-text')]")); +// PreparedLocator itemLocator = LOCATE.prepare("//span[text()='%s']"); - public ComparisonDialogOverlay(WebDriver webDriver) { - super(webDriver); - } + private final UiElement content = find(By.xpath("//div[contains(@class,'img-comp-container')]")); + + PreparedLocator selectedScreenshotOption = LOCATE.prepare("//mdc-select[@label='%s']//span[contains(@class,'selected-text')]//span[text()='%s']"); + + private final UiElement closeIcon = find(By.xpath("//button//span[text()='clear']")); - private UiElement findIconInDialog(String icon){ - return find(By.xpath(String.format("//mdc-icon[text()='%s']",icon))); + public ComparisonDialogOverlay(UiElement rootElement) { + super(rootElement); } public ReportDetailsTab closeDialog() { - UiElement closeBtn = find(By.xpath("//button//span[text()='clear']")); - closeBtn.click(); + this.closeIcon.click(); return createPage(ReportDetailsTab.class); } - public void checkSelectedAndContentFromStartingMatched(String state) { - HashMap stateMapping = new HashMap(); - stateMapping.put("Actual", "Difference"); - stateMapping.put("Difference", "Expected"); - stateMapping.put("Expected", "Difference"); + public void checkContent(final ReportDetailsTab.ScreenshotType leftType, final ReportDetailsTab.ScreenshotType rightType, final String imageName) { + UiElement leftSelectedOption = find(selectedScreenshotOption.with("Left", leftType.toString())); + UiElement rightSelectedOption = find(selectedScreenshotOption.with("Right", rightType.toString())); - HashMap screenshotMapping = new HashMap(); - screenshotMapping.put("Actual", "actual_difference_referenceImage"); - screenshotMapping.put("Difference", "difference_expected_referenceImage"); - screenshotMapping.put("Expected", "expected_difference_referenceImage"); + leftSelectedOption.assertThat().displayed(true); + rightSelectedOption.assertThat().displayed(true); - CONTROL.collectAssertions(()->{ - UiElement defaultSelectedItemLeft = selectedItemLeft.find(itemLocator.with(state)); - UiElement imgContent = find(By.xpath("//div[contains(@class,'img-comp-container')]")); - defaultSelectedItemLeft.expect().displayed(true); - String expectedRightState = stateMapping.get(state); - String screenshotReference = screenshotMapping.get(state); - ASSERT.assertNotNull(expectedRightState); - - UiElement defaultSelectedItemRight = selectedItemRight.find(itemLocator.with(expectedRightState)); - defaultSelectedItemRight.expect().displayed(true); - imgContent.expect().screenshot().pixelDistance(screenshotReference).isLowerThan(10); + final String referenceImageName = String.format("%s_%s_%s", imageName, leftType, rightType); + this.content.assertThat().screenshot().pixelDistance(referenceImageName).isLowerThan(1); + } - }); +// public void checkSelectedAndContentFromStartingMatched(String state) { +// HashMap stateMapping = new HashMap(); +// stateMapping.put("Actual", "Difference"); +// stateMapping.put("Difference", "Expected"); +// stateMapping.put("Expected", "Difference"); +// +// HashMap screenshotMapping = new HashMap(); +// screenshotMapping.put("Actual", "actual_difference_referenceImage"); +// screenshotMapping.put("Difference", "difference_expected_referenceImage"); +// screenshotMapping.put("Expected", "expected_difference_referenceImage"); +// +// CONTROL.collectAssertions(()->{ +// UiElement defaultSelectedItemLeft = selectedItemLeft.find(itemLocator.with(state)); +// UiElement imgContent = find(By.xpath("//div[contains(@class,'img-comp-container')]")); +// defaultSelectedItemLeft.expect().displayed(true); +// String expectedRightState = stateMapping.get(state); +// String screenshotReference = screenshotMapping.get(state); +// ASSERT.assertNotNull(expectedRightState); +// +// UiElement defaultSelectedItemRight = selectedItemRight.find(itemLocator.with(expectedRightState)); +// defaultSelectedItemRight.expect().displayed(true); +// imgContent.expect().screenshot().pixelDistance(screenshotReference).isLowerThan(10); +// +// }); +// +// } - } } diff --git a/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ReportDetailsTab.java b/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ReportDetailsTab.java index 03c2f2ef7..302ccea8e 100644 --- a/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ReportDetailsTab.java +++ b/report-ng-tests/src/main/java/io/testerra/report/test/pages/report/methodReport/ReportDetailsTab.java @@ -53,6 +53,9 @@ public class ReportDetailsTab extends AbstractReportMethodPage { private final UiElement layoutComparison = find(By.xpath("//layout-comparison")); PreparedLocator imgTitleLocator = LOCATE.prepare("//img[contains(@title,'%s')]"); + // Root element of every overly component + private final UiElement dialogRoot = find(By.xpath("//div[@class = 'mdc-dialog__container']")); + public ReportDetailsTab(WebDriver driver) { super(driver); } @@ -211,9 +214,15 @@ public boolean hasFailureAspectAScreenshotComparison(String failureMessage) { return this.getFailureAspectElement(failureMessage).find(By.xpath("//layout-comparison")).waitFor().present(true); } - public ComparisonDialogOverlay openComparisonDialogByClickingOnScreenShot(String imageTitle) { - UiElement image = layoutComparison.find(imgTitleLocator.with(imageTitle)); + public ComparisonDialogOverlay openComparisonDialogByClickingOnScreenShot(final ScreenshotType screenshotType) { + UiElement image = layoutComparison.find(imgTitleLocator.with(screenshotType.toString())); image.click(); - return createPage(ComparisonDialogOverlay.class); + return createComponent(ComparisonDialogOverlay.class, this.dialogRoot); + } + + public enum ScreenshotType { + Actual, + Difference, + Expected; } } diff --git a/report-ng-tests/src/test/java/io/testerra/report/test/report_test/common/LayoutTest.java b/report-ng-tests/src/test/java/io/testerra/report/test/report_test/common/LayoutTest.java index 26ff16305..9eefca686 100644 --- a/report-ng-tests/src/test/java/io/testerra/report/test/report_test/common/LayoutTest.java +++ b/report-ng-tests/src/test/java/io/testerra/report/test/report_test/common/LayoutTest.java @@ -30,6 +30,7 @@ import io.testerra.report.test.pages.report.sideBarPages.ReportDashBoardPage; import io.testerra.report.test.pages.report.sideBarPages.ReportTestsPage; import org.testng.annotations.Test; +import io.testerra.report.test.pages.report.methodReport.ReportDetailsTab.ScreenshotType; public class LayoutTest extends AbstractReportTest { @@ -153,27 +154,30 @@ public void testT05_checkPassedLayoutTestAndFailedAssertion() { } @Test - public void testT06_checkLayoutDialog(){ + public void testT06_checkLayoutDialog() { String methodName = "layoutTest01_layoutTestFailing"; String className = "GenerateLayoutTestsTTReportTest"; - String[] imageTitles = new String[]{ - "Actual", - "Difference", - "Expected" - }; +// String[] imageTitles = new String[]{ +// "Actual", +// "Difference", +// "Expected" +// }; TestStep.begin("Navigate to details page"); ReportDashBoardPage reportDashBoardPage = this.gotoDashBoardOnAdditionalReport(WEB_DRIVER_MANAGER.getWebDriver()); ReportTestsPage reportTestsPage = reportDashBoardPage.gotoToReportPage(ReportSidebarPageType.TESTS, ReportTestsPage.class); reportTestsPage.selectClassName(className); ReportDetailsTab reportDetailsTab = reportTestsPage.navigateToDetailsTab(methodName); - TestStep.begin("Open Layout Dialog"); - for(String title: imageTitles){ - ComparisonDialogOverlay comparisonDialogOverlay = reportDetailsTab.openComparisonDialogByClickingOnScreenShot(title); - comparisonDialogOverlay.checkSelectedAndContentFromStartingMatched(title); - reportDetailsTab = comparisonDialogOverlay.closeDialog(); - } + + TestStep.begin("Open Layout Dialog from actual image"); +// for(String title: imageTitles){ +// ComparisonDialogOverlay comparisonDialogOverlay = reportDetailsTab.openComparisonDialogByClickingOnScreenShot(title); + ComparisonDialogOverlay comparisonDialogOverlay = reportDetailsTab.openComparisonDialogByClickingOnScreenShot(ScreenshotType.Actual); + comparisonDialogOverlay.checkContent(ScreenshotType.Actual, ScreenshotType.Difference, "layout_compare_dialog"); +// comparisonDialogOverlay.checkSelectedAndContentFromStartingMatched(title); + reportDetailsTab = comparisonDialogOverlay.closeDialog(); +// } } } diff --git a/report-ng-tests/src/test/resources/test.properties b/report-ng-tests/src/test/resources/test.properties index 9e7caa8b6..5dfb7075f 100644 --- a/report-ng-tests/src/test/resources/test.properties +++ b/report-ng-tests/src/test/resources/test.properties @@ -25,7 +25,6 @@ tt.browser.maximize=false tt.display.resolution=1600x1024 #tt.element.timeout.seconds=3 -tt.screencaster.active=false #tt.selenium.server.host=localhost