2

I know with selenium RC, I used to pass a commandline operator... -firefoxProfileTemplate and that would work. Now working with Selenium2 (Webdriver), that doesn't seem to work anymore.

Since I'm using PHPUnit for other tests, I would like to continue to use it. Anyone know how to define a custom firefox profile for it?

General Redneck
  • 1,240
  • 2
  • 13
  • 28
  • Does this answer help? http://stackoverflow.com/a/7549723/841830 (If it does you could close your question; if it does not, can you expand your question, please) – Darren Cook Feb 11 '13 at 00:39
  • That is actually written for the [Facebook Webdriver framework](https://github.com/facebook/php-webdriver). I guess I could switch to using that, but phpunit does have a built in [selenium 2 framework](https://github.com/sebastianbergmann/phpunit-selenium/tree/master/PHPUnit/Extensions). Thanks for the suggestion. I may be able to piece together an answer by searching through the code and using that code example for help. – General Redneck Feb 13 '13 at 23:28

2 Answers2

1

This does not explicitly answer the question above, however, it did help solve the immediate problem as my setup for selenium would only ever use 1 Firefox instance and not try to load them on the fly.

With that said, this would help the majority of users out there, thus the reason I'm putting it as an "Answer" here, but not selecting it as the correct one.

I found the answer here at phpunit-selenium issue queue on github. Thanks emaks.

Simply load your selenium server with the command line option

-Dwebdriver.firefox.profile=PROFILE_NAME

Note: PROFILE_NAME is the machine name located in your profiles.ini in the Firefox Application Data directory. It is not a path or what not.

General Redneck
  • 1,240
  • 2
  • 13
  • 28
0

Lets say you use php-webdriver with FirefoxDriver. And you want to start FirefoxDriver with specific Firefox profile. (for staying logged in and save your login and cookies every selenium run)

First of all, find directory with you firefox profile data. For me on Win 10 it is C:/Users/MyWinProfile/AppData/Roaming/Mozilla/Firefox/Profiles/pivdau5sa.selen

After that use such code for opening firefox php-webdriver:

namespace Facebook\WebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Firefox\FirefoxDriver;
use Facebook\WebDriver\Firefox\FirefoxOptions;
require_once('vendor/autoload.php');

$firefoxOptions = new FirefoxOptions();
$firefoxOptions->addArguments(['-profile', 'C:/Users/<MyUserName>/AppData/Roaming/Mozilla/Firefox/Profiles/pivdau5sa.selen']);
$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability(FirefoxOptions::CAPABILITY, $firefoxOptions);
putenv('WEBDRIVER_FIREFOX_DRIVER=C:\PHP\geckodriver.exe'); // you may dont need this line

$driver = FirefoxDriver::start($capabilities);
Denis Borisov
  • 166
  • 1
  • 3