This tutorial demonstrates how to create a simple Selenium WebDriver application that is configured to access a web page in a desktop Java application based on JxBrowser.
Creating of these example projects is described in the tutorial.
The tutorial requires the jpackage tool available in PATH, so make sure that
the environment variable contains the %JAVA_HOME%/bin directory.
-
In the root directory, run the
downloadChromeDrivertask of the launcher module to download ChromeDriver to theresourcesdirectory:Windows:
gradlew launcher:downloadChromeDriver
macOS/Linux:
./gradlew launcher:downloadChromeDriver
Each version of ChromeDriver corresponds to the Chromium version used in JxBrowser. If you change the JxBrowser version in build.gradle.kts you need to update the
chromiumVersionproperty here before running thedownloadChromeDrivertask. Otherwise, Selenium WebDriver will not be able to connect to Chromium. You can find which Chromium version is used in the specific JxBrowser version in the release notes. -
In the root directory, run the
buildApplicationtask of the target-app module to create an executable file for the current platform that later will be run by Selenium WebDriver.Windows:
gradlew target-app:clean target-app:buildApplication
macOS/Linux:
./gradlew target-app:clean target-app:buildApplication
-
Run Selenium.
-
If everything configured properly, you will see the launched test application, and the following console output:
Current URL: about:blank // or Current URL: https://www.google.com/It means that Selenium WebDriver managed to successfully run the application, set up a connection with the JxBrowser's Chromium, and access the loaded web page to print its URL.