Skip to content

Commit ffaa175

Browse files
authored
Merge pull request #6 from ITArray/1.4.1
1.4.1
2 parents 6b3a9a9 + c565431 commit ffaa175

File tree

9 files changed

+159
-162
lines changed

9 files changed

+159
-162
lines changed

.gitignore

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,4 @@
1-
### JetBrains template
2-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
3-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
4-
5-
# User-specific stuff:
6-
.idea/workspace.xml
7-
.idea/tasks.xml
8-
.idea/dictionaries
9-
.idea/vcs.xml
10-
.idea/jsLibraryMappings.xml
11-
12-
# Sensitive or high-churn files:
13-
.idea/dataSources.ids
14-
.idea/dataSources.xml
15-
.idea/dataSources.local.xml
16-
.idea/sqlDataSources.xml
17-
.idea/dynamic.xml
18-
.idea/uiDesigner.xml
19-
20-
# Gradle:
21-
.idea/gradle.xml
22-
.idea/libraries
1+
target
232
*.iml
243
.idea
25-
drivers
26-
27-
# Mongo Explorer plugin:
28-
.idea/mongoSettings.xml
29-
30-
## File-based project format:
31-
*.iws
32-
33-
## Plugin-specific files:
34-
35-
# IntelliJ
36-
/out/
37-
38-
# mpeltonen/sbt-idea plugin
39-
.idea_modules/
40-
41-
# JIRA plugin
42-
atlassian-ide-plugin.xml
43-
44-
# Crashlytics plugin (for Android Studio and IntelliJ)
45-
com_crashlytics_export_strings.xml
46-
crashlytics.properties
47-
crashlytics-build.properties
48-
fabric.properties
49-
50-
# Created by .ignore support plugin (hsz.mobi)
4+
drivers

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
mvn clean deploy -DperformRelease=true -DconnectionUrl=scm:git:https://github.com/dzaiats/java.automation.library.git
2+
mvn clean deploy -DperformRelease=true -DconnectionUrl=scm:git:https://github.com/ITArray/Automotion.git

pom.xml

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
<groupId>net.itarray</groupId>
88
<artifactId>automotion</artifactId>
9-
<version>1.4.0</version>
9+
<version>1.4.1</version>
1010
<name>Automotion</name>
1111
<description>Library for automation testing</description>
1212
<url>https://www.itarray.net</url>
1313

1414
<licenses>
1515
<license>
1616
<name>Apache-2.0</name>
17-
<url>https://github.com/dzaiats/Automotion/blob/master/LICENSE</url>
17+
<url>https://github.com/ITArray/Automotion/blob/master/LICENSE-2.0</url>
1818
</license>
1919
</licenses>
2020

@@ -28,9 +28,9 @@
2828
</developers>
2929

3030
<scm>
31-
<connection>scm:git:[email protected]:dzaiats/java.automation.library.git</connection>
32-
<developerConnection>scm:git:[email protected]:dzaiats/java.automation.library.git</developerConnection>
33-
<url>[email protected]:dzaiats/java.automation.library.git</url>
31+
<connection>scm:git:[email protected]:ITArray/Automotion.git</connection>
32+
<developerConnection>scm:git:[email protected]:ITArray/Automotion.git</developerConnection>
33+
<url>[email protected]:ITArray/Automotion.git</url>
3434
</scm>
3535

3636
<properties>
@@ -39,68 +39,68 @@
3939
<maven.compiler.target>1.8</maven.compiler.target>
4040
</properties>
4141

42-
<!--<build>-->
43-
<!--<plugins>-->
44-
<!--<plugin>-->
45-
<!--<groupId>org.apache.maven.plugins</groupId>-->
46-
<!--<artifactId>maven-gpg-plugin</artifactId>-->
47-
<!--<executions>-->
48-
<!--<execution>-->
49-
<!--<id>sign-artifacts</id>-->
50-
<!--<phase>verify</phase>-->
51-
<!--<goals>-->
52-
<!--<goal>sign</goal>-->
53-
<!--</goals>-->
54-
<!--</execution>-->
55-
<!--</executions>-->
56-
<!--</plugin>-->
42+
<build>
43+
<plugins>
44+
<plugin>
45+
<groupId>org.apache.maven.plugins</groupId>
46+
<artifactId>maven-gpg-plugin</artifactId>
47+
<executions>
48+
<execution>
49+
<id>sign-artifacts</id>
50+
<phase>verify</phase>
51+
<goals>
52+
<goal>sign</goal>
53+
</goals>
54+
</execution>
55+
</executions>
56+
</plugin>
5757

58-
<!--<plugin>-->
59-
<!--<groupId>org.sonatype.plugins</groupId>-->
60-
<!--<artifactId>nexus-staging-maven-plugin</artifactId>-->
61-
<!--<version>1.6.3</version>-->
62-
<!--<extensions>true</extensions>-->
63-
<!--<configuration>-->
64-
<!--<serverId>ossrh</serverId>-->
65-
<!--<nexusUrl>https://oss.sonatype.org/</nexusUrl>-->
66-
<!--<stagingProfileId>22f8da536d8418</stagingProfileId> &lt;!&ndash;Staging&ndash;&gt;-->
67-
<!--&lt;!&ndash;<stagingProfileId>7edbe315063867</stagingProfileId> &lt;!&ndash;Central staging&ndash;&gt;&ndash;&gt;-->
68-
<!--<skipStagingRepositoryClose>true</skipStagingRepositoryClose>-->
69-
<!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
70-
<!--</configuration>-->
71-
<!--</plugin>-->
58+
<plugin>
59+
<groupId>org.sonatype.plugins</groupId>
60+
<artifactId>nexus-staging-maven-plugin</artifactId>
61+
<version>1.6.3</version>
62+
<extensions>true</extensions>
63+
<configuration>
64+
<serverId>ossrh</serverId>
65+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
66+
<stagingProfileId>22f8da536d8418</stagingProfileId> <!--Staging-->
67+
<!--<stagingProfileId>7edbe315063867</stagingProfileId> &lt;!&ndash;Central staging&ndash;&gt;-->
68+
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
69+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
70+
</configuration>
71+
</plugin>
7272

73-
<!--<plugin>-->
74-
<!--<groupId>org.apache.maven.plugins</groupId>-->
75-
<!--<artifactId>maven-source-plugin</artifactId>-->
76-
<!--<executions>-->
77-
<!--<execution>-->
78-
<!--<id>attach-sources</id>-->
79-
<!--<goals>-->
80-
<!--<goal>jar</goal>-->
81-
<!--</goals>-->
82-
<!--</execution>-->
83-
<!--</executions>-->
84-
<!--</plugin>-->
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-source-plugin</artifactId>
76+
<executions>
77+
<execution>
78+
<id>attach-sources</id>
79+
<goals>
80+
<goal>jar</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
8585

86-
<!--<plugin>-->
87-
<!--<groupId>org.apache.maven.plugins</groupId>-->
88-
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
89-
<!--<executions>-->
90-
<!--<execution>-->
91-
<!--<id>attach-javadocs</id>-->
92-
<!--<goals>-->
93-
<!--<goal>jar</goal>-->
94-
<!--</goals>-->
95-
<!--</execution>-->
96-
<!--</executions>-->
97-
<!--<configuration>-->
98-
<!--<additionalparam>-Xdoclint:none</additionalparam>-->
99-
<!--</configuration>-->
100-
<!--</plugin>-->
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-javadoc-plugin</artifactId>
89+
<executions>
90+
<execution>
91+
<id>attach-javadocs</id>
92+
<goals>
93+
<goal>jar</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
<configuration>
98+
<additionalparam>-Xdoclint:none</additionalparam>
99+
</configuration>
100+
</plugin>
101101

102-
<!--</plugins>-->
103-
<!--</build>-->
102+
</plugins>
103+
</build>
104104

105105
<distributionManagement>
106106
<snapshotRepository>

src/main/java/util/general/HtmlReportBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private void writeReport(String reportName) throws InterruptedException, IOExcep
4444

4545
long ms = System.currentTimeMillis();
4646

47-
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TARGET_AUTOMOTION + reportName.replace(" ", "") + ms + ".html"), StandardCharsets.UTF_8))) {
47+
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TARGET_AUTOMOTION + reportName.replace(" ", "_") + "-" + ms + ".html"), StandardCharsets.UTF_8))) {
4848
writer.write(html.toHtmlString());
4949
} catch (IOException ex) {
5050
LOG.error("Cannot create html report: " + ex.getMessage());
@@ -91,10 +91,14 @@ private Html buildHtml() throws IOException, ParseException {
9191
JSONObject jsonObject = (JSONObject) obj;
9292
JSONArray details = (JSONArray) jsonObject.get(DETAILS);
9393
new H1(this,
94-
new Style("color: rgb(0,139,139); margin-top: 50px;")) {{
95-
new NoTag(this, "Element: \"" + jsonObject.get(ELEMENT_NAME) + "\"");
94+
new Style("color: rgb(47,79,79); margin-top: 50px;")) {{
95+
new NoTag(this, "Scenario: \"" + jsonObject.get(SCENARIO) + "\"");
9696
}};
9797
new H2(this,
98+
new Style("color: rgb(0,139,139);")) {{
99+
new NoTag(this, "Element: \"" + jsonObject.get(ELEMENT_NAME) + "\"");
100+
}};
101+
new H3(this,
98102
new Style("color: rgb(255,69,0)")) {{
99103
new NoTag(this, "Failures:");
100104
}};

src/main/java/util/validator/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class Constants {
1313
public static final String SCREENSHOT = "screenshot";
1414
public static final String ELEMENT_NAME = "elementName";
1515
public static final String ROOT_ELEMENT = "rootElement";
16+
public static final String SCENARIO = "scenario";
1617
public static final String TIME_EXECUTION = "timeExecution";
1718
public static final String TARGET_AUTOMOTION_JSON = "target/automotion/json/";
1819
public static final String TARGET_AUTOMOTION_IMG = "target/automotion/img/";

src/main/java/util/validator/ResponsiveUIValidator.java

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
public class ResponsiveUIValidator implements Validator {
3232

3333
private final static Logger LOG = Logger.getLogger(ResponsiveUIValidator.class);
34-
private static boolean withReport = false;
3534
private static final int MIN_OFFSET = -10000;
35+
private static boolean withReport = false;
3636
private static long startTime;
3737
private static JSONObject jsonResults;
38+
private static String scenarioName = "Default";
3839
private WebDriver driver;
3940
private String rootElementReadableName = "Root Element";
4041
private WebElement rootElement;
@@ -67,6 +68,12 @@ public ResponsiveUIValidator init() {
6768
return new ResponsiveUIValidator(driver);
6869
}
6970

71+
@Override
72+
public ResponsiveUIValidator init(String scenarioName) {
73+
ResponsiveUIValidator.scenarioName = scenarioName;
74+
return new ResponsiveUIValidator(driver);
75+
}
76+
7077
@Override
7178
public ResponsiveUIValidator findElement(WebElement element, String readableNameOfElement) {
7279
rootElement = element;
@@ -426,6 +433,7 @@ public boolean validate() {
426433
rootDetails.put(WIDTH, widthRoot);
427434
rootDetails.put(HEIGHT, heightRoot);
428435

436+
jsonResults.put(SCENARIO, scenarioName);
429437
jsonResults.put(ROOT_ELEMENT, rootDetails);
430438
jsonResults.put(TIME_EXECUTION, String.valueOf(System.currentTimeMillis() - startTime) + " milliseconds");
431439
jsonResults.put(ELEMENT_NAME, rootElementReadableName);
@@ -476,10 +484,12 @@ public void generateReport() {
476484

477485
@Override
478486
public void generateReport(String name) {
479-
try {
480-
new HtmlReportBuilder().buildReport(name);
481-
} catch (IOException | ParseException | InterruptedException e) {
482-
e.printStackTrace();
487+
if (withReport && (boolean) jsonResults.get(ERROR_KEY)) {
488+
try {
489+
new HtmlReportBuilder().buildReport(name);
490+
} catch (IOException | ParseException | InterruptedException e) {
491+
e.printStackTrace();
492+
}
483493
}
484494
}
485495

@@ -726,21 +736,32 @@ private void validateSameSize(List<WebElement> elements) {
726736
int h2 = el2.getSize().getHeight();
727737
int w2 = el2.getSize().getWidth();
728738
if (h1 != h2 || w1 != w2) {
729-
putJsonDetailsWithoutElement("Elements in a gird have different size.");
739+
putJsonDetailsWithElement("Elements in a grid have different size.", el1);
730740
}
731741
}
732742
}
733743
}
734744
}
735745

736746
private void validateInsideOfContainer(WebElement element, String readableContainerName) {
737-
float xContainer = element.getLocation().getX();
738-
float yContainer = element.getLocation().getY();
739-
float widthContainer = element.getSize().getWidth();
740-
float heightContainer = element.getSize().getHeight();
741-
742-
if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
743-
putJsonDetailsWithElement(String.format("Element '%s' is not inside of '%s'", rootElementReadableName, readableContainerName), element);
747+
float xContainer = element.getLocation().x;
748+
float yContainer = element.getLocation().y;
749+
float widthContainer = element.getSize().width;
750+
float heightContainer = element.getSize().height;
751+
if (rootElements == null || rootElements.isEmpty()) {
752+
if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
753+
putJsonDetailsWithElement(String.format("Element '%s' is not inside of '%s'", rootElementReadableName, readableContainerName), element);
754+
}
755+
}else{
756+
for (WebElement el: rootElements){
757+
float xRoot = el.getLocation().x;
758+
float yRoot = el.getLocation().y;
759+
float widthRoot = el.getSize().width;
760+
float heightRoot = el.getSize().height;
761+
if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
762+
putJsonDetailsWithElement(String.format("Element is not inside of '%s'", readableContainerName), element);
763+
}
764+
}
744765
}
745766
}
746767

@@ -880,7 +901,8 @@ private void drawRoot(Color color) {
880901
g.drawRect(xRoot, yRoot, widthRoot, heightRoot);
881902
}
882903

883-
g.setStroke(new BasicStroke(1));
904+
Stroke dashed = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
905+
g.setStroke(dashed);
884906
g.setColor(Color.ORANGE);
885907
if (drawLeftOffsetLine) {
886908
if (SystemHelper.isRetinaDisplay(g) && isChrome()) {

src/main/java/util/validator/Validator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
interface Validator {
88
ResponsiveUIValidator init();
99

10+
ResponsiveUIValidator init(String scenarioName);
11+
1012
ResponsiveUIValidator findElement(WebElement element, String readableNameOfElement);
1113

1214
ResponsiveUIValidator findElements(List<WebElement> elements);

0 commit comments

Comments
 (0)