Skip to content

Commit c583458

Browse files
committed
[java] Removing deprecated LOGGING_PREFS cap
1 parent 5fbddf6 commit c583458

File tree

6 files changed

+14
-130
lines changed

6 files changed

+14
-130
lines changed

java/src/org/openqa/selenium/remote/CapabilityType.java

-8
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ public interface CapabilityType {
6868
@Deprecated
6969
String OVERLAPPING_CHECK_DISABLED = "overlappingCheckDisabled";
7070

71-
/**
72-
* @deprecated Non W3C compliant
73-
* Use {@link org.openqa.selenium.chrome.ChromeOptions#LOGGING_PREFS} or
74-
* Use {@link org.openqa.selenium.edge.EdgeOptions#LOGGING_PREFS}
75-
*/
76-
@Deprecated
77-
String LOGGING_PREFS = "loggingPrefs";
78-
7971
String BROWSER_NAME = "browserName";
8072
String PLATFORM_NAME = "platformName";
8173
String BROWSER_VERSION = "browserVersion";

java/src/org/openqa/selenium/remote/RemoteWebDriver.java

-11
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@
5353
import org.openqa.selenium.interactions.Sequence;
5454
import org.openqa.selenium.internal.Require;
5555
import org.openqa.selenium.logging.LocalLogs;
56-
import org.openqa.selenium.logging.LogType;
5756
import org.openqa.selenium.logging.LoggingHandler;
58-
import org.openqa.selenium.logging.LoggingPreferences;
5957
import org.openqa.selenium.logging.Logs;
6058
import org.openqa.selenium.logging.NeedsLocalLogs;
6159
import org.openqa.selenium.print.PrintOptions;
@@ -93,7 +91,6 @@
9391
import static java.util.Collections.singleton;
9492
import static java.util.concurrent.TimeUnit.SECONDS;
9593
import static java.util.logging.Level.SEVERE;
96-
import static org.openqa.selenium.remote.CapabilityType.LOGGING_PREFS;
9794
import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME;
9895
import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_JAVASCRIPT;
9996

@@ -205,14 +202,6 @@ private Capabilities init(Capabilities capabilities) {
205202

206203
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
207204

208-
LoggingPreferences mergedLoggingPrefs = new LoggingPreferences();
209-
mergedLoggingPrefs.addPreferences((LoggingPreferences) capabilities.getCapability(LOGGING_PREFS));
210-
211-
if (!mergedLoggingPrefs.getEnabledLogTypes().contains(LogType.CLIENT) ||
212-
mergedLoggingPrefs.getLevel(LogType.CLIENT) != Level.OFF) {
213-
builder.add(LogType.CLIENT);
214-
}
215-
216205
Set<String> logTypesToInclude = builder.build();
217206

218207
LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToInclude);

java/test/org/openqa/selenium/json/JsonTest.java

+1-31
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
import com.google.common.collect.ImmutableMap;
2121
import com.google.common.reflect.TypeToken;
2222

23-
import org.junit.jupiter.api.Test;
2423
import org.junit.jupiter.api.Tag;
24+
import org.junit.jupiter.api.Test;
2525
import org.openqa.selenium.Capabilities;
2626
import org.openqa.selenium.Cookie;
2727
import org.openqa.selenium.ImmutableCapabilities;
2828
import org.openqa.selenium.MutableCapabilities;
2929
import org.openqa.selenium.Platform;
3030
import org.openqa.selenium.Proxy;
31-
import org.openqa.selenium.logging.LoggingPreferences;
3231
import org.openqa.selenium.remote.CapabilityType;
3332
import org.openqa.selenium.remote.Command;
3433
import org.openqa.selenium.remote.DesiredCapabilities;
@@ -46,20 +45,12 @@
4645
import java.util.Map;
4746
import java.util.concurrent.TimeUnit;
4847

49-
import static java.util.logging.Level.ALL;
50-
import static java.util.logging.Level.FINE;
51-
import static java.util.logging.Level.OFF;
52-
import static java.util.logging.Level.WARNING;
5348
import static org.assertj.core.api.Assertions.assertThat;
5449
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
5550
import static org.assertj.core.api.Assertions.byLessThan;
5651
import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
5752
import static org.openqa.selenium.Proxy.ProxyType.PAC;
5853
import static org.openqa.selenium.json.Json.MAP_TYPE;
59-
import static org.openqa.selenium.logging.LogType.BROWSER;
60-
import static org.openqa.selenium.logging.LogType.CLIENT;
61-
import static org.openqa.selenium.logging.LogType.DRIVER;
62-
import static org.openqa.selenium.logging.LogType.SERVER;
6354

6455
@Tag("UnitTests")
6556
class JsonTest {
@@ -370,27 +361,6 @@ void shouldConvertCapabilitiesToAMapAndIncludeCustomValues() {
370361
assertThat(converted.getCapability("furrfu")).isEqualTo("fishy");
371362
}
372363

373-
@Test
374-
void shouldParseCapabilitiesWithLoggingPreferences() {
375-
String caps = String.format(
376-
"{\"%s\": {" +
377-
"\"browser\": \"WARNING\"," +
378-
"\"client\": \"DEBUG\", " +
379-
"\"driver\": \"ALL\", " +
380-
"\"server\": \"OFF\"}}",
381-
CapabilityType.LOGGING_PREFS);
382-
383-
Capabilities converted = new Json().toType(caps, Capabilities.class);
384-
385-
LoggingPreferences lp =
386-
(LoggingPreferences) converted.getCapability(CapabilityType.LOGGING_PREFS);
387-
assertThat(lp).isNotNull();
388-
assertThat(lp.getLevel(BROWSER)).isEqualTo(WARNING);
389-
assertThat(lp.getLevel(CLIENT)).isEqualTo(FINE);
390-
assertThat(lp.getLevel(DRIVER)).isEqualTo(ALL);
391-
assertThat(lp.getLevel(SERVER)).isEqualTo(OFF);
392-
}
393-
394364
@Test
395365
void shouldNotParseQuotedJsonObjectsAsActualJsonObjects() {
396366
String jsonStr = "{\"inner\":\"{\\\"color\\\":\\\"green\\\",\\\"number\\\":123}\"}";

java/test/org/openqa/selenium/logging/GetLogsTest.java

+6-32
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,22 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import static org.assertj.core.api.Assertions.assertThat;
21-
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
22-
import static org.openqa.selenium.testing.drivers.Browser.IE;
23-
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
24-
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
25-
2620
import org.junit.jupiter.api.AfterEach;
2721
import org.junit.jupiter.api.Test;
2822
import org.openqa.selenium.By;
29-
import org.openqa.selenium.Capabilities;
30-
import org.openqa.selenium.ImmutableCapabilities;
3123
import org.openqa.selenium.WebDriver;
32-
import org.openqa.selenium.remote.CapabilityType;
3324
import org.openqa.selenium.testing.Ignore;
3425
import org.openqa.selenium.testing.JupiterTestBase;
35-
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
3626

3727
import java.util.HashMap;
3828
import java.util.Map;
3929
import java.util.Set;
40-
import java.util.logging.Level;
30+
31+
import static org.assertj.core.api.Assertions.assertThat;
32+
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
33+
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
34+
import static org.openqa.selenium.testing.drivers.Browser.IE;
35+
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
4136

4237
@Ignore(HTMLUNIT)
4338
@Ignore(IE)
@@ -114,25 +109,4 @@ private static boolean hasOverlappingLogEntries(LogEntries firstLog, LogEntries
114109
return false;
115110
}
116111

117-
@Test
118-
void turningOffLogShouldMeanNoLogMessages() {
119-
Set<String> logTypes = driver.manage().logs().getAvailableLogTypes();
120-
for (String logType : logTypes) {
121-
createWebDriverWithLogging(logType, Level.OFF);
122-
LogEntries entries = localDriver.manage().logs().get(logType);
123-
assertThat(entries.getAll())
124-
.describedAs("There should be no log entries for log type %s when logging is turned off.", logType)
125-
.isEmpty();
126-
quitDriver();
127-
}
128-
}
129-
130-
private void createWebDriverWithLogging(String logType, Level logLevel) {
131-
LoggingPreferences loggingPrefs = new LoggingPreferences();
132-
loggingPrefs.enable(logType, logLevel);
133-
Capabilities caps = new ImmutableCapabilities(CapabilityType.LOGGING_PREFS, loggingPrefs);
134-
localDriver = new WebDriverBuilder().get(caps);
135-
localDriver.get(pages.errorsPage);
136-
localDriver.findElement(By.cssSelector("input")).click();
137-
}
138112
}

java/test/org/openqa/selenium/logging/PerformanceLogTypeTest.java

+6-34
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,19 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import static org.assertj.core.api.Assertions.assertThat;
21-
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
22-
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
23-
import static org.openqa.selenium.testing.drivers.Browser.IE;
24-
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
25-
2620
import org.junit.jupiter.api.AfterEach;
2721
import org.junit.jupiter.api.Test;
28-
import org.openqa.selenium.Capabilities;
29-
import org.openqa.selenium.ImmutableCapabilities;
3022
import org.openqa.selenium.WebDriver;
31-
import org.openqa.selenium.remote.CapabilityType;
3223
import org.openqa.selenium.testing.Ignore;
3324
import org.openqa.selenium.testing.JupiterTestBase;
34-
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
3525

3626
import java.util.Set;
37-
import java.util.logging.Level;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
30+
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
31+
import static org.openqa.selenium.testing.drivers.Browser.IE;
32+
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
3833

3934
@Ignore(HTMLUNIT)
4035
@Ignore(IE)
@@ -58,27 +53,4 @@ void performanceLogShouldBeDisabledByDefault() {
5853
assertThat(logTypes.contains(LogType.PERFORMANCE))
5954
.describedAs("Performance log should not be enabled by default").isFalse();
6055
}
61-
62-
void createLocalDriverWithPerformanceLogType() {
63-
LoggingPreferences logPrefs = new LoggingPreferences();
64-
logPrefs.enable(LogType.PERFORMANCE, Level.INFO);
65-
Capabilities caps = new ImmutableCapabilities(CapabilityType.LOGGING_PREFS, logPrefs);
66-
localDriver = new WebDriverBuilder().get(caps);
67-
}
68-
69-
@Test
70-
void shouldBeAbleToEnablePerformanceLog() {
71-
createLocalDriverWithPerformanceLogType();
72-
Set<String> logTypes = localDriver.manage().logs().getAvailableLogTypes();
73-
assertThat(logTypes.contains(LogType.PERFORMANCE))
74-
.describedAs("Profiler log should be enabled").isTrue();
75-
}
76-
77-
@Test
78-
void pageLoadShouldProducePerformanceLogEntries() {
79-
createLocalDriverWithPerformanceLogType();
80-
localDriver.get(pages.simpleTestPage);
81-
LogEntries entries = localDriver.manage().logs().get(LogType.PERFORMANCE);
82-
assertThat(entries).isNotEmpty();
83-
}
8456
}

java/test/org/openqa/selenium/remote/DesiredCapabilitiesTest.java

+1-14
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919

2020
import com.google.common.collect.ImmutableMap;
2121

22-
import org.junit.jupiter.api.Test;
2322
import org.junit.jupiter.api.Tag;
23+
import org.junit.jupiter.api.Test;
2424
import org.openqa.selenium.Capabilities;
2525
import org.openqa.selenium.Platform;
2626
import org.openqa.selenium.WebDriver;
2727
import org.openqa.selenium.firefox.FirefoxOptions;
28-
import org.openqa.selenium.logging.LoggingPreferences;
2928

3029
import java.util.Map;
3130
import java.util.concurrent.ConcurrentHashMap;
32-
import java.util.logging.Level;
3331

3432
import static org.assertj.core.api.Assertions.assertThat;
3533

@@ -80,17 +78,6 @@ void testCopyConstructorDoesNotAliasToArgument() {
8078
assertThat(newCapabilities.getCapability("BrowserName")).isEqualTo("firefox");
8179
}
8280

83-
@Test
84-
void testExtractDebugLogLevelFromCapabilityMap() {
85-
Map<String, Object> capabilitiesMap
86-
= ImmutableMap.of(CapabilityType.LOGGING_PREFS, ImmutableMap.of("browser", "DEBUG"));
87-
88-
DesiredCapabilities caps = new DesiredCapabilities(capabilitiesMap);
89-
LoggingPreferences prefs =
90-
(LoggingPreferences) caps.getCapability(CapabilityType.LOGGING_PREFS);
91-
assertThat(prefs.getLevel("browser")).isSameAs(Level.FINE);
92-
}
93-
9481
@Test
9582
void shouldAutomaticallyConvertPlatformFromStringToEnum() {
9683
DesiredCapabilities caps = new DesiredCapabilities();

0 commit comments

Comments
 (0)