-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from aquality-automation/feature/visualization
[Feature] Visualization
- Loading branch information
Showing
44 changed files
with
1,634 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ | |
# Log file | ||
*.log | ||
|
||
# Visualization | ||
visualDumps/ | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
|
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
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
42 changes: 42 additions & 0 deletions
42
src/main/java/aquality/selenium/core/configurations/IVisualizationConfiguration.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,42 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
/** | ||
* Represents visualization configuration, used for image comparison. | ||
*/ | ||
public interface IVisualizationConfiguration { | ||
/** | ||
* Image format for comparison. | ||
* @return image format. | ||
*/ | ||
String getImageFormat(); | ||
|
||
/** | ||
* Gets maximum length of full file name with path for image comparison. | ||
* @return maximum symbols count in file path. | ||
*/ | ||
int getMaxFullFileNameLength(); | ||
|
||
/** | ||
* Gets default threshold used for image comparison. | ||
* @return The default threshold value. | ||
*/ | ||
float getDefaultThreshold(); | ||
|
||
/** | ||
* Gets width of the image resized for comparison. | ||
* @return comparison width. | ||
*/ | ||
int getComparisonWidth(); | ||
|
||
/** | ||
* Gets height of the image resized for comparison. | ||
* @return comparison height. | ||
*/ | ||
int getComparisonHeight(); | ||
|
||
/** | ||
* Gets path used to save and load page dumps. | ||
* @return path to dumps. | ||
*/ | ||
String getPathToDumps(); | ||
} |
94 changes: 94 additions & 0 deletions
94
src/main/java/aquality/selenium/core/configurations/VisualizationConfiguration.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,94 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
import aquality.selenium.core.logging.Logger; | ||
import aquality.selenium.core.utilities.ISettingsFile; | ||
import com.google.inject.Inject; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Represents visualization configuration, used for image comparison. | ||
* Uses {@link ISettingsFile} as source for configuration values. | ||
*/ | ||
public class VisualizationConfiguration implements IVisualizationConfiguration { | ||
private String imageFormat; | ||
private Integer maxFullFileNameLength; | ||
private Float defaultThreshold; | ||
private Integer comparisonWidth; | ||
private Integer comparisonHeight; | ||
private String pathToDumps; | ||
|
||
private final ISettingsFile settingsFile; | ||
|
||
/** | ||
* Instantiates class using {@link ISettingsFile} with visualization settings. | ||
* @param settingsFile settings file. | ||
*/ | ||
@Inject | ||
public VisualizationConfiguration(ISettingsFile settingsFile) { | ||
this.settingsFile = settingsFile; | ||
} | ||
|
||
@Override | ||
public String getImageFormat() { | ||
if (imageFormat == null) { | ||
String valueFromConfig = settingsFile.getValueOrDefault("/visualization/imageExtension", "png").toString(); | ||
imageFormat = valueFromConfig.startsWith(".") ? valueFromConfig.substring(1) : valueFromConfig; | ||
} | ||
return imageFormat; | ||
} | ||
|
||
@Override | ||
public int getMaxFullFileNameLength() { | ||
if (maxFullFileNameLength == null) { | ||
maxFullFileNameLength = Integer.valueOf( | ||
settingsFile.getValueOrDefault("/visualization/maxFullFileNameLength", 255).toString()); | ||
} | ||
return maxFullFileNameLength; | ||
} | ||
|
||
@Override | ||
public float getDefaultThreshold() { | ||
if (defaultThreshold == null) { | ||
defaultThreshold = Float.valueOf( | ||
settingsFile.getValueOrDefault("/visualization/defaultThreshold", 0.012f).toString()); | ||
} | ||
return defaultThreshold; | ||
} | ||
|
||
@Override | ||
public int getComparisonWidth() { | ||
if (comparisonWidth == null) { | ||
comparisonWidth = Integer.valueOf( | ||
settingsFile.getValueOrDefault("/visualization/comparisonWidth", 16).toString()); | ||
} | ||
return comparisonWidth; | ||
} | ||
|
||
@Override | ||
public int getComparisonHeight() { | ||
if (comparisonHeight == null) { | ||
comparisonHeight = Integer.valueOf( | ||
settingsFile.getValueOrDefault("/visualization/comparisonHeight", 16).toString()); | ||
} | ||
return comparisonHeight; | ||
} | ||
|
||
@Override | ||
public String getPathToDumps() { | ||
if (pathToDumps == null) { | ||
pathToDumps = settingsFile.getValueOrDefault("/visualization/pathToDumps", "./src/test/resources/visualDumps/").toString(); | ||
if (pathToDumps.startsWith(".")) { | ||
try { | ||
pathToDumps = new File(pathToDumps).getCanonicalPath(); | ||
} catch (IOException e) { | ||
String errorMessage = "Failed to resolve path to dumps: " + e.getMessage(); | ||
Logger.getInstance().fatal(errorMessage, e); | ||
throw new IllegalArgumentException(errorMessage, e); | ||
} | ||
} | ||
} | ||
return pathToDumps; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/main/java/aquality/selenium/core/elements/CachedElementStateProvider.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
2 changes: 1 addition & 1 deletion
2
src/main/java/aquality/selenium/core/elements/DefaultElementStateProvider.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
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
2 changes: 1 addition & 1 deletion
2
src/main/java/aquality/selenium/core/elements/ElementStateProvider.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
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 |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
public enum ElementsCount { | ||
ZERO, | ||
MORE_THEN_ZERO, | ||
MORE_THAN_ZERO, | ||
ANY | ||
} |
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
Oops, something went wrong.