diff --git a/readme.md b/readme.md
index 241efb1..14ad30f 100644
--- a/readme.md
+++ b/readme.md
@@ -8,7 +8,7 @@ This is JAVA library for the running of mobile, web or API automated tests.
net.itarray
automotion
- 1.4.0
+ 1.4.1
### Steps of adding to the project ###
diff --git a/src/main/java/util/general/SystemHelper.java b/src/main/java/util/general/SystemHelper.java
index 4452765..771a1e0 100644
--- a/src/main/java/util/general/SystemHelper.java
+++ b/src/main/java/util/general/SystemHelper.java
@@ -1,8 +1,11 @@
package util.general;
import java.awt.*;
+import java.io.File;
import java.lang.reflect.Field;
+import static util.validator.Constants.TARGET_AUTOMOTION_JSON;
+
public class SystemHelper {
public static boolean isRetinaDisplay(Graphics2D g) {
boolean isRetina = false;
@@ -53,4 +56,10 @@ public static String hexStringToARGB(String hexARGB) throws IllegalArgumentExcep
return String.format("rgb(%d,%d,%d)", intARGB[0], intARGB[1], intARGB[2]);
}
}
+
+ public static boolean isAutomotionFolderExists(){
+ File file = new File(TARGET_AUTOMOTION_JSON);
+
+ return file != null && file.exists() && file.isDirectory() && file.list().length > 0;
+ }
}
diff --git a/src/main/java/util/validator/ResponsiveUIValidator.java b/src/main/java/util/validator/ResponsiveUIValidator.java
index 992221e..e04a592 100644
--- a/src/main/java/util/validator/ResponsiveUIValidator.java
+++ b/src/main/java/util/validator/ResponsiveUIValidator.java
@@ -25,6 +25,7 @@
import java.util.concurrent.atomic.AtomicLong;
import static environment.EnvironmentFactory.isChrome;
+import static util.general.SystemHelper.isAutomotionFolderExists;
import static util.validator.Constants.*;
import static util.validator.ResponsiveUIValidator.Units.PX;
@@ -473,7 +474,7 @@ public boolean validate() {
@Override
public void generateReport() {
- if (withReport && (boolean) jsonResults.get(ERROR_KEY)) {
+ if (withReport && isAutomotionFolderExists()) {
try {
new HtmlReportBuilder().buildReport();
} catch (IOException | ParseException | InterruptedException e) {
@@ -484,7 +485,7 @@ public void generateReport() {
@Override
public void generateReport(String name) {
- if (withReport && (boolean) jsonResults.get(ERROR_KEY)) {
+ if (withReport && isAutomotionFolderExists()) {
try {
new HtmlReportBuilder().buildReport(name);
} catch (IOException | ParseException | InterruptedException e) {
@@ -551,27 +552,30 @@ private void validateGridAlignment(int columns, int rows) {
map.get(y).incrementAndGet();
}
+ int mapSize = map.size();
if (rows > 0) {
- if (map.size() != rows) {
- putJsonDetailsWithoutElement("Elements in a grid are not aligned properly.");
+ if (mapSize != rows) {
+ putJsonDetailsWithoutElement("Elements in a grid are not aligned properly. Looks like grid has wrong amount of rows. Expected is " + rows + ". Actual is " + mapSize + "");
}
}
if (columns > 0) {
int rowCount = 1;
for (Map.Entry entry : map.entrySet()) {
- if (rowCount <= map.size()) {
- if (entry.getValue().intValue() != columns) {
- putJsonDetailsWithoutElement("Elements in a grid are not aligned properly in row #" + rowCount + ".");
+ if (rowCount <= mapSize) {
+ int actualInARow = entry.getValue().intValue();
+ if (actualInARow != columns) {
+ putJsonDetailsWithoutElement("Elements in a grid are not aligned properly in row #" + rowCount + ". Expected " + columns + " elements in a row. Actually it's " + actualInARow + "");
}
rowCount++;
}
}
- } else {
- if (map.size() == rootElements.size()) {
- putJsonDetailsWithoutElement("Elements are not aligned in a grid.");
- }
}
+// else {
+// if (map.size() == rootElements.size()) {
+// putJsonDetailsWithoutElement("Elements are not aligned in a grid.");
+// }
+// }
}
// List row = new ArrayList<>();
@@ -728,17 +732,14 @@ private void validateSameSize(WebElement element, String readableName) {
}
private void validateSameSize(List elements) {
- for (WebElement el1 : elements) {
- for (WebElement el2 : elements) {
- if (!el1.equals(el2)) {
- int h1 = el1.getSize().getHeight();
- int w1 = el1.getSize().getWidth();
- int h2 = el2.getSize().getHeight();
- int w2 = el2.getSize().getWidth();
- if (h1 != h2 || w1 != w2) {
- putJsonDetailsWithElement("Elements in a grid have different size.", el1);
- }
- }
+ for (int i = 0; i < elements.size() - 1; i ++){
+ int h1 = elements.get(i).getSize().getHeight();
+ int w1 = elements.get(i).getSize().getWidth();
+ int h2 = elements.get(i + 1).getSize().getHeight();
+ int w2 = elements.get(i + 1).getSize().getWidth();
+ if (h1 != h2 || w1 != w2) {
+ putJsonDetailsWithElement("Elements in a grid have different size.", elements.get(i));
+ putJsonDetailsWithElement("Elements in a grid have different size.", elements.get(i + 1));
}
}
}