0

What is the point of the method FirefoxBinary#startProfile?

How would one control a browser opened using the above method?

FirefoxBinary binary = new FirefoxBinary(new File("path\\to\\binary.exe"));
String profilePath = "path\\to\\profile";
FirefoxProfile profile = new FirefoxProfile(new File(profilePath));
binary.startProfile(profile, profilePath, "");
//A browser opens at this point, but how do I send it commands or attach 
//it to a WebDriver?
Joel Christophel
  • 2,604
  • 4
  • 30
  • 49

1 Answers1

2

The purpose of the method is to do exactly what it does: start an instance of Firefox using the specified profile. WebDriver makes a copy of the profile in the temp directory and adds the WebDriver Firefox extension into this copy of the profile. Th startProfile method launches Firefox, making sure to clean up the profile so that it's usable by the new instance. If you know what port the browser extension that gets added to the profile is listening on, you could connect to it and control the browser using the WebDriver JSON wire protocol commands.

However, unless you really know what you're doing, this is the complicated way to do it. You're far better off calling the FirefoxDriver constructor, passing in the FirefoxBinary object, and letting the internals of the constructor call the startProfile method for you.

JimEvans
  • 27,201
  • 7
  • 83
  • 108
  • The reason I ask is because using the FirefoxDriver constructor is failing to start the browser correctly while startProfile() works well. If you wish to help me further, I have a bounty on my main question involving this issue: http://stackoverflow.com/questions/22978074/using-selenium-webdriver-with-tor-browser-bundle – Joel Christophel Apr 19 '14 at 15:46