99 * Licensed under the Apache License, Version 2.0 (the "License");
1010 * you may not use this file except in compliance with the License.
1111 * You may obtain a copy of the License at
12- *
12+ *
1313 * http://www.apache.org/licenses/LICENSE-2.0
14- *
14+ *
1515 * Unless required by applicable law or agreed to in writing, software
1616 * distributed under the License is distributed on an "AS IS" BASIS,
1717 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2020 * #L%
2121 */
2222
23+ import com .github .kklisura .cdtp .launch .ChromeLauncher ;
2324import com .github .kklisura .cdtp .protocol .events .network .RequestWillBeSent ;
2425import com .github .kklisura .cdtp .protocol .support .types .EventHandler ;
2526import com .github .kklisura .cdtp .services .ChromeDevToolsService ;
2627import com .github .kklisura .cdtp .services .ChromeService ;
27- import com .github .kklisura .cdtp .services .impl .ChromeServiceImpl ;
2828import com .github .kklisura .cdtp .services .types .ChromeTab ;
2929
3030/** Hello world! */
3131public class App {
3232 public static void main (String [] args ) throws Exception {
33- final ChromeService chromeService = new ChromeServiceImpl (9222 );
33+ ChromeLauncher chromeLauncher = new ChromeLauncher ();
34+
35+ final ChromeService chromeService = chromeLauncher .launch (false );
3436 final ChromeTab tab = chromeService .createTab ();
3537
3638 try (ChromeDevToolsService cdtpService = chromeService .createDevToolsService (tab )) {
@@ -47,14 +49,13 @@ public void onEvent(RequestWillBeSent event) {
4749
4850 cdtpService .getNetwork ().enable ();
4951
50- // Network requestWillBeSent event
51- // Page loadEventFired
52-
53- cdtpService .getPage ().navigate ("http://google.com" );
52+ cdtpService .getPage ().navigate ("http://github.com" );
5453
5554 Thread .sleep (10000 );
5655 }
5756
5857 chromeService .closeTab (tab );
58+
59+ chromeLauncher .close ();
5960 }
6061}
0 commit comments