Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This is JAVA library for the running of mobile, web or API automated tests.
<dependency>
<groupId>net.itarray</groupId>
<artifactId>automotion</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
</dependency>

### Steps of adding to the project ###
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/util/general/SystemHelper.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
45 changes: 23 additions & 22 deletions src/main/java/util/validator/ResponsiveUIValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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<Integer, AtomicLong> 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<WebElement> row = new ArrayList<>();
Expand Down Expand Up @@ -728,17 +732,14 @@ private void validateSameSize(WebElement element, String readableName) {
}

private void validateSameSize(List<WebElement> 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));
}
}
}
Expand Down