selenium RC- change default port 4444 port .if the port is busy at runtime
How to handle the scenario while running SELENIUM RC.If we get the default port 4444 is开发者_开发知识库 busy.
You first need to check whether port 4444 is busy. If it is busy then set your RC to use a different port.
static int port=4444;
try {
ServerSocket serverSocket = new ServerSocket(port);
//Checking whether 4444 is closed or not
if(!serverSocket.isClosed())
port=5555;//Or whatever port you like
//Now start selenium server
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setPort(port);
SeleniumServer server = new SeleniumServer(false, rcc);
server.start(); }
catch(Exception e){
e.printStackTrace(); }
精彩评论