Skip to content

Commit

Permalink
Merge branch 'master' into future/keyboard-shortcuts-for-Accept-Revert
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaik authored Jan 21, 2019
2 parents b26bc0d + 75bc334 commit 01d2484
Show file tree
Hide file tree
Showing 110 changed files with 719 additions and 1,519 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ All notable changes to AET will be documented in this file.
## Unreleased

**List of changes that are finished but not yet released in any final version.**

## Version 3.2.0


- [PR-451](https://github.com/Cognifide/aet/pull/451) Collectors and comparators configured by single config number
- [PR-449](https://github.com/Cognifide/aet/pull/449) Improvements to the Winter Edition Theme
- [PR-354](https://github.com/Cognifide/aet/pull/354) Remove jmsEndpointConfig information from communication settings endpoint ([#352](https://github.com/Cognifide/aet/issues/352))
- [PR-412](https://github.com/Cognifide/aet/pull/412) ([PR-336](https://github.com/Cognifide/aet/pull/336), [PR-337](https://github.com/Cognifide/aet/pull/337), [PR-395](https://github.com/Cognifide/aet/pull/395)) - Added rerun functionality for suite, test and url
- [PR-429](https://github.com/Cognifide/aet/pull/429) - `aet-cookbook` version updated to [`v5.1.1`](https://github.com/Cognifide/aet-cookbook/blob/master/CHANGELOG.md#511) in Vagrant. **Important**: please follow the instructions from [PR-43 description](https://github.com/Cognifide/aet-cookbook/pull/43) in order to keep the MongoDB data on your local environment.
- [PR-422](https://github.com/Cognifide/aet/pull/422) RunnerConfiguration's urlPackageSize property got set to 1
- [PR-430](https://github.com/Cognifide/aet/pull/430) Upgraded HTML codesniffer to latest release (3.2.0)
- [PR-385](https://github.com/Cognifide/aet/pull/385) Fixed ChefDK and vagrant-berkshelf versions
- [PR-404](https://github.com/Cognifide/aet/pull/404) Added missing tooltip for conditional tests
- [PR-408](https://github.com/Cognifide/aet/pull/408) Advanced Screen Comparision button layout fix
- [PR-410](https://github.com/Cognifide/aet/pull/410) Notification that displays when exclude-elements are not found on page now shows what specific elements were not found([#372](https://github.com/Cognifide/aet/issues/372))

## Version 3.1.0

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Please do so, we believe that having good an up-to-date documentation is as impo

## Changelog
When changing or fixing some important part of AET, please remember to update [Changelog](https://github.com/Cognifide/aet/blob/master/CHANGELOG.md).
Your entry should be enlisted in `Unreleased` section. It will be moved to appropriate release notes during release process.
Your entry should be enlisted **at the end** of the `Unreleased` section. It will be moved to appropriate release notes during release process.
Please use convention `- [PR-ABC](https://github.com/Cognifide/aet/pull/ABC) - short description of the PR.`.

## Tests naming convention
Expand Down
2 changes: 1 addition & 1 deletion api/communication-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>api</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>communication-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.Serializable;

public class ExcludedElement implements Serializable {

private static final long serialVersionUID = 692282363549228800L;

private final Point point;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@

import java.io.Serializable;
import java.util.List;
import java.util.Set;

public class LayoutExclude implements Serializable {

private static final long serialVersionUID = -6496109702966509444L;

private final List<ExcludedElement> excludedElements;
private final Set<String> notFoundElements;

public LayoutExclude(
List<ExcludedElement> excludedElements) {
public LayoutExclude(List<ExcludedElement> excludedElements, Set<String> notFoundElements) {
this.excludedElements = excludedElements;
this.notFoundElements = notFoundElements;
}

public List<ExcludedElement> getExcludedElements() {
return excludedElements;
}

public Set<String> getNotFoundElements() {
return notFoundElements;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* AET
*
* Copyright (C) 2013 Cognifide Limited
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.cognifide.aet.communication.api.queues;

public enum QueuesConstant implements WorkerConfig {
COLLECTOR("collectorJobs", "collectorResults"),
COMPARATOR("comparatorJobs", "comparatorResults");

public static final String NAMESPACE = "AET.";

final String jobsQueueName;
final String resultsQueueName;

QueuesConstant(String jobsQueueName, String resultsQueueName) {
this.jobsQueueName = jobsQueueName;
this.resultsQueueName = resultsQueueName;
}

@Override
public String getJobsQueueName() {
return NAMESPACE + jobsQueueName;
}

@Override
public String getResultsQueueName() {
return NAMESPACE + resultsQueueName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* AET
*
* Copyright (C) 2013 Cognifide Limited
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.cognifide.aet.communication.api.queues;

public interface WorkerConfig {

/**
* @return name of the jobs queue
*/
String getJobsQueueName();

/**
* @return name of the results queue name
*/
String getResultsQueueName();

}
2 changes: 1 addition & 1 deletion api/datastorage-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>api</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>datastorage-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api/jobs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>api</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>jobs-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>aet-root</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion api/validation-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>api</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>validation-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/aet-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>client</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>aet-maven-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/client-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>client</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>client-core</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>aet-root</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>client</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/cleaner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>cleaner</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/communication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>communication</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/datastorage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>datastorage</artifactId>
Expand Down
8 changes: 6 additions & 2 deletions core/jobs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>core</artifactId>
<groupId>com.cognifide.aet</groupId>
<version>3.1.1-SNAPSHOT</version>
<version>3.2.1-SNAPSHOT</version>
</parent>

<artifactId>jobs</artifactId>
Expand Down Expand Up @@ -141,11 +141,15 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.openqa.selenium.By;
Expand All @@ -56,6 +64,8 @@ public class ScreenCollector extends WebElementsLocatorParams implements Collect

private static final String PNG_FORMAT = "png";

private static final String CSS_SELECTOR_SEPARATOR = ",";

private final WebDriver webDriver;

private final ArtifactsDAO artifactsDAO;
Expand All @@ -70,22 +80,6 @@ public class ScreenCollector extends WebElementsLocatorParams implements Collect
this.artifactsDAO = artifactsDAO;
}

private List<ExcludedElement> getExcludeElementsFromWebElements(List<WebElement> webElements) {
List<ExcludedElement> excludeExcludedElements = new ArrayList<>(webElements.size());

Point screenshotOffset = isSelectorPresent() ?
webDriver.findElement(getLocator()).getLocation() : new Point(0, 0);
for (WebElement webElement : webElements) {
Point point = webElement.getLocation()
.moveBy(-screenshotOffset.getX(), -screenshotOffset.getY());

excludeExcludedElements.add(new ExcludedElement(
new java.awt.Point(point.getX(), point.getY()),
new java.awt.Dimension(webElement.getSize().width, webElement.getSize().height)));
}
return excludeExcludedElements;
}

@Override
public CollectorStepResult collect() throws ProcessingException {
byte[] screenshot = takeScreenshot();
Expand All @@ -98,11 +92,7 @@ public CollectorStepResult collect() throws ProcessingException {
String resultId = artifactsDAO.saveArtifact(properties, screenshotStream, CONTENT_TYPE);

if (excludeCssSelector != null) {
List<ExcludedElement> excludeExcludedElements = getExcludeElementsFromWebElements(
webDriver.findElements(By.cssSelector(excludeCssSelector)));
stepResult = CollectorStepResult
.newCollectedResult(resultId,
new Payload((new LayoutExclude(excludeExcludedElements))));
stepResult = getResultWithExcludeSelectors(resultId);
} else {
stepResult = CollectorStepResult.newCollectedResult(resultId);
}
Expand All @@ -124,6 +114,65 @@ private boolean isPatternAndResultMD5Identical(byte[] screenshot) {
}
}

private CollectorStepResult getResultWithExcludeSelectors(String resultId) {
ArrayList<String> cssSelectors = new ArrayList<>(
Arrays.asList(excludeCssSelector.split(CSS_SELECTOR_SEPARATOR)));

Map<String, List<WebElement>> elements = searchElementsOnPage(cssSelectors);

List<WebElement> foundExcludeElements = getFoundWebElements(elements);
Set<String> notFoundSelectors = getNotFoundSelectors(elements);

List<ExcludedElement> excludedElements = getExcludeElementsFromWebElements(
foundExcludeElements);
return CollectorStepResult.newCollectedResult(resultId,
new Payload((new LayoutExclude(excludedElements, notFoundSelectors))));
}

private HashMap<String, List<WebElement>> searchElementsOnPage(ArrayList<String> cssSelectors) {
HashMap<String, List<WebElement>> elements = new HashMap<>();

cssSelectors.forEach(selector -> {
List<WebElement> foundElements = webDriver.findElements(By.cssSelector(selector));
if (!CollectionUtils.isEmpty(foundElements)) {
elements.put(selector, foundElements);
} else {
elements.put(selector, Collections.emptyList());
}
});

return elements;
}

private List<WebElement> getFoundWebElements(Map<String, List<WebElement>> elements) {
return elements.values().stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
}

private Set<String> getNotFoundSelectors(Map<String, List<WebElement>> elements) {
return elements.entrySet().stream()
.filter(entry -> entry.getValue().isEmpty())
.map(Entry::getKey)
.collect(Collectors.toSet());
}

private List<ExcludedElement> getExcludeElementsFromWebElements(List<WebElement> webElements) {
List<ExcludedElement> excludeExcludedElements = new ArrayList<>(webElements.size());

Point screenshotOffset = isSelectorPresent() ?
webDriver.findElement(getLocator()).getLocation() : new Point(0, 0);
for (WebElement webElement : webElements) {
Point point = webElement.getLocation()
.moveBy(-screenshotOffset.getX(), -screenshotOffset.getY());

excludeExcludedElements.add(new ExcludedElement(
new java.awt.Point(point.getX(), point.getY()),
new java.awt.Dimension(webElement.getSize().width, webElement.getSize().height)));
}
return excludeExcludedElements;
}

@Override
public void setParameters(Map<String, String> params) throws ParametersException {
if (StringUtils.isNotBlank(params.get(XPATH_PARAM)) || StringUtils
Expand Down
Loading

0 comments on commit 01d2484

Please sign in to comment.