Skip to content

Commit

Permalink
issue #467: add tests for ErrorCauseFinder
Browse files Browse the repository at this point in the history
  • Loading branch information
bhecquet committed Dec 6, 2021
1 parent 384e358 commit a44d6e7
Show file tree
Hide file tree
Showing 3 changed files with 413 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import com.seleniumtests.connectors.selenium.fielddetector.Label;
import com.seleniumtests.core.TestStepManager;
import com.seleniumtests.core.utils.TestNGResultUtils;
import com.seleniumtests.customexception.ConfigurationException;
import com.seleniumtests.customexception.SeleniumRobotServerException;
import com.seleniumtests.reporter.logger.Snapshot;
import com.seleniumtests.reporter.logger.TestStep;
import com.seleniumtests.util.imaging.StepReferenceComparator;
Expand Down Expand Up @@ -164,15 +166,25 @@ private void searchMatchingInPreviousStep(TestStepManager testStepManager, TestS
Collections.reverse(testStepsSubList);
for (TestStep testStep2: testStepsSubList) {
if (testStep2.getStepResultId() != null) {
File referenceSnapshot = SeleniumRobotSnapshotServerConnector.getInstance().getReferenceSnapshot(testStep2.getStepResultId());
int matching = compareReferenceToStepSnapshot(stepSnapshotFile, referenceSnapshot);
try {
File referenceSnapshot = SeleniumRobotSnapshotServerConnector.getInstance().getReferenceSnapshot(testStep2.getStepResultId());

if (matching > 80) {
errorCauses.add(new ErrorCause(ErrorType.SELENIUM_ERROR, String.format("Wrong page found, we are on the page of step '%s'", testStep2.getName())));
break;
if (referenceSnapshot == null) {
continue;
}
int matching = compareReferenceToStepSnapshot(stepSnapshotFile, referenceSnapshot);

if (matching > 80) {
errorCauses.add(new ErrorCause(ErrorType.SELENIUM_ERROR, String.format("Wrong page found, we are on the page of step '%s'", testStep2.getName())));
return;
}
} catch (ConfigurationException | SeleniumRobotServerException e) {
logger.error(e.getMessage());
}
}
}

errorCauses.add(new ErrorCause(ErrorType.UNKNOWN_PAGE, null));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public enum ErrorType {
ERROR_MESSAGE, // error message displayed
ERROR_IN_FIELD, // some field shows an error (it's coloured in red)
APPLICATION_CHANGED, // compared to the page we expect, the page we are on is slightly different
SELENIUM_ERROR // we are not on the right page to perform our actions, it may be due to a problem when clicking during previous step
SELENIUM_ERROR, // we are not on the right page to perform our actions, it may be due to a problem when clicking during previous step
UNKNOWN_PAGE // Page is unknown, maybe a scripting error ?
}
Loading

0 comments on commit a44d6e7

Please sign in to comment.