-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/exclude #303
Merged
Merged
Feature/exclude #303
Changes from 45 commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
9a2a0c5
Preparing prototype
PiteroS678 60f3205
created threshold, moved logic from image comparision result to layou…
plutasnyy f013b93
created tests for threshold
plutasnyy f769083
created status conditionally passed in frontend
plutasnyy aa31764
created documentation for threshold parameters
plutasnyy 645fb72
Preparing prototype
PiteroS678 2b53717
merge with treshold
5e82351
Preparing prototype
PiteroS678 ddebdaf
updated documentation
plutasnyy d3bccfe
Update SuiteReportLayoutCase.md
plutasnyy bff0d18
Refactor
PiteroS678 7039644
added sum of passed and conditionally passed in side panel
plutasnyy 972a64a
rafactor saveArtifact
plutasnyy b8d98fe
added integration tests for exclude
plutasnyy 6d087df
updated photo
plutasnyy 49527b4
added documentation about exclude elements
plutasnyy 55b1f12
removed blank line
plutasnyy 0a31c80
updated documentation
plutasnyy 27c45c5
centered button
plutasnyy 4386af1
added integrations tests
plutasnyy ccc8720
fixed wrong class in dynamic content
plutasnyy 2ae9496
fixed typo in test name
plutasnyy 23e4997
removed unused incrementation
plutasnyy 2c82913
Refactor
PiteroS678 3930e29
Show difference in test - fix
PiteroS678 a47a732
ScreenCollector refactor
PiteroS678 77e96a9
Wiki - move `exclude-elements` parameter to ScreenCollector
PiteroS678 41ba6cb
ScreenCollector refactor
PiteroS678 bc02476
Added height to tests
PiteroS678 a08bacd
href update
PiteroS678 cce570a
Wiki - `exclude-elements` value update
PiteroS678 5593ae5
LayoutComparator refactor
PiteroS678 cf2ab30
LoginModifierTest - ignore removed
PiteroS678 f60959b
Empty lines removed
PiteroS678 a260f02
merge with threhold
plutasnyy ba5008e
removed duplicated tests
plutasnyy 0290864
ScreenCollector - fix
PiteroS678 2b6afa6
Merge branch 'feature/exclude' of https://github.com/Cognifide/aet in…
plutasnyy d10788d
updated tests
plutasnyy b10c8a3
removed blank lines
plutasnyy 282dc0f
StepResult - serialVersionUID update
PiteroS678 a5b09de
LayoutComparator - update
PiteroS678 adc9e4e
Payload & ScreenCollector - refactor
PiteroS678 5385992
ScreenCollector - refactor
PiteroS678 54fc03d
Exclude feature - refactor
PiteroS678 6b7db4d
Exclude feature - refactor
PiteroS678 8427fc9
ScreenCollector - refactor
PiteroS678 8d42fd3
Wiki - ScreenCollector update
PiteroS678 c113b3d
merge with master
plutasnyy 09d18c0
Merge branch 'master' into feature/exclude
tkaik 11534ca
Merge branch 'master' of https://github.com/Cognifide/aet into featur…
tkaik 70e120d
CHANGELOG update
PiteroS678 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...communication-api/src/main/java/com/cognifide/aet/communication/api/metadata/Payload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* 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.metadata; | ||
|
||
import com.cognifide.aet.communication.api.metadata.exclude.LayoutExclude; | ||
import java.io.Serializable; | ||
|
||
public class Payload implements Serializable { | ||
|
||
private static final long serialVersionUID = -4218060468970419297L; | ||
|
||
private final LayoutExclude exclude; | ||
|
||
public Payload(LayoutExclude exclude) { | ||
this.exclude = exclude; | ||
} | ||
|
||
public LayoutExclude getExclude() { | ||
return exclude; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...i/src/main/java/com/cognifide/aet/communication/api/metadata/exclude/ExcludedElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.metadata.exclude; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Point; | ||
import java.io.Serializable; | ||
|
||
public class ExcludedElement implements Serializable { | ||
private static final long serialVersionUID = 692282363549228800L; | ||
|
||
private final Point point; | ||
|
||
private final Dimension dimension; | ||
|
||
public ExcludedElement(Point point, Dimension dimension) { | ||
this.point = point; | ||
this.dimension = dimension; | ||
} | ||
|
||
public Point getPoint() { | ||
return point; | ||
} | ||
|
||
public Dimension getDimension() { | ||
return dimension; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...api/src/main/java/com/cognifide/aet/communication/api/metadata/exclude/LayoutExclude.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* 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.metadata.exclude; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
public class LayoutExclude implements Serializable { | ||
private static final long serialVersionUID = -6496109702966509444L; | ||
|
||
private final List<ExcludedElement> excludedElements; | ||
|
||
public LayoutExclude( | ||
List<ExcludedElement> excludedElements) { | ||
this.excludedElements = excludedElements; | ||
} | ||
|
||
public List<ExcludedElement> getExcludedElements() { | ||
return excludedElements; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,9 @@ | |
package com.cognifide.aet.job.common.collectors.screen; | ||
|
||
import com.cognifide.aet.communication.api.metadata.CollectorStepResult; | ||
import com.cognifide.aet.communication.api.metadata.Payload; | ||
import com.cognifide.aet.communication.api.metadata.exclude.ExcludedElement; | ||
import com.cognifide.aet.communication.api.metadata.exclude.LayoutExclude; | ||
import com.cognifide.aet.job.api.collector.CollectorJob; | ||
import com.cognifide.aet.job.api.collector.CollectorProperties; | ||
import com.cognifide.aet.job.api.exceptions.ParametersException; | ||
|
@@ -28,11 +31,14 @@ | |
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import javax.imageio.ImageIO; | ||
import org.apache.commons.codec.digest.DigestUtils; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.OutputType; | ||
|
@@ -56,12 +62,27 @@ public class ScreenCollector extends WebElementsLocatorParams implements Collect | |
|
||
private final CollectorProperties properties; | ||
|
||
private String excludeCssSelector; | ||
|
||
ScreenCollector(CollectorProperties properties, WebDriver webDriver, ArtifactsDAO artifactsDAO) { | ||
this.properties = properties; | ||
this.webDriver = webDriver; | ||
this.artifactsDAO = artifactsDAO; | ||
} | ||
|
||
private List<ExcludedElement> getExcludeElementsFromWebElements( | ||
List<WebElement> webElements) { | ||
List<ExcludedElement> excludeExcludedElements = new LinkedList<>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
for (WebElement webElement : webElements) { | ||
java.awt.Point point = new java.awt.Point(webElement.getLocation().x, | ||
webElement.getLocation().y); | ||
java.awt.Dimension dimension = new java.awt.Dimension(webElement.getSize().width, | ||
webElement.getSize().height); | ||
excludeExcludedElements.add(new ExcludedElement(point, dimension)); | ||
} | ||
return excludeExcludedElements; | ||
} | ||
|
||
@Override | ||
public CollectorStepResult collect() throws ProcessingException { | ||
byte[] screenshot = takeScreenshot(); | ||
|
@@ -72,7 +93,15 @@ public CollectorStepResult collect() throws ProcessingException { | |
} else { | ||
try (final InputStream screenshotStream = new ByteArrayInputStream(screenshot)) { | ||
String resultId = artifactsDAO.saveArtifact(properties, screenshotStream, CONTENT_TYPE); | ||
stepResult = CollectorStepResult.newCollectedResult(resultId); | ||
|
||
if (excludeCssSelector != null) { | ||
List<ExcludedElement> excludeExcludedElements = getExcludeElementsFromWebElements( | ||
webDriver.findElements(By.cssSelector(excludeCssSelector))); | ||
stepResult = CollectorStepResult | ||
.newCollectedResult(resultId, new Payload((new LayoutExclude(excludeExcludedElements)))); | ||
} else { | ||
stepResult = CollectorStepResult.newCollectedResult(resultId); | ||
} | ||
} catch (Exception e) { | ||
throw new ProcessingException(e.getMessage(), e); | ||
} | ||
|
@@ -97,6 +126,13 @@ public void setParameters(Map<String, String> params) throws ParametersException | |
.isNotBlank(params.get(CSS_PARAM))) { | ||
setElementParams(params); | ||
} | ||
if (params.containsKey(EXCLUDE_ELEMENT_PARAM)) { | ||
if (StringUtils.isNotBlank(params.get(EXCLUDE_ELEMENT_PARAM))) { | ||
excludeCssSelector = params.get(EXCLUDE_ELEMENT_PARAM); | ||
} else { | ||
throw new ParametersException("Elements to exclude are not specified in suite"); | ||
} | ||
} | ||
} | ||
|
||
private byte[] takeScreenshot() throws ProcessingException { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe returning
Optional<Payload>
here would be a good idea?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPayload()
fromStepResult
is used only inComparatorMessageListenerImpl
withoutif
statement. If you mean to use it further -LayoutComparator
thenOptional<Payload>
is nice idea.