saba
saba

Reputation: 539

How to change Firefox WebDriver Port

It is just a curiosity that how can I run firefox driver on different port like IE and Chrome driver.This driver have option like

ChromeDriverService service=new ChromeDriverService.Builder().usingPort(7000).
                                            usingDriverExecutable(new File("")).build();

though the firefox driver have the option like that

System.setProperty("webdriver.firefox.port","7046");

or

DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability("webdriver_firefox_port",7046);

but it can not run firefox driver on this port I am using 2.41 Selenium Webdriver and firefox 31

Can anyone explain why and how can I run firefox driver in specified port.

Upvotes: 3

Views: 10315

Answers (1)

Andrey Egorov
Andrey Egorov

Reputation: 1269

Well, not sure, but this should work

ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("WebDriver");
profile.setPreference(FirefoxProfile.PORT_PREFERENCE, 7046)
WebDriver driver = new FirefoxDriver(profile);

Upvotes: 2

Related Questions