воскресенье, 21 июля 2013 г.

How to use custom Firefox profile

By default FirefoxProfile (here and below it's about Java binding) allows to set preferences and extensions.

What if you need to setup another file from profile folder, e.g. cert8.db ?

Code below is for remote case. For local case code will be similar.

You could use something like:
----------------------------------------------------
File profileDir = new File("<path-do-folder-with-profile>")
FirefoxProfile profile = new FirefoxProfile(profileDir);
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
webdriver = new RemoteWebDriver(capabilites);
----------------------------------------------------

or (if you have named Firefox profile) :

----------------------------------------------------
FirefoxProfile profile = new ProfilesIni().getProfile("<name-of-profile>");
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(FirefoxDriver.PROFILE, profile);
webdriver = new RemoteWebDriver(capabilites);
----------------------------------------------------

In both cases content of profile folder will be zipped and sent to grid, then to node, unzipped to tmp folder and used as profile of started firefox.

It could consume too much resources. You al so could use another way:
1. do not pass any profile data in capabilities
2. run node as: java -Dwebdriver.firefox.profile=<name-of-profile> ...

In this case a folder of named Firefox profile <name-of-profile> at node
will be copied to tmp folder, updated and used as profile of started firefox.

Комментариев нет:

Отправить комментарий