29
29
import static org .openqa .selenium .testing .Driver .PHANTOMJS ;
30
30
import static org .openqa .selenium .testing .Driver .SAFARI ;
31
31
32
- import com .google .common .base .Predicate ;
33
32
import com .google .common .collect .ImmutableList ;
34
- import com .google .common .collect .Iterables ;
35
33
36
34
import org .junit .After ;
37
35
import org .junit .Test ;
38
36
import org .openqa .selenium .By ;
39
- import org .openqa .selenium .Capabilities ;
37
+ import org .openqa .selenium .ImmutableCapabilities ;
40
38
import org .openqa .selenium .WebDriver ;
41
- import org .openqa .selenium .firefox .FirefoxOptions ;
42
39
import org .openqa .selenium .logging .profiler .EventType ;
43
40
import org .openqa .selenium .testing .Ignore ;
44
41
import org .openqa .selenium .testing .JUnit4TestBase ;
45
42
import org .openqa .selenium .testing .drivers .WebDriverBuilder ;
46
43
47
44
import java .util .Arrays ;
45
+ import java .util .stream .Collectors ;
46
+ import java .util .stream .StreamSupport ;
48
47
49
48
@ Ignore (HTMLUNIT )
50
49
@ Ignore (IE )
@@ -118,7 +117,7 @@ public void testGetsYieldToPageLoadLogEntries() throws Exception {
118
117
private void startLoggingDriver () {
119
118
if (loggingDriver == null ) {
120
119
WebDriverBuilder builder = new WebDriverBuilder ().setDesiredCapabilities (
121
- getCapabilitiesWithProfilerOn ( true ));
120
+ new ImmutableCapabilities ( ENABLE_PROFILING_CAPABILITY , true ));
122
121
loggingDriver = builder .get ();
123
122
}
124
123
}
@@ -129,16 +128,7 @@ private LogEntries getProfilerEntries(WebDriver driver) {
129
128
130
129
private ImmutableList <LogEntry > getProfilerEntriesOfType (final LogEntries entries ,
131
130
final EventType eventType ) {
132
- return ImmutableList .copyOf (Iterables .filter (entries , new Predicate <LogEntry >() {
133
- public boolean apply (LogEntry entry ) {
134
- return entry .getMessage ().contains (eventType .toString ());
135
- }
136
- }));
137
- }
138
-
139
- private static Capabilities getCapabilitiesWithProfilerOn (boolean enabled ) {
140
- FirefoxOptions options = new FirefoxOptions ();
141
- options .setCapability (ENABLE_PROFILING_CAPABILITY , enabled );
142
- return options ;
131
+ return ImmutableList .copyOf (StreamSupport .stream (entries .spliterator (), false ).filter (
132
+ entry -> entry .getMessage ().contains (eventType .toString ())).collect (Collectors .toList ()));
143
133
}
144
134
}
0 commit comments