Vel Ganesh
Vel Ganesh

Reputation: 553

Check if Selenium Hub/Node are running on a given port

I want to check whether Selenium Hub or Node is running on a particular port (ex:- 5555). I already have the code to check whether a particular port is free or not. But I am not sure how to find out the application using the port.

if (Port is free)
    i=1
else if (Port is used as Selenium Hub)
    i=2
else if (Port is used as Selenium Node)
    i=3
else if (Port is used by apps other than Selenium)
    i=4
else
    i=5

Please let me know if this can be done using java.

Upvotes: 0

Views: 4549

Answers (1)

ghm1014
ghm1014

Reputation: 695

You could try to access a know http url to the node/server, if it responds with a non error (lets sey an 200 OK) you can assume it's a selenium running there, for example do a httpclient get to:

http://<host>:<port>/wd/hub/static/resource/hub.html

If it does a 404 it's not selenium.

Upvotes: 4

Related Questions