Setup Selenium Grid 2.0 on multiple machines

596 views
Skip to first unread message

dan_null

unread,
Jul 28, 2011, 5:08:04 PM7/28/11
to Selenium Users
Hi,
I am having trouble getting a simple setup with Selenium Grid 2.0. I
want to set up two machines (The first running the hub and a webdriver
node and the second machine running one or two nodes). I have not
problem creating a hub (on localhost with unique port) and multiple
nodes on the same machine. I am using the standalone server 2.1.0 and
only using webdriver API/test cases with Windows XP. The problem I am
having is being able to give the hub a host that is NOT localhost (the
machine has a static IP, not using DHCP) so that the nodes can
successfully register to that hub. It seems to be a networking issue
or lacking of understanding on my part.

I looked through the most recent message in group and only found one
post similar to mine:
http://groups.google.com/group/selenium-users/browse_thread/thread/8f1e9bbff33267cf/0224d6a29867aee4?lnk=gst&q=grid+2#
,however, it does not help.

Basically, for running JUnit tests using grid 2.0 on the same machine,
I use the following:

To get the hub going, I run: java -jar selenium-server-
standalone-2.1.0.jar -role hub -port 5555

To get the nodes going, I run: java -jar selenium-server-
standalone-2.1.0.jar -role webdriver -port 2222 -hub http://localhost:5555
browser browserName=firefox,version=5,maxInstances=3 (browser info not
that important)

In my test case, I have the following code:
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setBrowserName("firefox");
capability.setVersion("5.0");
driver = new RemoteWebDriver(new URL("localhost:5555/wd/hub"),
capability);

I added the directory were my standalone 2.1.0 server JAR is located
in the PATH environment variable. Basically, I know want to set up my
Grid so that the first machine will run the hub with a static IP as
the host with a port of say 4444.

I made the following change my nodes to reference the hub correctly,
by running: java -jar selenium-server-standalone-2.1.0.jar -role
webdriver -port 2222 -hub http://STATIC_IP_HOST:5555 browser
browserName=firefox,version=5,maxInstances=3

I changed my tests to so that the remote webdriver is also referencing
the hub correctly: driver = new RemoteWebDriver(new
URL("STATIC_IP_HOST:5555/wd/hub"), capability);

Can anyone help me so that the hub does not run on localhost? My
networking knowledge isn't very strong so if I am lacking or
misunderstanding key networking concepts that would help out, please
enlighten me! Thanks for the help in advance!

Krishnan Mahadevan

unread,
Jul 29, 2011, 9:25:18 AM7/29/11
to seleniu...@googlegroups.com
I have a doubt on the following line
driver = new RemoteWebDriver(new URL("STATIC_IP_HOST:5555/wd/hub"), capability);

I am assuming that the new URL that you are providing is of the form :
url = new URL("http://" + hostToRun + ":" + port + "/wd/hub");

For starting the hub and the remoteWebDriver you would be using the following I believe

java -jar selenium-server-standalone-2.1.0.jar -role hub -hubhost STATIC_IP_ADDRESS -port 4444
java -jar selenium-server-standalone-2.1.0.jar -role webdriver -hub http://STATIC_IP_ADDRESS:4444/grid/register -port 5556

Note:
The following would still work (I have been using this for a few days now and never had problems)

MachineA (Here's where we will run our hub and webdriver node)
java -jar selenium-server-standalone-2.1.0.jar -role hub (Starts the hub on the localhost)
java -jar selenium-server-standalone-2.1.0.jar -role webdriver -hub http://localhost:4444/grid/register -port 5556

Now imagine MachineB is where your development is (This is your local machine from where you are writing code)

You would instantiate the RemoteWebDriver as below

WebDriver d = new RemoteWebDriver(new URL("http://" + MachineA_Name + ":4444/wd/hub"), DesiredCapabilities.firefox())

Hope that helps

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"




--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


dan_null

unread,
Jul 29, 2011, 12:38:17 PM7/29/11
to Selenium Users
Hey Krishnan,

I got it to work now! Basically, I had the set up you described
correct where you have a hub and a node on the same machine, then run
the java program on a different machine referencing a hub which would
cause the test to run on the machine with the hub and node. My problem
was that my second machine had three ethernet adapters (VMware Network
Adapter VMnet8, VMware Network Adapter VMnet1, and LAN). When I did
not specify the "host" option when I start up the node it would select
a host IP address (not sure if it was DHCP IP) for me which did not
work correctly in the network that I am in (I basically need LAN). so
I added a "-host LAN_IP_ADDRESS" when I launched node and it works!
Thanks for your help, I was able to figure it out because of the JSON
information the when you start up a node or hub, which was brought to
my attention by you mentioning 'hubHost'. I was wondered where you
learned of that option and figured something must be different with
our networks because basically had the exactly same set ups (and that
the local node was working fine). I then eventually noticed all
options in the JSON information when you start up a node/hub when I
was doing some more trail and error.

Thanks again!

-Daniel Barajas

On Jul 29, 6:25 am, Krishnan Mahadevan
<krishnan.mahadevan1...@gmail.com> wrote:
> I have a doubt on the following line
> *driver = new RemoteWebDriver(new URL("STATIC_IP_HOST:5555/wd/hub"),
> capability);*
>
> I am assuming that the new URL that you are providing is of the form :
> url = new URL("http://" + hostToRun + ":" + port + "/wd/hub");
>
> For starting the hub and the remoteWebDriver you would be using the
> following I believe
>
> java -jar selenium-server-standalone-2.1.0.jar -role hub -hubhost
> STATIC_IP_ADDRESS -port 4444
> java -jar selenium-server-standalone-2.1.0.jar -role webdriver -hubhttp://STATIC_IP_ADDRESS:4444/grid/register-port 5556
>
> Note:
> The following would still work (I have been using this for a few days now
> and never had problems)
>
> MachineA (Here's where we will run our hub and webdriver node)
> java -jar selenium-server-standalone-2.1.0.jar -role hub (Starts the hub on
> the localhost)
> java -jar selenium-server-standalone-2.1.0.jar -role webdriver -hubhttp://localhost:4444/grid/register-port 5556
>
> Now imagine MachineB is where your development is (This is your local
> machine from where you are writing code)
>
> You would instantiate the RemoteWebDriver as below
>
> WebDriver d = new RemoteWebDriver(new URL("http://" + MachineA_Name +
> ":4444/wd/hub"), DesiredCapabilities.firefox())
>
> Hope that helps
>
> Thanks & Regards
> Krishnan Mahadevan
>
> "All the desirable things in life are either illegal, expensive, fattening
> or in love with someone else!"
>
>
>
>
>
>
>
> On Fri, Jul 29, 2011 at 2:38 AM, dan_null <i.am.bara...@gmail.com> wrote:
> > Hi,
> > I am having trouble getting a simple setup with Selenium Grid 2.0. I
> > want to set up two machines (The first running the hub and a webdriver
> > node and the second machine running one or two nodes). I have not
> > problem creating a hub (on localhost with unique port) and multiple
> > nodes on the same machine. I am using the standalone server 2.1.0 and
> > only using webdriver API/test cases with Windows XP. The problem I am
> > having is being able to give the hub a host that is NOT localhost (the
> > machine has a static IP, not using DHCP) so that the nodes can
> > successfully register to that hub. It seems to be a networking issue
> > or lacking of understanding on my part.
>
> > I looked through the most recent message in group and only found one
> > post similar to mine:
>
> >http://groups.google.com/group/selenium-users/browse_thread/thread/8f...
> > ,however<http://groups.google.com/group/selenium-users/browse_thread/thread/8f...>,
> > it does not help.
>
> > Basically, for running JUnit tests using grid 2.0 on the same machine,
> > I use the following:
>
> > To get the hub going, I run:  java -jar selenium-server-
> > standalone-2.1.0.jar -role hub -port 5555
>
> > To get the nodes going, I run:  java -jar selenium-server-
> > standalone-2.1.0.jar -role webdriver -port 2222 -hubhttp://localhost:5555
Reply all
Reply to author
Forward
0 new messages