Running a simple test in selenium grid 2 using ruby

802 views Asked by At

I am new to selenium.

I just wanted to use grid2 on a project.

As of now, I have setup a hub a.a.a.a:4444

and I have registerd a node b.b.b.b:5555

I see the following on the grid console

port:5555
host:b.b.b.b
servlets:[]
cleanUpCycle:5000
browserTimeout:0
hubHost:a.a.a.a
registerCycle:5000
hub:http://a.a.a.a:4444/grid/register
newSessionWaitTimeout:-1
capabilityMatcher:org.openqa.grid.internal.utils.DefaultCapabilityMatcher
url:http://b.b.b.b:5555
remoteHost:http://b.b.b.b:5555
prioritizer:null
register:true
throwOnCapabilityNotPresent:true
nodePolling:5000
proxy:org.openqa.grid.selenium.proxy.DefaultRemoteProxy
maxSession:5
role:node
hubPort:4444
timeout:300000

I would like to do a simple test , that is go to the node and see if a url opens for example www.url.com/mysoftware. If it opens then print "opens" else "fails". I use Ruby generally but I am not able to find a good place to start for this.

Thanks

1

There are 1 answers

0
ddavison On

All you need to do, is have your test launch against the grid. The grid will delegate your tests to the most available node.

It would look something like this (please keep in mind the below is pseudo-code):

def my_test
  hub = "http://a.a.a.a/"
  driver = WebDriver::Remote.new(hub)

  driver.get("http://google.com/")
  puts "works!" if driver.get_title.eq? 'Google'
end

So the thing to keep in mind is that YOU don't launch tests against individual nodes. The Grid will delegate those tests. WHere I work, we have thousands of tests running at a time, and we fire all of our tests at the grid. The grid will then find which one is best suited for the job. There is, of course, an algorithm that decides this. But the main thing to keep in mind is:

Fire your tests at the grid. Not the nodes.