SeleniumHQ/selenium-google-code-issue-archive

Selenium webdriver.firefox.port assigned port not working

Mahbubur-Rahman opened this issue · 0 comments

I have inherited the firefoxDriver class to assign port manually.

public class CustomFFDriver extends FirefoxDriver{
	
	private FirefoxProfile fp = new FirefoxProfile();
	private static final Logger logger = LoggerFactory.getLogger(CustomFFDriver.class);
			
	public CustomFFDriver(FirefoxProfile fp){
		super(fp);
		this.fp = fp;
	}
	
	@Override
	protected Lock obtainLock(FirefoxProfile profile) {
//		return new SocketLock(47002);
		return new SocketLock(new InetSocketAddress("localhost", 47002));
	}
	
	@Override
	protected ExtensionConnection connectTo(FirefoxBinary binary, FirefoxProfile profile, String host) {
	    Lock lock = obtainLock(profile);
	    System.out.println(((SocketLock) lock).getLockPort());
	    logger.info(String.valueOf(((SocketLock) lock).getLockPort()));
	    try {
	      FirefoxBinary bin = binary == null ? new FirefoxBinary() : binary;
	      return new NewProfileExtensionConnection(lock, bin, profile, host);
	    } catch (Exception e) {
	      throw new WebDriverException(e);
	    }
	}
	
}

When I execute it in Jenkins CI server, and from terminal check with netstat, output like below appears which seems port assignment is not working:

[root@ops2 ~]# netstat -atp | grep firefox
tcp        0      0 localhost:7055              *:*                         LISTEN      29960/firefox

If the netstat command I am using is wrong, than how I can check it?
Is port assignment not working or I am doing something wrong?