Skip to content

Commit 9922fd6

Browse files
Adjustments to start Options (#660)
* Adjustments to start options Could not get the test suite to pass. Ran into two issues due to options (or lack of options) being passed to the `start` function. Rather than adjust the test suite to pass the necessary option I thought it would be better to adjust the API to have defaults so the options are not necessary. Spawn Options Stdio =================== This defaults to `pipe`. With this default the behavior I was getting is that the `checkStarted` was always failing. This was obviously not an issue at some point. I am guessing that the selenium jar file changed it's behavior so that it didn't fully boot up until some stdio activity occurred and since this library is not interacting with that pipe it remained not booted. I noticed the `bin/selenium-standalone` script did not have a problem booting the server. After a bit of debugging determined it is because it sets the spawnOptions.stdio to `inherit`. This allows that sub-process to not be blocked by stdio. I considered also defaulting spawnOptions.stdio to 'inhert' with the API but I'm not sure writing on top of the parent's STDIO is the right default behavior. It would seem being quite and squashing stdio (sending to /dev/null) is a better default so I set it to `ignore`. Obviously if this is not the right behavior for a specific application they can always override. Add `--detect-drivers false` Option =================================== Once the above fix to the boot process was made I was still getting a problem with one test, "should start with the given drivers", where no driver are being specified. When this is run the selenium-standalone jar was giving me the following error: 10:56:47.730 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding 10:56:47.733 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing 10:56:48.170 INFO [NodeOptions.getSessionFactories] - Detected 8 available processors 10:56:48.181 INFO [NodeOptions.discoverDrivers] - Discovered 0 driver(s) 10:56:48.187 WARN [NodeOptions.addDetectedDrivers] - No drivers have been configured or have been found on PATH java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77) at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70) Caused by: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:115) at org.openqa.selenium.grid.node.config.NodeOptions.getNode(NodeOptions.java:131) at org.openqa.selenium.grid.commands.Standalone.createHandlers(Standalone.java:203) at org.openqa.selenium.grid.TemplateGridServerCommand.asServer(TemplateGridServerCommand.java:41) at org.openqa.selenium.grid.commands.Standalone.execute(Standalone.java:214) at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$4(TemplateGridCommand.java:129) at org.openqa.selenium.grid.Main.launch(Main.java:83) at org.openqa.selenium.grid.Main.go(Main.java:57) at org.openqa.selenium.grid.Main.main(Main.java:42) ... 6 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.openqa.selenium.grid.config.ClassCreation.callCreateMethod(ClassCreation.java:50) at org.openqa.selenium.grid.config.MemoizedConfig.lambda$getClass$4(MemoizedConfig.java:100) at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737) at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:95) ... 14 more Caused by: org.openqa.selenium.grid.config.ConfigException: No drivers have been configured or have been found on PATH at org.openqa.selenium.grid.node.config.NodeOptions.addDetectedDrivers(NodeOptions.java:403) at org.openqa.selenium.grid.node.config.NodeOptions.getSessionFactories(NodeOptions.java:192) at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:76) ... 22 more It seems if no driver is specified then it will try searching for drivers on the system. My guess is if there are some in someones PATH then it will boot fine. But on my system there are none in any PATH so it fails with this error. Since this library is specifying explicit paths to all drivers it seems the detection is not necessary. By disabling it we prevent the error from occuring on systems like mine. * Update lib/start.js * Update lib/start.js * Update lib/start.js * Update lib/start.js * Update lib/start.js * Update lib/start.js Co-authored-by: Christian Bromann <git@bromann.dev>
1 parent a88a903 commit 9922fd6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/start.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ async function start(_opts) {
2727
opts.seleniumArgs = [];
2828
}
2929

30+
if (!opts.spawnOptions) {
31+
opts.spawnOptions = {};
32+
}
33+
3034
if (!opts.version) {
3135
opts.version = defaultConfig.version;
3236
}
@@ -38,6 +42,8 @@ async function start(_opts) {
3842
!hasParam(opts.seleniumArgs, 'standalone') &&
3943
!hasParam(opts.seleniumArgs, 'distributor')
4044
) {
45+
opts.seleniumArgs.unshift('false');
46+
opts.seleniumArgs.unshift('--detect-drivers');
4147
opts.seleniumArgs.unshift('standalone');
4248
}
4349

@@ -117,6 +123,10 @@ async function start(_opts) {
117123
throw new Error(`Port ${seleniumStatusUrl.port} is already in use.`);
118124
}
119125

126+
if (!opts.spawnOptions.stdio) {
127+
opts.spawnOptions.stdio = 'ignore';
128+
}
129+
120130
debug('Spawning Selenium Server process', opts.javaPath, args);
121131
const selenium = spawn(opts.javaPath, args, opts.spawnOptions);
122132
await checkStarted(selenium, seleniumStatusUrl.toString());

0 commit comments

Comments
 (0)