Skip to content

Commit

Permalink
Merge branch 'develop' and bumped version to 3.4.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	pom.xml
  • Loading branch information
Marcel Pfotenhauer committed Sep 3, 2019
2 parents 3e4e78b + dce14c2 commit a82a664
Show file tree
Hide file tree
Showing 72 changed files with 1,325 additions and 221 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Maven Central](https://img.shields.io/maven-central/v/com.xceptance/neodymium-library.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.xceptance%22%20AND%20a:%22neodymium-library%22) [![Join the chat at https://gitter.im/neodymium-library/community](https://badges.gitter.im/neodymium-library/community.svg)](https://gitter.im/neodymium-library/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# Neodymium v3.3.1
# Neodymium v3.4.0
Neodymium tries to solve your typical and most pressing UI test automation problems by combining JUnit, WebDriver, BDD/Cucumber, and proper reporting. It gives you ready to use templates, assembles well-known open source projects, and enhances this all with additional functionality that is often missing.

Neodymium is basically the combination of state of the art open source test libraries with additionally glue to make it stick reliably together.
Expand Down
10 changes: 5 additions & 5 deletions config/ai.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#neodymium.ai.FORMAT = png
#########################################################################

# Global flag to turn visual asserations off, nothing will be done, all code is skipped
# Global flag to turn visual assertions off, nothing will be done, all code is skipped
neodymium.ai.enabled = false

# Result directory for the image output, relative to the test suite
Expand All @@ -25,7 +25,7 @@ neodymium.ai.resultDirectory = results/ai
# The ID is used in the creation of the folder structure for the results.
neodymium.ai.ID = localmachine

# Bound to the choosen test case or not.
# Bound to the chosen test case or not.
# If the flag is true the name of the used test case will be used for localization.
# The value false let the network unbound and can be used for different testcases
neodymium.ai.TESTCASE_BOUND = true
Expand All @@ -49,8 +49,8 @@ neodymium.ai.WAITINGTIME = 1000
# procedural value between 0 - 1.00 percent
neodymium.ai.INTENDED_PERCENTAGE_MATCH = 0.80

# Color will also be used for image comparison, useful for websides with much almost same size content.
# Constent is every element on the webside.
# Color will also be used for image comparison, useful for websites with much almost same size content.
# Content is every element on the website.
neodymium.ai.USE_COLOR_FOR_COMPARISON = true

# Parameter for enabling down scaling from screenshots or not, this can drastically change
Expand All @@ -68,7 +68,7 @@ neodymium.ai.PERCENTAGE_DIFFERENCE = 0.2

# value for the learning algorithm allowed values are between 0.0 - 1.0
# affect the learn speed of the neural network, greater values are for faster learning
# but the accurancy can decrease with higher values
# but the accuracy can decrease with higher values
neodymium.ai.LEARNING_RATE = 0.3

# image format for saving
Expand Down
4 changes: 2 additions & 2 deletions config/neodymium.properties
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
# Neodymium context properties
#
#############################
# The following setting reassemble responsive design breakpoints. They determine at which page width a site is considered to be displayed on a small, medium, large oder extra large device.
# The following setting reassemble responsive design breakpoints. They determine at which page width a site is considered to be displayed on a small, medium, large or extra large device.
# You can use the by calling e.g. Neodymium.isSmallDesktop()
#
# neodymium.context.device.breakpoint.small = 576
Expand All @@ -98,7 +98,7 @@
# JavaScriptUtils properties
#
#############################
# The following properties are taken into account if you use functions form the JavaScripUtils class.
# The following properties are taken into account if you use functions form the JavaScriptUtils class.
#
# neodymium.javaScriptUtils.timeout = 2000
# neodymium.javaScriptUtils.pollingInterval = 200
Expand Down
4 changes: 2 additions & 2 deletions config/visualassertion.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Global flag to turn visual asserations off, nothing will be done, all code is skipped
# Global flag to turn visual assertions off, nothing will be done, all code is skipped
neodymium.visualassertion.enabled=true

# Result directory for the image output, relative to the test suite
Expand All @@ -20,7 +20,7 @@ neodymium.visualassertion.mark.blocksize.x=10
neodymium.visualassertion.mark.blocksize.y=10

## How the marking should look like - marking type
# box: Draw a box with blocksize, the difference box might not be in the center, it is effectivly
# box: Draw a box with blocksize, the difference box might not be in the center, it is effectively
# the comparison box used in the algorithm.
# marker: Use yellow highlighter and mark different pixels in red too
neodymium.visualassertion.mark.type=marker
Expand Down
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.xceptance</groupId>
<artifactId>neodymium-library</artifactId>
<version>3.3.1</version>
<version>3.4.0</version>

<name>neodymium-library</name>
<url>https://github.com/Xceptance/neodymium-library</url>
Expand Down Expand Up @@ -55,8 +55,8 @@
<maven.compiler.target.version>1.8</maven.compiler.target.version>
<surefire.version>2.22.1</surefire.version>
<allure.version>2.12.1</allure.version>
<cucumber.version>4.3.1</cucumber.version>
<log4j.version>2.11.2</log4j.version>
<cucumber.version>4.7.2</cucumber.version>
<log4j.version>2.12.1</log4j.version>
</properties>

<repositories>
Expand Down Expand Up @@ -202,7 +202,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.24</version>
<version>1.25</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
Expand Down Expand Up @@ -242,12 +242,12 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
<version>28.1-jre</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>5.2.3</version>
<version>5.2.8</version>
<exclusions>
<exclusion>
<groupId>net.lightbody.bmp</groupId>
Expand All @@ -258,12 +258,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.6</version>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.6</version>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -273,7 +273,7 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.26</version>
<version>1.7.28</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.InitializationError;

import cucumber.api.junit.Cucumber;
import io.cucumber.junit.Cucumber;

public class NeodymiumCucumberRunner extends Cucumber
{
Expand All @@ -18,7 +18,7 @@ public NeodymiumCucumberRunner(Class<?> clazz) throws InitializationError, IOExc
public void run(RunNotifier notifier)
{
// we add our own run listener in order to attach screenshots taken by Selenide to the Allure report
// this also neccessary to clear the context between tests
// this also necessary to clear the context between tests
notifier.addListener(new NeodymiumCucumberRunListener());
super.run(notifier);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/xceptance/neodymium/NeodymiumRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public enum DescriptionMode
@Override
protected Statement methodBlock(FrameworkMethod method)
{
// This will build a default JUnit statement which runs excactly one of the test methods including before/after
// This will build a default JUnit statement which runs exactly one of the test methods including before/after
// methods. This call will also create the test class instance in which this method will be invoked.
Statement methodStatement = super.methodBlock(method);
// We need this particular test class instance for our own statements but we can not access it from here.
Expand Down Expand Up @@ -160,7 +160,7 @@ protected List<FrameworkMethod> computeTestMethods()
// super.computeTestMethods will return all methods that are annotated with @Test
for (FrameworkMethod testAnnotatedMethod : super.computeTestMethods())
{
// these lists contain all the builders and data that will be responsible for a partiuclar method
// these lists contain all the builders and data that will be responsible for a particular method
List<StatementBuilder> builderList = new LinkedList<>();
List<List<Object>> builderDataList = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.net.MalformedURLException;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -16,6 +15,7 @@
import org.junit.runners.model.TestClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -154,7 +154,7 @@ public void setUpTest(String browserTag)
}
catch (final MalformedURLException e)
{
throw new RuntimeException("An error occured during URL creation. See nested exception.", e);
throw new RuntimeException("An error occurred during URL creation. See nested exception.", e);
}
if (webdriver != null)
{
Expand Down Expand Up @@ -184,60 +184,42 @@ private void initSelenideConfiguration()
}

public void teardown(boolean testFailed)
{
teardown(testFailed, false, webdriver);
}

public void teardown(boolean testFailed, boolean preventReuse, WebDriver webDriver)
{
BrowserConfiguration browserConfiguration = multibrowserConfiguration.getBrowserProfiles().get(Neodymium.getBrowserProfileName());

if (testFailed && Neodymium.configuration().keepBrowserOpenOnFailure() && !browserConfiguration.isHeadless())
// keep browser open
if ((browserConfiguration != null && !browserConfiguration.isHeadless())
&& ((Neodymium.configuration().keepBrowserOpenOnFailure() && testFailed) || Neodymium.configuration().keepBrowserOpen()))
{
// test failed and we want to leave the browser instance open
// don't quit the webdriver, just remove references
LOGGER.debug("Keep browser open");
Neodymium.setDriver(null);
Neodymium.setBrowserProfileName(null);
Neodymium.setBrowserName(null);
return;
// nothing to do
}

if (Neodymium.configuration().reuseWebDriver())
// reuse
else if (Neodymium.configuration().reuseWebDriver() && !preventReuse && isWebDriverStillOpen(webDriver))
{
LOGGER.debug("Put browser into cache");
WebDriverCache.instance.putWebDriver(browserTag, webdriver);
}
// close the WebDriver
else
{
if (browserConfiguration.isHeadless() || !Neodymium.configuration().keepBrowserOpen())
LOGGER.debug("Teardown browser");
if (webDriver != null)
{
LOGGER.debug("Teardown browser");
if (webdriver != null)
webdriver.quit();
webDriver.quit();
}
}

Neodymium.setDriver(null);
Neodymium.setBrowserProfileName(null);
Neodymium.setBrowserName(null);
}

public static void quitCachedBrowser()
{
if (!Neodymium.configuration().keepBrowserOpen())
{
Collection<WebDriver> allWebdriver = WebDriverCache.instance.getAllWebdriver();

for (WebDriver wd : allWebdriver)
{
try
{
LOGGER.debug("Quit web driver: " + wd.toString());
wd.quit();
}
catch (Exception e)
{
LOGGER.debug("Error on quitting web driver", e);
}
}
}
}

@Override
public List<Object> createIterationData(TestClass testClass, FrameworkMethod method)
{
Expand Down Expand Up @@ -321,7 +303,6 @@ public List<Browser> findClassBrowserAnnotation(Class<?> clazz)
{
return browserAnnotations;
}

}

@Override
Expand Down Expand Up @@ -350,4 +331,22 @@ public List<String> getBrowserTags()

return tags;
}

private boolean isWebDriverStillOpen(WebDriver webDriver)
{
if (webDriver == null)
{
return false;
}
try
{
RemoteWebDriver driver = (RemoteWebDriver) ((EventFiringWebDriver) webDriver).getWrappedDriver();
return driver.getSessionId() != null;
}
catch (Exception e)
{
LOGGER.warn("Couldn't detect if the WebDriver is still open!", e);
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ else if (windowWidth > 0 && windowHeight > 0)
}
catch (final WebDriverException e)
{
// on saucelabs in some cases like iphone emulation you cant resize the browser.
// on saucelabs in some cases like iphone emulation you can't resize the browser.
// they throw an unchecked WebDriverException with the message "Not yet implemented"
// if we catch an exception we check the message. if another message is set we throw the exception else
// we suppress it
Expand Down Expand Up @@ -165,7 +165,7 @@ private static FirefoxBinary createFirefoxBinary(final String pathToBrowser)
* Instantiate the {@link WebDriver} according to the configuration read from {@link Browser} annotations.
*
* @param config
* {@link BrowserConfiguration} that describes the descired browser instance
* {@link BrowserConfiguration} that describes the desired browser instance
* @return {@link WebDriver} the instance of the browser described in {@link BrowserConfiguration}
* @throws MalformedURLException
* if <a href="https://github.com/Xceptance/neodymium-library/wiki/Selenium-grid">Selenium grid</a> is
Expand Down
Loading

0 comments on commit a82a664

Please sign in to comment.