我想在selenium集线器中实现一种默认队列。 有可能指定节点的名称(实际上是它的环境,比如“ubuntu上的firefox”或“windows上的chrome”)。硒网格本身有一个默认队列,它按照“先进先出”的原则工作。但我想优先考虑一些给硒服务器的任务。我没有可能引入自定义队列(好像没有API),这就是为什么我决定将队列的逻辑与硒服务器分开的原因。我只会调用具有特定名称(环境)的特定节点,例如“firefox important node”或者像这样的。命名硒网格节点。产生一个特定的节点
所以,我想知道如何直接告诉硒哪个节点用于我的任务? 一般而言,我是否以正确的方式思考?
这里是我的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] %>
}
}
而且我Driver类:
...
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
...
我仍不很不知道如何为我的任务使用指定的节点。 如果我尝试启动驱动程序加入:name => "firefox important node"
与
environments:
- name: "firefox important node"
browser: "*firefox"
- name: "Firefox36 on Linux"
browser: "*firefox"
硒延长nodeConfig.json.erb的配置只是开始随机节点上随机firefox浏览器。我如何控制它?
Java代码是相当混乱,我试图用Ruby编写类似的代码,但我并没有取得预期的结果。我们决定使用两个独立的硒中枢,一个用于优先队列,另一个用于常规。 –
这更多的是一个架构问题 - 扩展与外部代码。通过编写一个扩展,你可以重复使用相同的节点来实现你的目标 - 看起来好得多(尽管是的 - 你必须在java中弄乱) – Kenn