@@ -42,6 +42,8 @@ public class LocalSeleniumGrid extends SeleniumGrid {
4242 private static final String OPT_HOST = "--host" ;
4343 private static final String OPT_PORT = "--port" ;
4444 private static final String OPT_CONFIG = "--config" ;
45+ private static final String OPT_PUB_EVENTS = "--publish-events" ;
46+ private static final String OPT_SUB_EVENTS = "--subscribe-events" ;
4547
4648 /**
4749 * Constructor for models of local Selenium Grid instances from hub URL.
@@ -139,6 +141,8 @@ public static SeleniumGrid create(SeleniumConfig config, final URL hubUrl) throw
139141 Objects .requireNonNull (config , "[config] must be non-null" );
140142
141143 String launcherClassName = config .getString (SeleniumSettings .GRID_LAUNCHER .key ());
144+ String publishUrl = config .getPublishUrl ();
145+ String subscribeUrl = config .getSubscribeUrl ();
142146 String [] dependencyContexts = config .getDependencyContexts ();
143147 String workingDir = config .getString (SeleniumSettings .GRID_WORKING_DIR .key ());
144148 Path workingPath = (workingDir == null || workingDir .isEmpty ()) ? null : Paths .get (workingDir );
@@ -157,8 +161,8 @@ public static SeleniumGrid create(SeleniumConfig config, final URL hubUrl) throw
157161 Integer hubPort = (hubUrl != null ) ?
158162 hubUrl .getPort () : config .getInteger (SeleniumSettings .HUB_PORT .key (), -1 );
159163 Path outputPath = GridUtility .getOutputPath (config , true );
160- hubServer = create (config , launcherClassName , dependencyContexts ,
161- true , hubPort , hubConfigPath , workingPath , outputPath );
164+ hubServer = create (config , launcherClassName , dependencyContexts , true , hubPort ,
165+ publishUrl , subscribeUrl , hubConfigPath , workingPath , outputPath );
162166 }
163167
164168 // store hub host and hub port in system properties for subsequent retrieval
@@ -178,10 +182,10 @@ public static SeleniumGrid create(SeleniumConfig config, final URL hubUrl) throw
178182 nodeServers .add (nodeServer );
179183 // if this is an Appium Grid server
180184 if (nodeServer instanceof AppiumGridServer ) {
181- // get path to relay configuration path from Appium process environment
185+ // get path to relay configuration from Appium process environment
182186 Path nodeConfigPath = ((AppiumGridServer ) nodeServer ).getNodeConfigPath ();
183187 // add relay node for Appium Grid server to nodes list
184- nodeServers .add (create (config , launcherClassName , dependencyContexts , false , -1 , nodeConfigPath ,
188+ nodeServers .add (createNode (config , launcherClassName , dependencyContexts , -1 , nodeConfigPath ,
185189 workingPath , GridUtility .getOutputPath (config , null )));
186190 LOGGER .debug ("Adding local Grid relay for Appium server providing personalities: {}" ,
187191 nodeServer .getPersonalities ().keySet ());
@@ -218,6 +222,35 @@ public static SeleniumGrid create(SeleniumConfig config, final URL hubUrl) throw
218222 }
219223 }
220224
225+ /**
226+ * Create an object that represents a Selenium Grid server with the specified arguments.
227+ * <p>
228+ * <b>NOTE</b>: The created object defines a separate process for managing the local server, but does <b>NOT</b>
229+ * start this process.
230+ *
231+ * @param config {@link SeleniumConfig} object
232+ * @param launcherClassName fully-qualified name of {@code GridLauncher} class
233+ * @param dependencyContexts fully-qualified names of context classes for Selenium Grid dependencies
234+ * @param port port that Grid server should use; -1 to specify auto-configuration
235+ * @param configPath {@link Path} to server configuration file
236+ * @param workingPath {@link Path} of working directory for server process; {@code null} for default
237+ * @param outputPath {@link Path} to output log file; {@code null} to decline log-to-file
238+ * @param propertyNames optional array of property names to propagate to server process
239+ * @return {@link LocalGridServer} object for managing the server process
240+ * @throws GridServerLaunchFailedException if a Grid component process failed to start
241+ * @see #activate()
242+ * @see LocalGridServer#start()
243+ * @see <a href="http://www.seleniumhq.org/docs/07_selenium_grid.jsp#getting-command-line-help">
244+ * Getting Command-Line Help</a>
245+ */
246+ public static LocalGridServer createNode (final SeleniumConfig config , final String launcherClassName ,
247+ final String [] dependencyContexts , final Integer port , final Path configPath ,
248+ final Path workingPath , final Path outputPath , final String ... propertyNames ) {
249+
250+ return create (config , launcherClassName , dependencyContexts , false , port ,
251+ null , null , configPath , workingPath , outputPath , propertyNames );
252+ }
253+
221254 /**
222255 * Create an object that represents a Selenium Grid server with the specified arguments.
223256 * <p>
@@ -229,19 +262,22 @@ public static SeleniumGrid create(SeleniumConfig config, final URL hubUrl) throw
229262 * @param dependencyContexts fully-qualified names of context classes for Selenium Grid dependencies
230263 * @param isHub role of Grid server being started ({@code true} = hub; {@code false} = node)
231264 * @param port port that Grid server should use; -1 to specify auto-configuration
265+ * @param publishUrl URL for publishing Grid events
266+ * @param subscribeUrl URL for subscribing to Grid events
232267 * @param configPath {@link Path} to server configuration file
233268 * @param workingPath {@link Path} of working directory for server process; {@code null} for default
234269 * @param outputPath {@link Path} to output log file; {@code null} to decline log-to-file
235270 * @param propertyNames optional array of property names to propagate to server process
236271 * @return {@link LocalGridServer} object for managing the server process
237- * @throws GridServerLaunchFailedException If a Grid component process failed to start
272+ * @throws GridServerLaunchFailedException if a Grid component process failed to start
238273 * @see #activate()
239274 * @see LocalGridServer#start()
240275 * @see <a href="http://www.seleniumhq.org/docs/07_selenium_grid.jsp#getting-command-line-help">
241276 * Getting Command-Line Help</a>
242277 */
243278 public static LocalGridServer create (final SeleniumConfig config , final String launcherClassName ,
244- final String [] dependencyContexts , final boolean isHub , final Integer port , final Path configPath ,
279+ final String [] dependencyContexts , final boolean isHub , final Integer port ,
280+ final String publishUrl , final String subscribeUrl , final Path configPath ,
245281 final Path workingPath , final Path outputPath , final String ... propertyNames ) {
246282
247283 List <String > argsList = new ArrayList <>();
@@ -272,6 +308,16 @@ public static LocalGridServer create(final SeleniumConfig config, final String l
272308 argsList .add (OPT_PORT );
273309 argsList .add (portNum .toString ());
274310
311+ if (publishUrl != null ) {
312+ argsList .add (OPT_PUB_EVENTS );
313+ argsList .add (publishUrl );
314+ }
315+
316+ if (subscribeUrl != null ) {
317+ argsList .add (OPT_SUB_EVENTS );
318+ argsList .add (subscribeUrl );
319+ }
320+
275321 // specify server configuration file
276322 argsList .add (OPT_CONFIG );
277323 argsList .add (configPath .toString ());
0 commit comments