Naming selenium grid nodes. Spawning a specific node
Posted
by
???? ????
on Stack Overflow
See other posts from Stack Overflow
or by ???? ????
Published on 2013-06-18T13:25:38Z
Indexed on
2013/06/26
10:21 UTC
Read the original article
Hit count: 293
I'm trying to implement a kind of default queues in selenium hub. There is a possibility to specify node's name (actually its environment, smth like "firefox on ubuntu" or "chrome on windows"). Selenium grid itself has a default queue, it works according to 'First In, First Out' principle. But I want to prioritize some of my tasks given to selenium server. I have no possibility to introduce custom queue (seems like there is no API for that), that's why I decided to separate queue's logic from selenium server. I'll only call a specific node with specific name (environment) for example "firefox important node" or smth like that.
So, I want to know how to directly tell selenium which node to use for my task? And generally, am I thinking in a right way?
Here are my configs: hubConfig.json.erb
{
"host": null,
"port": <%= node[:selenium][:server][:port] %>,
"newSessionWaitTimeout": -1,
"servlets" : [],
"prioritizer": null,
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"nodePolling": <%= node[:selenium][:server][:node_polling] %>,
"cleanUpCycle": <%= node[:selenium][:server][:cleanup_cycle] %>,
"timeout": <%= node[:selenium][:server][:timeout] %>,
"browserTimeout": 0,
"maxSession": <%= node[:selenium][:server][:max_session] %>
}
nodeConfig.json.erb
{
"capabilities": [
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}, {
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}, {
"browserName": "phantomjs",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
}
],
"configuration": {
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": <%= node[:selenium][:node][:max_session] %>,
"port": <%= node[:selenium][:node][:port] %>,
"host": "<%= node[:fqdn] %>",
"register": true,
"registerCycle": <%= node[:selenium][:node][:register_cycle] %>,
"hubPort": <%= node[:selenium][:server][:port] %>
}
}
And my Driver class:
...
def remote_driver
@browser = Watir::Browser.new(:remote,
:url => "http://myhub.com:4444/wd/hub",
:http_client => client,
:desired_capabilities => capabilities
)
end
def capabilities
Selenium::WebDriver::Remote::Capabilities.send(
"firefox",
:javascript_enabled => true,
:css_selectors_enabled => true,
:takes_screenshot => true
)
end
def client
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 360
client
end
...
I still don't know how to use specified node for my task.
If I try to start a driver adding :name => "firefox important node"
and extend nodeConfig.json.erb's configuration with
environments:
- name: "firefox important node"
browser: "*firefox"
- name: "Firefox36 on Linux"
browser: "*firefox"
selenium just starts random firefox browser on a random node. How can I control it?
© Stack Overflow or respective owner