File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
src/org/openqa/selenium/remote
test/org/openqa/selenium/remote Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 23
23
import com .google .common .collect .Lists ;
24
24
25
25
import org .openqa .selenium .Beta ;
26
+ import org .openqa .selenium .UnsupportedCommandException ;
26
27
import org .openqa .selenium .WebDriverException ;
27
28
import org .openqa .selenium .logging .LocalLogs ;
28
29
import org .openqa .selenium .logging .LogCombiner ;
@@ -79,6 +80,9 @@ public LogEntries get(String logType) {
79
80
80
81
private LogEntries getRemoteEntries (String logType ) {
81
82
Object raw = executeMethod .execute (DriverCommand .GET_LOG , ImmutableMap .of (TYPE_KEY , logType ));
83
+ if (!(raw instanceof List )) {
84
+ throw new UnsupportedCommandException ("malformed response to remote logs command" );
85
+ }
82
86
@ SuppressWarnings ("unchecked" )
83
87
List <Map <String , Object >> rawList = (List <Map <String , Object >>) raw ;
84
88
List <LogEntry > remoteEntries = Lists .newArrayListWithCapacity (rawList .size ());
Original file line number Diff line number Diff line change 18
18
package org .openqa .selenium .remote ;
19
19
20
20
import static org .junit .Assert .assertEquals ;
21
+ import static org .junit .Assert .fail ;
21
22
import static org .mockito .Mockito .verifyNoMoreInteractions ;
22
23
import static org .mockito .Mockito .when ;
23
24
@@ -125,6 +126,24 @@ public void canGetServerLogs() {
125
126
verifyNoMoreInteractions (localLogs );
126
127
}
127
128
129
+ @ Test
130
+ public void throwsOnBogusRemoteLogsResponse () {
131
+ when (
132
+ executeMethod
133
+ .execute (DriverCommand .GET_LOG , ImmutableMap .of (RemoteLogs .TYPE_KEY , LogType .BROWSER )))
134
+ .thenReturn (new ImmutableMap .Builder ()
135
+ .put ("error" , "unknown method" )
136
+ .put ("message" , "Command not found: POST /session/11037/log" )
137
+ .put ("stacktrace" , "" ).build ());
138
+ try {
139
+ remoteLogs .get (LogType .BROWSER );
140
+ fail ("Should have thrown WebDriverException" );
141
+ } catch (WebDriverException expected ) {
142
+ }
143
+
144
+ verifyNoMoreInteractions (localLogs );
145
+ }
146
+
128
147
@ Test
129
148
public void canGetAvailableLogTypes () {
130
149
List <String > remoteAvailableLogTypes = new ArrayList <>();
You can’t perform that action at this time.
0 commit comments