Skip to content

Commit

Permalink
Merge branch 'develop' into #135-update-to-java-11
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Pfotenhauer committed Aug 26, 2020
2 parents a515a2f + 81e95f8 commit 6ef7a41
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 33 deletions.
14 changes: 4 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<maven.compiler.source.version>11</maven.compiler.source.version>
<maven.compiler.target.version>11</maven.compiler.target.version>
<surefire.version>2.22.2</surefire.version>
<allure.version>2.13.3</allure.version>
<allure.version>2.13.5</allure.version>
<cucumber.version>5.7.0</cucumber.version>
<log4j.version>2.13.3</log4j.version>
</properties>
Expand Down Expand Up @@ -253,7 +253,7 @@
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>selenide</artifactId>
<version>5.12.2</version>
<version>5.14.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -263,12 +263,12 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.10</version>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -301,11 +301,5 @@
<version>2.1.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>xyz.rogfam</groupId>
<artifactId>littleproxy</artifactId>
<version>2.0.0-beta-5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class WebDriverCache

public static final WebDriverCache instance = new WebDriverCache();

private static final Map<String, WebDriverStateContainer> cache = Collections.synchronizedMap(new HashMap<>());
private final Map<String, WebDriverStateContainer> cache = Collections.synchronizedMap(new HashMap<>());

/**
* The private constructor of the {@link WebDriverCache}. Creates the synchronized {@link HashMap} instance and
Expand Down Expand Up @@ -158,7 +158,7 @@ public int getWebDriverStateContainerCacheSize()
**/
public static void quitCachedBrowsers()
{
for (Iterator<Entry<String, WebDriverStateContainer>> iterator = cache.entrySet().iterator(); iterator.hasNext();)
for (Iterator<Entry<String, WebDriverStateContainer>> iterator = instance.cache.entrySet().iterator(); iterator.hasNext();)
{
WebDriverStateContainer cont = iterator.next().getValue();
try
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/xceptance/neodymium/util/Neodymium.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public static WebDriverStateContainer getWebDriverStateContainer()

public static WebDriver getDriver()
{
return getContext().webDriverStateContainer != null ? getContext().webDriverStateContainer.getWebDriver() : null;
final WebDriverStateContainer wDSC = getContext().webDriverStateContainer;
return wDSC == null ? null : wDSC.getWebDriver();
}

public static EventFiringWebDriver getEventFiringWebdriver()
Expand All @@ -158,7 +159,8 @@ public static RemoteWebDriver getRemoteWebDriver()

public static BrowserUpProxy getLocalProxy()
{
return getContext().webDriverStateContainer != null ? getContext().webDriverStateContainer.getProxy() : null;
final WebDriverStateContainer wDSC = getContext().webDriverStateContainer;
return wDSC == null ? null : wDSC.getProxy();
}

public static String getBrowserProfileName()
Expand Down
22 changes: 3 additions & 19 deletions src/main/java/com/xceptance/neodymium/util/SelenideAddons.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import static com.codeborne.selenide.Selenide.open;
import static com.codeborne.selenide.Selenide.sleep;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Base64;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -458,21 +456,7 @@ public static void dragAndDropUntilCondition(SelenideElement elementToMove, Sele
*/
public static void openHtmlContentWithCurrentWebDriver(String htmlContent)
{
File tempHtmlContentFile = null;
try
{
tempHtmlContentFile = File.createTempFile("htmlContent", ".html", new File("./target/"));
tempHtmlContentFile.deleteOnExit();

FileWriter fileWriter;
fileWriter = new FileWriter(tempHtmlContentFile);
fileWriter.append(htmlContent);
fileWriter.close();
}
catch (final IOException e)
{
e.printStackTrace();
}
open("file://" + tempHtmlContentFile.getAbsolutePath());
String encodedStuff = Base64.getEncoder().encodeToString(htmlContent.getBytes());
open("data:text/html;charset=utf-8;base64," + encodedStuff);
}
}

0 comments on commit 6ef7a41

Please sign in to comment.