Skip to content

Commit 83f0a32

Browse files
joshbruningsevaseva
authored andcommitted
Test remote end does not support profiler logs.
When a remote driver does not support profiler logs, it may throw WebDriverException. That exception should not prevent the user from retrieving the local profiler logs. Signed-off-by: Seva Lotoshnikov <[email protected]>
1 parent e1b34f6 commit 83f0a32

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Diff for: java/client/test/org/openqa/selenium/remote/RemoteLogsTest.java

+19
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.junit.runners.JUnit4;
3131
import org.mockito.Mock;
3232
import org.mockito.MockitoAnnotations;
33+
import org.openqa.selenium.WebDriverException;
3334
import org.openqa.selenium.logging.LocalLogs;
3435
import org.openqa.selenium.logging.LogEntries;
3536
import org.openqa.selenium.logging.LogEntry;
@@ -76,6 +77,24 @@ public void canGetProfilerLogs() {
7677
assertEquals("world", allLogEntries.get(1).getMessage());
7778
}
7879

80+
@Test
81+
public void canGetLocalProfilerLogsIfNoRemoteProfilerLogSupport() {
82+
List<LogEntry> entries = new ArrayList<LogEntry>();
83+
entries.add(new LogEntry(Level.INFO, 0, "hello"));
84+
when(localLogs.get(LogType.PROFILER)).thenReturn(new LogEntries(entries));
85+
86+
when(
87+
executeMethod.execute(
88+
DriverCommand.GET_LOG, ImmutableMap.of(RemoteLogs.TYPE_KEY, LogType.PROFILER)))
89+
.thenThrow(
90+
new WebDriverException("IGNORE THIS LOG MESSAGE AND STACKTRACE; IT IS EXPECTED."));
91+
92+
LogEntries logEntries = remoteLogs.get(LogType.PROFILER);
93+
List<LogEntry> allLogEntries = logEntries.getAll();
94+
assertEquals(1, allLogEntries.size());
95+
assertEquals("hello", allLogEntries.get(0).getMessage());
96+
}
97+
7998
@Test
8099
public void canGetClientLogs() {
81100
List<LogEntry> entries = new ArrayList<LogEntry>();

0 commit comments

Comments
 (0)