From c583458827f7ca780cb3526e1bd2466d35a57d98 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 7 Dec 2022 22:31:43 +0100 Subject: [PATCH] [java] Removing deprecated LOGGING_PREFS cap --- .../selenium/remote/CapabilityType.java | 8 ---- .../selenium/remote/RemoteWebDriver.java | 11 ----- .../org/openqa/selenium/json/JsonTest.java | 32 +-------------- .../openqa/selenium/logging/GetLogsTest.java | 38 +++--------------- .../logging/PerformanceLogTypeTest.java | 40 +++---------------- .../remote/DesiredCapabilitiesTest.java | 15 +------ 6 files changed, 14 insertions(+), 130 deletions(-) diff --git a/java/src/org/openqa/selenium/remote/CapabilityType.java b/java/src/org/openqa/selenium/remote/CapabilityType.java index 448fbbaf031a7..91e0f61036fdd 100644 --- a/java/src/org/openqa/selenium/remote/CapabilityType.java +++ b/java/src/org/openqa/selenium/remote/CapabilityType.java @@ -68,14 +68,6 @@ public interface CapabilityType { @Deprecated String OVERLAPPING_CHECK_DISABLED = "overlappingCheckDisabled"; - /** - * @deprecated Non W3C compliant - * Use {@link org.openqa.selenium.chrome.ChromeOptions#LOGGING_PREFS} or - * Use {@link org.openqa.selenium.edge.EdgeOptions#LOGGING_PREFS} - */ - @Deprecated - String LOGGING_PREFS = "loggingPrefs"; - String BROWSER_NAME = "browserName"; String PLATFORM_NAME = "platformName"; String BROWSER_VERSION = "browserVersion"; diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index a1c4a80d08656..73aa7277f533a 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -53,9 +53,7 @@ import org.openqa.selenium.interactions.Sequence; import org.openqa.selenium.internal.Require; import org.openqa.selenium.logging.LocalLogs; -import org.openqa.selenium.logging.LogType; import org.openqa.selenium.logging.LoggingHandler; -import org.openqa.selenium.logging.LoggingPreferences; import org.openqa.selenium.logging.Logs; import org.openqa.selenium.logging.NeedsLocalLogs; import org.openqa.selenium.print.PrintOptions; @@ -93,7 +91,6 @@ import static java.util.Collections.singleton; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.logging.Level.SEVERE; -import static org.openqa.selenium.remote.CapabilityType.LOGGING_PREFS; import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME; import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_JAVASCRIPT; @@ -205,14 +202,6 @@ private Capabilities init(Capabilities capabilities) { ImmutableSet.Builder builder = new ImmutableSet.Builder<>(); - LoggingPreferences mergedLoggingPrefs = new LoggingPreferences(); - mergedLoggingPrefs.addPreferences((LoggingPreferences) capabilities.getCapability(LOGGING_PREFS)); - - if (!mergedLoggingPrefs.getEnabledLogTypes().contains(LogType.CLIENT) || - mergedLoggingPrefs.getLevel(LogType.CLIENT) != Level.OFF) { - builder.add(LogType.CLIENT); - } - Set logTypesToInclude = builder.build(); LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToInclude); diff --git a/java/test/org/openqa/selenium/json/JsonTest.java b/java/test/org/openqa/selenium/json/JsonTest.java index be74b81faea52..45c945f0eaaf6 100644 --- a/java/test/org/openqa/selenium/json/JsonTest.java +++ b/java/test/org/openqa/selenium/json/JsonTest.java @@ -20,15 +20,14 @@ import com.google.common.collect.ImmutableMap; import com.google.common.reflect.TypeToken; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Capabilities; import org.openqa.selenium.Cookie; import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.MutableCapabilities; import org.openqa.selenium.Platform; import org.openqa.selenium.Proxy; -import org.openqa.selenium.logging.LoggingPreferences; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.Command; import org.openqa.selenium.remote.DesiredCapabilities; @@ -46,20 +45,12 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import static java.util.logging.Level.ALL; -import static java.util.logging.Level.FINE; -import static java.util.logging.Level.OFF; -import static java.util.logging.Level.WARNING; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.byLessThan; import static org.assertj.core.api.InstanceOfAssertFactories.MAP; import static org.openqa.selenium.Proxy.ProxyType.PAC; import static org.openqa.selenium.json.Json.MAP_TYPE; -import static org.openqa.selenium.logging.LogType.BROWSER; -import static org.openqa.selenium.logging.LogType.CLIENT; -import static org.openqa.selenium.logging.LogType.DRIVER; -import static org.openqa.selenium.logging.LogType.SERVER; @Tag("UnitTests") class JsonTest { @@ -370,27 +361,6 @@ void shouldConvertCapabilitiesToAMapAndIncludeCustomValues() { assertThat(converted.getCapability("furrfu")).isEqualTo("fishy"); } - @Test - void shouldParseCapabilitiesWithLoggingPreferences() { - String caps = String.format( - "{\"%s\": {" + - "\"browser\": \"WARNING\"," + - "\"client\": \"DEBUG\", " + - "\"driver\": \"ALL\", " + - "\"server\": \"OFF\"}}", - CapabilityType.LOGGING_PREFS); - - Capabilities converted = new Json().toType(caps, Capabilities.class); - - LoggingPreferences lp = - (LoggingPreferences) converted.getCapability(CapabilityType.LOGGING_PREFS); - assertThat(lp).isNotNull(); - assertThat(lp.getLevel(BROWSER)).isEqualTo(WARNING); - assertThat(lp.getLevel(CLIENT)).isEqualTo(FINE); - assertThat(lp.getLevel(DRIVER)).isEqualTo(ALL); - assertThat(lp.getLevel(SERVER)).isEqualTo(OFF); - } - @Test void shouldNotParseQuotedJsonObjectsAsActualJsonObjects() { String jsonStr = "{\"inner\":\"{\\\"color\\\":\\\"green\\\",\\\"number\\\":123}\"}"; diff --git a/java/test/org/openqa/selenium/logging/GetLogsTest.java b/java/test/org/openqa/selenium/logging/GetLogsTest.java index 2bcae55c0c14f..ef5e5ac2a6453 100644 --- a/java/test/org/openqa/selenium/logging/GetLogsTest.java +++ b/java/test/org/openqa/selenium/logging/GetLogsTest.java @@ -17,27 +17,22 @@ package org.openqa.selenium.logging; -import static org.assertj.core.api.Assertions.assertThat; -import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT; -import static org.openqa.selenium.testing.drivers.Browser.IE; -import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; -import static org.openqa.selenium.testing.drivers.Browser.SAFARI; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.openqa.selenium.By; -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.testing.Ignore; import org.openqa.selenium.testing.JupiterTestBase; -import org.openqa.selenium.testing.drivers.WebDriverBuilder; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.logging.Level; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; +import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT; +import static org.openqa.selenium.testing.drivers.Browser.IE; +import static org.openqa.selenium.testing.drivers.Browser.SAFARI; @Ignore(HTMLUNIT) @Ignore(IE) @@ -114,25 +109,4 @@ private static boolean hasOverlappingLogEntries(LogEntries firstLog, LogEntries return false; } - @Test - void turningOffLogShouldMeanNoLogMessages() { - Set logTypes = driver.manage().logs().getAvailableLogTypes(); - for (String logType : logTypes) { - createWebDriverWithLogging(logType, Level.OFF); - LogEntries entries = localDriver.manage().logs().get(logType); - assertThat(entries.getAll()) - .describedAs("There should be no log entries for log type %s when logging is turned off.", logType) - .isEmpty(); - quitDriver(); - } - } - - private void createWebDriverWithLogging(String logType, Level logLevel) { - LoggingPreferences loggingPrefs = new LoggingPreferences(); - loggingPrefs.enable(logType, logLevel); - Capabilities caps = new ImmutableCapabilities(CapabilityType.LOGGING_PREFS, loggingPrefs); - localDriver = new WebDriverBuilder().get(caps); - localDriver.get(pages.errorsPage); - localDriver.findElement(By.cssSelector("input")).click(); - } } diff --git a/java/test/org/openqa/selenium/logging/PerformanceLogTypeTest.java b/java/test/org/openqa/selenium/logging/PerformanceLogTypeTest.java index 881e265e283d6..0b631e8539e68 100644 --- a/java/test/org/openqa/selenium/logging/PerformanceLogTypeTest.java +++ b/java/test/org/openqa/selenium/logging/PerformanceLogTypeTest.java @@ -17,24 +17,19 @@ package org.openqa.selenium.logging; -import static org.assertj.core.api.Assertions.assertThat; -import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; -import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT; -import static org.openqa.selenium.testing.drivers.Browser.IE; -import static org.openqa.selenium.testing.drivers.Browser.SAFARI; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import org.openqa.selenium.Capabilities; -import org.openqa.selenium.ImmutableCapabilities; import org.openqa.selenium.WebDriver; -import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.testing.Ignore; import org.openqa.selenium.testing.JupiterTestBase; -import org.openqa.selenium.testing.drivers.WebDriverBuilder; import java.util.Set; -import java.util.logging.Level; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; +import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT; +import static org.openqa.selenium.testing.drivers.Browser.IE; +import static org.openqa.selenium.testing.drivers.Browser.SAFARI; @Ignore(HTMLUNIT) @Ignore(IE) @@ -58,27 +53,4 @@ void performanceLogShouldBeDisabledByDefault() { assertThat(logTypes.contains(LogType.PERFORMANCE)) .describedAs("Performance log should not be enabled by default").isFalse(); } - - void createLocalDriverWithPerformanceLogType() { - LoggingPreferences logPrefs = new LoggingPreferences(); - logPrefs.enable(LogType.PERFORMANCE, Level.INFO); - Capabilities caps = new ImmutableCapabilities(CapabilityType.LOGGING_PREFS, logPrefs); - localDriver = new WebDriverBuilder().get(caps); - } - - @Test - void shouldBeAbleToEnablePerformanceLog() { - createLocalDriverWithPerformanceLogType(); - Set logTypes = localDriver.manage().logs().getAvailableLogTypes(); - assertThat(logTypes.contains(LogType.PERFORMANCE)) - .describedAs("Profiler log should be enabled").isTrue(); - } - - @Test - void pageLoadShouldProducePerformanceLogEntries() { - createLocalDriverWithPerformanceLogType(); - localDriver.get(pages.simpleTestPage); - LogEntries entries = localDriver.manage().logs().get(LogType.PERFORMANCE); - assertThat(entries).isNotEmpty(); - } } diff --git a/java/test/org/openqa/selenium/remote/DesiredCapabilitiesTest.java b/java/test/org/openqa/selenium/remote/DesiredCapabilitiesTest.java index 7d85422ac5115..59232674c7362 100644 --- a/java/test/org/openqa/selenium/remote/DesiredCapabilitiesTest.java +++ b/java/test/org/openqa/selenium/remote/DesiredCapabilitiesTest.java @@ -19,17 +19,15 @@ import com.google.common.collect.ImmutableMap; -import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.openqa.selenium.Capabilities; import org.openqa.selenium.Platform; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxOptions; -import org.openqa.selenium.logging.LoggingPreferences; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import java.util.logging.Level; import static org.assertj.core.api.Assertions.assertThat; @@ -80,17 +78,6 @@ void testCopyConstructorDoesNotAliasToArgument() { assertThat(newCapabilities.getCapability("BrowserName")).isEqualTo("firefox"); } - @Test - void testExtractDebugLogLevelFromCapabilityMap() { - Map capabilitiesMap - = ImmutableMap.of(CapabilityType.LOGGING_PREFS, ImmutableMap.of("browser", "DEBUG")); - - DesiredCapabilities caps = new DesiredCapabilities(capabilitiesMap); - LoggingPreferences prefs = - (LoggingPreferences) caps.getCapability(CapabilityType.LOGGING_PREFS); - assertThat(prefs.getLevel("browser")).isSameAs(Level.FINE); - } - @Test void shouldAutomaticallyConvertPlatformFromStringToEnum() { DesiredCapabilities caps = new DesiredCapabilities();