Skip to content

Commit 327744d

Browse files
committed
Add initial support for chrome launcher
1 parent 6823a7f commit 327744d

File tree

4 files changed

+1167
-8
lines changed

4 files changed

+1167
-8
lines changed

cdtp-java-client/src/main/java/com/github/kklisura/cdtp/App.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
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.
@@ -20,17 +20,19 @@
2020
* #L%
2121
*/
2222

23+
import com.github.kklisura.cdtp.launch.ChromeLauncher;
2324
import com.github.kklisura.cdtp.protocol.events.network.RequestWillBeSent;
2425
import com.github.kklisura.cdtp.protocol.support.types.EventHandler;
2526
import com.github.kklisura.cdtp.services.ChromeDevToolsService;
2627
import com.github.kklisura.cdtp.services.ChromeService;
27-
import com.github.kklisura.cdtp.services.impl.ChromeServiceImpl;
2828
import com.github.kklisura.cdtp.services.types.ChromeTab;
2929

3030
/** Hello world! */
3131
public 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

Comments
 (0)