Skip to content

Commit

Permalink
Merge pull request #6 from ITArray/1.4.1
Browse files Browse the repository at this point in the history
1.4.1
  • Loading branch information
dzaiats authored Dec 4, 2016
2 parents 6b3a9a9 + c565431 commit ffaa175
Show file tree
Hide file tree
Showing 9 changed files with 159 additions and 162 deletions.
50 changes: 2 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,50 +1,4 @@
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml

# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Gradle:
.idea/gradle.xml
.idea/libraries
target
*.iml
.idea
drivers

# Mongo Explorer plugin:
.idea/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Created by .ignore support plugin (hsz.mobi)
drivers
2 changes: 1 addition & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
mvn clean deploy -DperformRelease=true -DconnectionUrl=scm:git:https://github.com/dzaiats/java.automation.library.git
mvn clean deploy -DperformRelease=true -DconnectionUrl=scm:git:https://github.com/ITArray/Automotion.git
126 changes: 63 additions & 63 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

<groupId>net.itarray</groupId>
<artifactId>automotion</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<name>Automotion</name>
<description>Library for automation testing</description>
<url>https://www.itarray.net</url>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://github.com/dzaiats/Automotion/blob/master/LICENSE</url>
<url>https://github.com/ITArray/Automotion/blob/master/LICENSE-2.0</url>
</license>
</licenses>

Expand All @@ -28,9 +28,9 @@
</developers>

<scm>
<connection>scm:git:[email protected]:dzaiats/java.automation.library.git</connection>
<developerConnection>scm:git:[email protected]:dzaiats/java.automation.library.git</developerConnection>
<url>[email protected]:dzaiats/java.automation.library.git</url>
<connection>scm:git:[email protected]:ITArray/Automotion.git</connection>
<developerConnection>scm:git:[email protected]:ITArray/Automotion.git</developerConnection>
<url>[email protected]:ITArray/Automotion.git</url>
</scm>

<properties>
Expand All @@ -39,68 +39,68 @@
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<!--<build>-->
<!--<plugins>-->
<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-gpg-plugin</artifactId>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>sign-artifacts</id>-->
<!--<phase>verify</phase>-->
<!--<goals>-->
<!--<goal>sign</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>

<!--<plugin>-->
<!--<groupId>org.sonatype.plugins</groupId>-->
<!--<artifactId>nexus-staging-maven-plugin</artifactId>-->
<!--<version>1.6.3</version>-->
<!--<extensions>true</extensions>-->
<!--<configuration>-->
<!--<serverId>ossrh</serverId>-->
<!--<nexusUrl>https://oss.sonatype.org/</nexusUrl>-->
<!--<stagingProfileId>22f8da536d8418</stagingProfileId> &lt;!&ndash;Staging&ndash;&gt;-->
<!--&lt;!&ndash;<stagingProfileId>7edbe315063867</stagingProfileId> &lt;!&ndash;Central staging&ndash;&gt;&ndash;&gt;-->
<!--<skipStagingRepositoryClose>true</skipStagingRepositoryClose>-->
<!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
<!--</configuration>-->
<!--</plugin>-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.3</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<stagingProfileId>22f8da536d8418</stagingProfileId> <!--Staging-->
<!--<stagingProfileId>7edbe315063867</stagingProfileId> &lt;!&ndash;Central staging&ndash;&gt;-->
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>

<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-source-plugin</artifactId>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>attach-sources</id>-->
<!--<goals>-->
<!--<goal>jar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!--<plugin>-->
<!--<groupId>org.apache.maven.plugins</groupId>-->
<!--<artifactId>maven-javadoc-plugin</artifactId>-->
<!--<executions>-->
<!--<execution>-->
<!--<id>attach-javadocs</id>-->
<!--<goals>-->
<!--<goal>jar</goal>-->
<!--</goals>-->
<!--</execution>-->
<!--</executions>-->
<!--<configuration>-->
<!--<additionalparam>-Xdoclint:none</additionalparam>-->
<!--</configuration>-->
<!--</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>

<!--</plugins>-->
<!--</build>-->
</plugins>
</build>

<distributionManagement>
<snapshotRepository>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/util/general/HtmlReportBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void writeReport(String reportName) throws InterruptedException, IOExcep

long ms = System.currentTimeMillis();

try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TARGET_AUTOMOTION + reportName.replace(" ", "") + ms + ".html"), StandardCharsets.UTF_8))) {
try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(TARGET_AUTOMOTION + reportName.replace(" ", "_") + "-" + ms + ".html"), StandardCharsets.UTF_8))) {
writer.write(html.toHtmlString());
} catch (IOException ex) {
LOG.error("Cannot create html report: " + ex.getMessage());
Expand Down Expand Up @@ -91,10 +91,14 @@ private Html buildHtml() throws IOException, ParseException {
JSONObject jsonObject = (JSONObject) obj;
JSONArray details = (JSONArray) jsonObject.get(DETAILS);
new H1(this,
new Style("color: rgb(0,139,139); margin-top: 50px;")) {{
new NoTag(this, "Element: \"" + jsonObject.get(ELEMENT_NAME) + "\"");
new Style("color: rgb(47,79,79); margin-top: 50px;")) {{
new NoTag(this, "Scenario: \"" + jsonObject.get(SCENARIO) + "\"");
}};
new H2(this,
new Style("color: rgb(0,139,139);")) {{
new NoTag(this, "Element: \"" + jsonObject.get(ELEMENT_NAME) + "\"");
}};
new H3(this,
new Style("color: rgb(255,69,0)")) {{
new NoTag(this, "Failures:");
}};
Expand Down
1 change: 1 addition & 0 deletions src/main/java/util/validator/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class Constants {
public static final String SCREENSHOT = "screenshot";
public static final String ELEMENT_NAME = "elementName";
public static final String ROOT_ELEMENT = "rootElement";
public static final String SCENARIO = "scenario";
public static final String TIME_EXECUTION = "timeExecution";
public static final String TARGET_AUTOMOTION_JSON = "target/automotion/json/";
public static final String TARGET_AUTOMOTION_IMG = "target/automotion/img/";
Expand Down
50 changes: 36 additions & 14 deletions src/main/java/util/validator/ResponsiveUIValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@
public class ResponsiveUIValidator implements Validator {

private final static Logger LOG = Logger.getLogger(ResponsiveUIValidator.class);
private static boolean withReport = false;
private static final int MIN_OFFSET = -10000;
private static boolean withReport = false;
private static long startTime;
private static JSONObject jsonResults;
private static String scenarioName = "Default";
private WebDriver driver;
private String rootElementReadableName = "Root Element";
private WebElement rootElement;
Expand Down Expand Up @@ -67,6 +68,12 @@ public ResponsiveUIValidator init() {
return new ResponsiveUIValidator(driver);
}

@Override
public ResponsiveUIValidator init(String scenarioName) {
ResponsiveUIValidator.scenarioName = scenarioName;
return new ResponsiveUIValidator(driver);
}

@Override
public ResponsiveUIValidator findElement(WebElement element, String readableNameOfElement) {
rootElement = element;
Expand Down Expand Up @@ -426,6 +433,7 @@ public boolean validate() {
rootDetails.put(WIDTH, widthRoot);
rootDetails.put(HEIGHT, heightRoot);

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

@Override
public void generateReport(String name) {
try {
new HtmlReportBuilder().buildReport(name);
} catch (IOException | ParseException | InterruptedException e) {
e.printStackTrace();
if (withReport && (boolean) jsonResults.get(ERROR_KEY)) {
try {
new HtmlReportBuilder().buildReport(name);
} catch (IOException | ParseException | InterruptedException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -726,21 +736,32 @@ private void validateSameSize(List<WebElement> elements) {
int h2 = el2.getSize().getHeight();
int w2 = el2.getSize().getWidth();
if (h1 != h2 || w1 != w2) {
putJsonDetailsWithoutElement("Elements in a gird have different size.");
putJsonDetailsWithElement("Elements in a grid have different size.", el1);
}
}
}
}
}

private void validateInsideOfContainer(WebElement element, String readableContainerName) {
float xContainer = element.getLocation().getX();
float yContainer = element.getLocation().getY();
float widthContainer = element.getSize().getWidth();
float heightContainer = element.getSize().getHeight();

if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
putJsonDetailsWithElement(String.format("Element '%s' is not inside of '%s'", rootElementReadableName, readableContainerName), element);
float xContainer = element.getLocation().x;
float yContainer = element.getLocation().y;
float widthContainer = element.getSize().width;
float heightContainer = element.getSize().height;
if (rootElements == null || rootElements.isEmpty()) {
if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
putJsonDetailsWithElement(String.format("Element '%s' is not inside of '%s'", rootElementReadableName, readableContainerName), element);
}
}else{
for (WebElement el: rootElements){
float xRoot = el.getLocation().x;
float yRoot = el.getLocation().y;
float widthRoot = el.getSize().width;
float heightRoot = el.getSize().height;
if (xRoot < xContainer || yRoot < yContainer || (xRoot + widthRoot) > (xContainer + widthContainer) || (yRoot + heightRoot) > (yContainer + heightContainer)) {
putJsonDetailsWithElement(String.format("Element is not inside of '%s'", readableContainerName), element);
}
}
}
}

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

g.setStroke(new BasicStroke(1));
Stroke dashed = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
g.setStroke(dashed);
g.setColor(Color.ORANGE);
if (drawLeftOffsetLine) {
if (SystemHelper.isRetinaDisplay(g) && isChrome()) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/util/validator/Validator.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
interface Validator {
ResponsiveUIValidator init();

ResponsiveUIValidator init(String scenarioName);

ResponsiveUIValidator findElement(WebElement element, String readableNameOfElement);

ResponsiveUIValidator findElements(List<WebElement> elements);
Expand Down
Loading

0 comments on commit ffaa175

Please sign in to comment.