Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to register selenium webdriver node on VM to the hub on Host

I have a host with IP 192.168.3.146. This IP is a static IP given from DHCP server. Now I have VM with network configured as Bridged.

I am seeing the IP as 10.0.2.15. Since it's bridged should I be getting anything in the range 192.168.3.x assigned to the VM as well?

When I register from this VM to the host I am not able to register the web driver, it just says "Registering" and does nothing until I kill it.

Command used to register the node:

java -jar selenium-server-standalone-2.26.0.jar -role web driver -hub http:/192.168.3.146:4444/grid/register -port 5558 -host 10.0.2.15 -browser "browserName=firefox, version=6, platform=WINDOWS"

Also tried:

java -jar selenium-server-standalone-2.26.0.jar -role node -port 5558 -hub http:/192.168.3.146:4444/grid/register

NOTE: in both commands http:/ is deliberate - please ignore it. I'm actually using // since I was getting error while posting I have used :/

Any suggestions please?

like image 615
user1134114 Avatar asked Nov 12 '22 16:11

user1134114


1 Answers

The easiest way to get this setup is to use NAT Networking, and local port forwarding. What's nice about this setup is that you can run everything offline, and not rely on a constantly changing dynamic IP address. Here's how you do that:

Configure the Guest VM to use NAT Networking, add Port Forwarding rules for ports 4444 and 5555.

Host Machine, as Hub

java -jar selenium-server-standalone.jar -role hub -port 4444

Guest Machine, as Node

java -jar selenium-server-standalone.jar -role node -host 127.0.0.1 -port 5555 -hub http://10.0.2.2:4444/grid/register

I use this setup to run multiple instances of the modern.ie VM machines in VirtualBox, and it works very nicely.

like image 190
Apollo Clark Avatar answered Jan 04 '23 02:01

Apollo Clark