question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Selenium Grid 4, How to match a particular pattern capability in ruby 3.x.x

See original GitHub issue

What happened?

I’m unable to match the custom capabilities in ruby code for selenium grid 4 nodes.

As per this documentation: https://www.selenium.dev/documentation/grid/configuration/cli_options/#matching-node-a

I’ve tried to do the same thing in ruby like below:

  1. Started the selenium grid with this command:
java -jar ./selenium-server-4.1.2.jar  hub --session-request-timeout 500 --port 4444 --tracing false

  1. Started Running nodes with the below commands:
node a) java -jar selenium-server-4.1.2.jar node --max-sessions 74 --log-level "fine" --port 5555  --driver-implementation "chrome" --override-max-sessions true --max-threads 55 --driver-configuration display-name="$(hostname)" stereotype='{"browserName":"chrome","custom_key1":"custom_value1"}'

node b) java -jar selenium-server-4.1.2.jar node --max-sessions 74 --log-level "fine" --port 5556  --driver-implementation "chrome" --override-max-sessions true --max-threads 55 --driver-configuration display-name="$(hostname)" stereotype='{"browserName":"chrome","custom_key2":"custom_value2"}'

Then From My Ruby Code, I’ve tried to connect to the node ‘a’ which uses custom_key1 and custom_value1 like below:



options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized'])

caps = {"custom_key1":"custom_value1"}

options.add_option("my_options",caps)

And finally trying to initialize the browser:

driver = Selenium::WebDriver.for(:remote, :url => "http://192.168.29.141:4444", :capabilities => options)

So here Im able to get the driver but its getting randomly from the above nodes. If I pass custom_key1 and custom_value1 then I should get the browser from that node ‘a’ only. But However browser session is getting created in node ‘b’ too. Im getting browser from node ‘b’ even after I pass custom_key1 from my code.

Could someone please help me to match this particular nodes with some pattern

How can we reproduce the issue?

options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized'])

caps = {"custom_key1":"custom_value1"}

options.add_option("my_options",caps)

And finally trying to initialize the browser:

driver = Selenium::WebDriver.for(:remote, :url => "http://192.168.29.141:4444", :capabilities => options)



### Relevant log output

```shell
browser getting initialized whatever the args we pass

Operating System

ubuntu 18.04

Selenium version

selenium 4.1.2

What are the browser(s) and version(s) where you see this issue?

chrome Version 99.0.4844.82 (Official Build) (64-bit)

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 99.0.4844.51

Are you using Selenium Grid?

Selenium Grid 4.1.2 (revision 9a5a329c5a)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
user574commented, Apr 8, 2022

The correct command to create the nodes :

A)
java -jar selenium-server-4.1.2.jar node --detect-drivers false --log-level "fine" --port 5555   --override-max-sessions true --max-threads 55 --driver-configuration display-name="$(hostname)" max-sessions=74 stereotype='{"browserName":"chrome","cluster:pcgeo":"hetzner"}'
B)
java -jar selenium-server-4.1.2.jar node --detect-drivers false --log-level "fine" --port 5556   --override-max-sessions true --max-threads 55 --driver-configuration display-name="$(hostname)" max-sessions=74 stereotype='{"browserName":"chrome","cluster:pcgeo":"aws"}'

Correct code to add ruby options:

opt = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized'])
opt.add_option("cluster:pcgeo","aws_india")
driver = Selenium::WebDriver.for(:remote, :url => "http://192.168.29.141:4444" , :capabilities => opt)

Thanks a lot for your quick response & the best solution 😃

@diemol @titusfortner

0reactions
github-actions[bot]commented, May 9, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selenium Grid 4, How to match a particular pattern capability ...
I've tried to do the same thing in ruby like below: Started the selenium grid with this command: java -jar ./selenium-server-4.1.2.jar hub -- ......
Read more >
Selenium Grid Tutorial: Parallel Testing Guide with Examples
Selenium Grid setup tutorial for parallel execution to perform automated cross browser testing on different browsers i.e. Chrome, IE, ...
Read more >
Grid2 · SeleniumHQ/selenium Wiki - GitHub
A node matches if all the requested capabilities are met. To request specific capabilities on the grid, specify them before passing it into ......
Read more >
Selenium 4 Grid Tutorial with examples - YouTube
In this video, I am going to explain new Selenium Grid feature which has ability to run the tests in remote machines on...
Read more >
Selenium 4.0 Released: New Features, Comparison with ...
The first new feature I want to mention is simplified capability setting. In the older versions of Selenium, you had to set all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found