Reputation: 914
I use -D java parameters to specify the path to executable driver when register a new node in selenium grid:
java -Dwebdriver.chrome.driver="../driver/chromedriver.exe" -jar selenium-server-standalone-3.3.1.jar -role node -hub http://localhost:4445/grid/register -nodeConfig config/defaultNodeConfig.json
I'd like to use webdrivermanager-java library (https://github.com/bonigarcia/webdrivermanager) to manage driver executable files. But it registers drivers using System.setProperty(), so it available only in JVM where the library is running (am I mistaken?).
My question is:
What is the proper way to call webdrivermanager-java from command line before starting he node and how to export path of downloaded drivers to selenium node's -D java parameter?
I have an idea to create tiny "node-runner" java application and call webdrivermanager and selenium-server-standalone.jar in it, so they use the same JVM environment.
Is there a better solution to set nodes' drivers paths using webdrivermanager?
Upvotes: 1
Views: 943
Reputation: 4858
Indeed, IMHO the best choice is to create a Java application in which you call WebDriverManager first, and then you register the node in the hub. Something like this:
Dependencies
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.1</version>
</dependency>
</dependencies>
App to start a Selenium hub
import org.openqa.grid.selenium.GridLauncherV3;
public class StartHub {
public static void main(String[] args) throws Exception {
GridLauncherV3.main(new String[] { "-role", "hub", "-port", "4444" });
}
}
App to register a node (Chrome in this example) in the hub
import org.openqa.grid.selenium.GridLauncherV3;
import io.github.bonigarcia.wdm.WebDriverManager;
public class StartNode {
public static void main(String[] args) throws Exception {
WebDriverManager.chromedriver().setup();
GridLauncherV3.main(new String[] { "-role", "node", "-hub",
"http://localhost:4444/grid/register", "-browser",
"browserName=chrome" });
}
}
Upvotes: 2