Skip to content

Commit 63a79bd

Browse files
committed
[java] Removing deprecated ENABLE_PROFILING_CAPABILITY cap
1 parent 7b212ee commit 63a79bd

File tree

4 files changed

+12
-107
lines changed

4 files changed

+12
-107
lines changed

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

-7
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,6 @@ public interface CapabilityType {
8686
@Deprecated
8787
String LOGGING_PREFS = "loggingPrefs";
8888

89-
/**
90-
* @deprecated Non W3C compliant
91-
*/
92-
@Deprecated
93-
String ENABLE_PROFILING_CAPABILITY = "webdriver.logging.profiler.enabled";
94-
95-
9689
String BROWSER_NAME = "browserName";
9790
String PLATFORM_NAME = "platformName";
9891
String BROWSER_VERSION = "browserVersion";

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

-5
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,6 @@ private Capabilities init(Capabilities capabilities) {
205205

206206
ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>();
207207

208-
boolean isProfilingEnabled = capabilities.is(CapabilityType.ENABLE_PROFILING_CAPABILITY);
209-
if (isProfilingEnabled) {
210-
builder.add(LogType.PROFILER);
211-
}
212-
213208
LoggingPreferences mergedLoggingPrefs = new LoggingPreferences();
214209
mergedLoggingPrefs.addPreferences((LoggingPreferences) capabilities.getCapability(LOGGING_PREFS));
215210

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

+7-21
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,21 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import static org.assertj.core.api.Assertions.assertThat;
21-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
22-
import static org.openqa.selenium.remote.CapabilityType.ENABLE_PROFILING_CAPABILITY;
23-
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
24-
import static org.openqa.selenium.testing.drivers.Browser.IE;
25-
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
26-
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
27-
2820
import org.junit.jupiter.api.AfterEach;
2921
import org.junit.jupiter.api.Test;
30-
import org.openqa.selenium.Capabilities;
31-
import org.openqa.selenium.ImmutableCapabilities;
3222
import org.openqa.selenium.WebDriver;
3323
import org.openqa.selenium.testing.Ignore;
3424
import org.openqa.selenium.testing.JupiterTestBase;
35-
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
3625

3726
import java.util.Set;
3827

28+
import static org.assertj.core.api.Assertions.assertThat;
29+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
30+
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
31+
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
32+
import static org.openqa.selenium.testing.drivers.Browser.IE;
33+
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
34+
3935
@Ignore(HTMLUNIT)
4036
@Ignore(IE)
4137
@Ignore(FIREFOX)
@@ -91,16 +87,6 @@ void profilerLogShouldBeDisabledByDefault() {
9187
.describedAs("Profiler logs should not be enabled by default").isFalse();
9288
}
9389

94-
@Test
95-
@Ignore(value = SAFARI, reason = "Safari does not support profiler logs")
96-
public void shouldBeAbleToEnableProfilerLog() {
97-
Capabilities caps = new ImmutableCapabilities(ENABLE_PROFILING_CAPABILITY, true);
98-
localDriver = new WebDriverBuilder().get(caps);
99-
Set<String> logTypes = localDriver.manage().logs().getAvailableLogTypes();
100-
assertThat(logTypes.contains(LogType.PROFILER))
101-
.describedAs("Profiler log should be enabled").isTrue();
102-
}
103-
10490
@Test
10591
void serverLogShouldBeEnabledByDefaultOnRemote() {
10692
assumeTrue(Boolean.getBoolean("selenium.browser.remote"));

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

+5-74
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,17 @@
1717

1818
package org.openqa.selenium.logging;
1919

20-
import static org.assertj.core.api.Assertions.assertThat;
21-
import static org.openqa.selenium.remote.CapabilityType.ENABLE_PROFILING_CAPABILITY;
22-
import static org.openqa.selenium.testing.drivers.Browser.CHROME;
23-
import static org.openqa.selenium.testing.drivers.Browser.EDGE;
24-
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
25-
import static org.openqa.selenium.testing.drivers.Browser.IE;
26-
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
27-
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
28-
2920
import org.junit.jupiter.api.AfterEach;
3021
import org.junit.jupiter.api.Test;
31-
import org.openqa.selenium.By;
32-
import org.openqa.selenium.ImmutableCapabilities;
3322
import org.openqa.selenium.WebDriver;
34-
import org.openqa.selenium.logging.profiler.EventType;
3523
import org.openqa.selenium.testing.Ignore;
3624
import org.openqa.selenium.testing.JupiterTestBase;
37-
import org.openqa.selenium.testing.drivers.WebDriverBuilder;
3825

39-
import java.util.List;
40-
import java.util.stream.Collectors;
41-
import java.util.stream.StreamSupport;
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
import static org.openqa.selenium.testing.drivers.Browser.FIREFOX;
28+
import static org.openqa.selenium.testing.drivers.Browser.HTMLUNIT;
29+
import static org.openqa.selenium.testing.drivers.Browser.IE;
30+
import static org.openqa.selenium.testing.drivers.Browser.SAFARI;
4231

4332
@Ignore(HTMLUNIT)
4433
@Ignore(IE)
@@ -64,65 +53,7 @@ void testDisabledProfilingDoesNotLog() {
6453
.isEmpty();
6554
}
6655

67-
@Test
68-
void testLogsSingleHttpCommand() {
69-
startLoggingDriver();
70-
List<LogEntry> entries = getProfilerEntriesOfType(getProfilerEntries(loggingDriver),
71-
EventType.HTTP_COMMAND);
72-
// Expect start of newSession, end of newSession, start of getLogs, end of getLogs
73-
String[] expected = {"\"command\": \"newSession\",\"startorend\": \"start\"",
74-
"\"command\": \"newSession\",\"startorend\": \"end\"",
75-
"\"command\": \"getLog\",\"startorend\": \"start\"",
76-
"\"command\": \"getLog\",\"startorend\": \"end\""};
77-
assertThat(containsExpectedEntries(entries, expected)).isTrue();
78-
}
79-
80-
/**
81-
* Checks if the given list of strings occur in the given order among the
82-
* given log messages (one string per message).
83-
*
84-
* @param entries The list of log entries.
85-
* @param expected The array of expected strings.
86-
* @return true if a match was found for all expected strings, otherwise false.
87-
*/
88-
private boolean containsExpectedEntries(List<LogEntry> entries, String[] expected) {
89-
int index = 0;
90-
for (LogEntry entry : entries) {
91-
if (index == expected.length) {
92-
return true;
93-
}
94-
if (!entry.getMessage().contains(expected[index])) {
95-
index++;
96-
}
97-
}
98-
return (index == expected.length);
99-
}
100-
101-
@Test
102-
@Ignore(CHROME)
103-
@Ignore(EDGE)
104-
public void testGetsYieldToPageLoadLogEntries() {
105-
startLoggingDriver();
106-
loggingDriver.get(pages.formPage);
107-
loggingDriver.findElement(By.id("submitButton")).click();
108-
assertThat(
109-
getProfilerEntriesOfType(getProfilerEntries(loggingDriver), EventType.YIELD_TO_PAGE_LOAD).size())
110-
.isPositive();
111-
}
112-
113-
private void startLoggingDriver() {
114-
if (loggingDriver == null) {
115-
loggingDriver = new WebDriverBuilder()
116-
.get(new ImmutableCapabilities(ENABLE_PROFILING_CAPABILITY, true));
117-
}
118-
}
119-
12056
private LogEntries getProfilerEntries(WebDriver driver) {
12157
return driver.manage().logs().get(LogType.PROFILER);
12258
}
123-
124-
private List<LogEntry> getProfilerEntriesOfType(LogEntries entries, EventType eventType) {
125-
return StreamSupport.stream(entries.spliterator(), false).filter(
126-
entry -> entry.getMessage().contains(eventType.toString())).collect(Collectors.toList());
127-
}
12859
}

0 commit comments

Comments
 (0)