如何在运行SELENIUM RC时处理该场景。如果我们得到默认端口4444正忙。
答案 0 :(得分:2)
首先需要检查端口4444是否正忙。如果它正忙,则将RC设置为使用其他端口。
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(); }