diff --git a/.idea/androidDexCompiler.xml b/.idea/androidDexCompiler.xml index b28dce7dc34ad..ec54ed20bde02 100644 --- a/.idea/androidDexCompiler.xml +++ b/.idea/androidDexCompiler.xml @@ -1,7 +1,7 @@ - diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 8444a97ecdf2a..56ae915df35ac 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,7 +1,7 @@ - - - \ No newline at end of file + diff --git a/dotnet/test/remote/AssemblyTeardown.cs b/dotnet/test/remote/AssemblyTeardown.cs index aca281e6ee801..8edd20db86a30 100644 --- a/dotnet/test/remote/AssemblyTeardown.cs +++ b/dotnet/test/remote/AssemblyTeardown.cs @@ -20,6 +20,7 @@ using NUnit.Framework; using OpenQA.Selenium.Environment; using System.Threading.Tasks; +using System; namespace OpenQA.Selenium.Remote { diff --git a/java/src/org/openqa/selenium/concurrent/ExecutorServices.java b/java/src/org/openqa/selenium/concurrent/ExecutorServices.java index 78b9cd8d942ef..73008fcb8f97a 100644 --- a/java/src/org/openqa/selenium/concurrent/ExecutorServices.java +++ b/java/src/org/openqa/selenium/concurrent/ExecutorServices.java @@ -1,4 +1,4 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one + // Licensed to the Software Freedom Conservancy (SFC) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The SFC licenses this file @@ -26,18 +26,27 @@ public class ExecutorServices { private static final Logger LOG = Logger.getLogger(ExecutorServices.class.getName()); + private static final int DEFAULT_SHUTDOWN_TIMEOUT = 5; public static void shutdownGracefully(String name, ExecutorService service) { service.shutdown(); + if(!awaitTermination(name, service, DEFAULT_SHUTDOWN_TIMEOUT)){ + forceShutdown(name, service); + } + } + + private static boolean awaitTermination(String name, ExecutorService service, int timeoutSeconds){ + try { - if (!service.awaitTermination(5, SECONDS)) { - LOG.warning(String.format("Failed to shutdown %s", name)); - service.shutdownNow(); - } - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); + return service.awaitTermination(timeoutSeconds, SECONDS); + }catch(InterruptedException ex){ + Thread.currentThread().interrupt; LOG.log(WARNING, String.format("Failed to shutdown %s", name), e); - service.shutdownNow(); + return false; + + private static void forceShutDown(String name, ExecutorService, service){ + LOG.warning(String.format("Failed to shutdown %s", name), e); + service.shutdownNow(); + } } -} diff --git a/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java b/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java index ce0d823408d00..2db687ae4c7ff 100644 --- a/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java +++ b/java/test/org/openqa/selenium/chrome/ChromeDriverFunctionalTest.java @@ -56,9 +56,16 @@ public void builderGeneratesDefaultChromeOptions() { // This test won't pass if we want to use Chrome in a non-standard location Assumptions.assumeThat(System.getProperty("webdriver.chrome.binary")).isNull(); - localDriver = ChromeDriver.builder().build(); - Capabilities capabilities = ((ChromeDriver) localDriver).getCapabilities(); + localDriver = initializeChromeDriver(); + assertDefaultChromeCapabilities((ChromeDriver) localDriver); + } + + private ChromeDriver initializeChromeDriver(){ + return ChromeDriver.builder().build(); + } + private void assertDefaultChromeCapabilities(ChromeDriver driver){ + Capabilities capabilities = driver.getCapabilities(); assertThat(localDriver.manage().timeouts().getImplicitWaitTimeout()).isEqualTo(Duration.ZERO); assertThat(capabilities.getCapability("browserName")).isEqualTo("chrome"); } diff --git a/java/test/org/openqa/selenium/html5/LocationContextTest.java b/java/test/org/openqa/selenium/html5/LocationContextTest.java index c4ab2bccd2526..9b79fbb6de453 100644 --- a/java/test/org/openqa/selenium/html5/LocationContextTest.java +++ b/java/test/org/openqa/selenium/html5/LocationContextTest.java @@ -39,8 +39,8 @@ public void hasLocationContext() { void testShouldSetAndGetLatitude() { driver.get(pages.html5Page); - ((LocationContext) driver).setLocation(new Location(40.714353, -74.005973, 0.056747)); - Location location = ((LocationContext) driver).location(); + LocationContext locationContext = (LocationContext) driver; + Location location = setAndRetrieveLocation(locationContext, 40.714353, -74.005973, 0.056747); assertThat(location).isNotNull(); assertThat(location.getLatitude()).isCloseTo(40.714353, byLessThan(0.000001)); } @@ -49,8 +49,8 @@ void testShouldSetAndGetLatitude() { void testShouldSetAndGetLongitude() { driver.get(pages.html5Page); - ((LocationContext) driver).setLocation(new Location(40.714353, -74.005973, 0.056747)); - Location location = ((LocationContext) driver).location(); + LocationContext locationContext = (LocationContext) driver; + Location location = setAndRetrieveLocation(locationContext, 40.714353, -74.005973, 0.056747); assertThat(location).isNotNull(); assertThat(location.getLongitude()).isCloseTo(-74.005973, byLessThan(0.000001)); } @@ -60,9 +60,9 @@ void testShouldSetAndGetLongitude() { @NotYetImplemented(EDGE) public void testShouldSetAndGetAltitude() { driver.get(pages.html5Page); - - ((LocationContext) driver).setLocation(new Location(40.714353, -74.005973, 0.056747)); - Location location = ((LocationContext) driver).location(); + + LocationContext locationContext = (LocationContext) driver; + Location location = setAndRetrieveLocation(locationContext, 40.714353, -74.005973, 0.056747); assertThat(location).isNotNull(); assertThat(location.getAltitude()).isCloseTo(0.056747, byLessThan(0.000001)); }