2929import static org .openqa .selenium .testing .Driver .PHANTOMJS ;
3030import static org .openqa .selenium .testing .Driver .SAFARI ;
3131
32- import com .google .common .base .Predicate ;
3332import com .google .common .collect .ImmutableList ;
34- import com .google .common .collect .Iterables ;
3533
3634import org .junit .After ;
3735import org .junit .Test ;
3836import org .openqa .selenium .By ;
39- import org .openqa .selenium .Capabilities ;
37+ import org .openqa .selenium .ImmutableCapabilities ;
4038import org .openqa .selenium .WebDriver ;
41- import org .openqa .selenium .firefox .FirefoxOptions ;
4239import org .openqa .selenium .logging .profiler .EventType ;
4340import org .openqa .selenium .testing .Ignore ;
4441import org .openqa .selenium .testing .JUnit4TestBase ;
4542import org .openqa .selenium .testing .drivers .WebDriverBuilder ;
4643
4744import java .util .Arrays ;
45+ import java .util .stream .Collectors ;
46+ import java .util .stream .StreamSupport ;
4847
4948@ Ignore (HTMLUNIT )
5049@ Ignore (IE )
@@ -118,7 +117,7 @@ public void testGetsYieldToPageLoadLogEntries() throws Exception {
118117 private void startLoggingDriver () {
119118 if (loggingDriver == null ) {
120119 WebDriverBuilder builder = new WebDriverBuilder ().setDesiredCapabilities (
121- getCapabilitiesWithProfilerOn ( true ));
120+ new ImmutableCapabilities ( ENABLE_PROFILING_CAPABILITY , true ));
122121 loggingDriver = builder .get ();
123122 }
124123 }
@@ -129,16 +128,7 @@ private LogEntries getProfilerEntries(WebDriver driver) {
129128
130129 private ImmutableList <LogEntry > getProfilerEntriesOfType (final LogEntries entries ,
131130 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 ()));
143133 }
144134}
0 commit comments