Reputation: 15092
Like many, we start selenium server via the following command:
java -jar selenium-server-standalone-2.21.0.jar
What we found is that this opens selenium up on 0.0.0.0:4444
Started SocketListener on 0.0.0.0:4444
[USER @ BOX ~]# netstat -na | grep LISTEN | grep 4444
tcp 0 0 :::4444 :::* LISTEN
Is there any way to bind selenium to a specific ip (localhost)?
Thanks.
Upvotes: 18
Views: 24419
Reputation: 11
I was also facing the same problem with the Hub. So my Hub is pointing toward some other IP address when I tried to UP the hub, but when I check my IP address it was different on my local system. To overcome the problem I just tried the following code and it works.
java -jar selenium-server-standalone-3.12.0.jar -host 192.XXX.X.XX -role hub
And my hub was registered to my local machine IP address.
Upvotes: 1
Reputation: 76
This is not the correct way of handling this problem but its a way
So what this will do is just drop any connection on port 4444 from any outside source. You can test this by first going to page
start server like this
java -jar selenium-server-standalone-2.39.0.jar -host 127.0.0.1 -port 4444
verify everything is working
http://yourexternalip:4444/wd/hub/
the page will load. if your server is running properly.
Dispatch the commands
sudo iptables -A INPUT -p tcp --dport 4444 -s 127.0.0.1 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 4444 -j DROP
then reload the page. the webpage will no longer be accessible (because you are accessing from external IP)
your new accessible URL is now
http://127.0.0.1:4444/wd/hub/
which should be working
Again this is more of a band-aid to a greater problem and doing this will not force you to change any source code and still keeping a secure system
Upvotes: 5
Reputation: 119
This will be possible by adding the "-host 192.168.1.100" parameter, provided you have this fix in your version:
https://code.google.com/p/selenium/source/detail?r=71c5e231f442
(That fix isn't included in the available binaries at the time of writing so you will have to build your own from source.)
Upvotes: 2
Reputation: 339
Use the following command
java -jar selenium-server-standalone-2.21.0.jar -host 192.168.1.100
where 192.168.1.100 is the IP address of the host
Upvotes: 9
Reputation: 8548
You could run java -jar selenium-server-standalone-2.21.0.jar
on a remote machine
and then in your selenium scripts define your webdriver to run remotely.
In ruby you could do it this way
@driver = Selenium::WebDriver.for(:remote, :url => "http://specific_ip_of_remotemachine:4444", :desired_capabilities => firefox)
is this what you are looking for?
Upvotes: 0