Skip to content

Commit

Permalink
improve selenium driver management
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilou242 committed Nov 4, 2023
1 parent 9ed6492 commit 878ce12
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jnotebook-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.apache.commons.io.FileUtils;
import org.jetbrains.annotations.NotNull;
import org.jsoup.Jsoup;
Expand Down Expand Up @@ -104,6 +105,7 @@ private String optimizeHtml(String html) {
miniServer.server.start();
// use selenium to render the file with javascript in a browser and parse the content
ChromeOptions options = new ChromeOptions().addArguments("--headless=new");
WebDriverManager.chromedriver().setup();
final WebDriver webDriver = new ChromeDriver(options);
webDriver.get(miniServer.url);
final String htmlWithOpti = webDriver.getPageSource();
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
<artifactId>selenium-java</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.6.1</version>
</dependency>
<dependency>
<!-- jsoup HTML parser library @ https://jsoup.org/ -->
<groupId>org.jsoup</groupId>
Expand Down

0 comments on commit 878ce12

Please sign in to comment.