2
如何在运行SELENIUM RC时处理场景。如果我们得到默认端口4444正忙。selenium RC-更改默认端口4444端口如果端口在运行时处于忙状态
如何在运行SELENIUM RC时处理场景。如果我们得到默认端口4444正忙。selenium RC-更改默认端口4444端口如果端口在运行时处于忙状态
您首先需要检查端口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(); }