From eeba903891aae5eceb8029e9402340bdf608d316 Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Tue, 28 Sep 2021 17:24:05 +0100 Subject: [PATCH] Fix the EdgeOptionsTest --- .../org/openqa/selenium/edge/EdgeOptionsTest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java b/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java index e63287750800e..4f2340d0416e0 100644 --- a/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java +++ b/java/test/org/openqa/selenium/edge/EdgeOptionsTest.java @@ -17,7 +17,6 @@ package org.openqa.selenium.edge; -import com.google.common.io.Files; import org.junit.Test; import org.junit.experimental.categories.Category; import org.openqa.selenium.ImmutableCapabilities; @@ -29,6 +28,8 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.Arrays; import java.util.Base64; import java.util.Collections; @@ -66,8 +67,7 @@ public void canAddArguments() { @Test public void canAddExtensions() throws IOException { EdgeOptions options = new EdgeOptions(); - File tmpDir = File.createTempFile("webdriver", "tmp"); - tmpDir.deleteOnExit(); + Path tmpDir = Files.createTempDirectory("webdriver"); File ext1 = createTempFile(tmpDir, "ext1 content"); File ext2 = createTempFile(tmpDir, "ext2 content"); options.addExtensions(ext1, ext2); @@ -96,11 +96,11 @@ private void checkCommonStructure(EdgeOptions options) { .containsOnlyKeys("args", "extensions"); } - private File createTempFile(File tmpDir, String content) { + private File createTempFile(Path tmpDir, String content) { try { - File ext = File.createTempFile("tmp", "ext", tmpDir); - Files.asCharSink(ext, Charset.defaultCharset()).write(content); - return ext; + Path file = Files.createTempFile(tmpDir, "tmp", "ext"); + Files.write(file, content.getBytes(Charset.defaultCharset())); + return file.toFile(); } catch (IOException e) { throw new UncheckedIOException(e); }