5

I use Selenium WebDriver with firefox. Every time selenium generates new anoniumus profile for firefox in temp folder and after exit, removes it. I need this profile. How can I get it? F.e. profile stored in

C:\Documents and Settings\Developer\Local Settings\Temp\anonymous5583304190515426768webdriver-profile

After shutting down WebDriver with

driver.quit();

profile will be removed, but it is already logged and I want to use it in next iteration, by initing WebDriver with it:

FirefoxDriver driver = new FirefoxDriver(new FirefoxProfile(profileFolder));

Is it possible to save profile without dirty hacks like coping whole folder while driver works (I'm not sure even it works, because in windows, folder is locked while firefox launched)? Maybe exists some API in Selenium for it?

Prasad
  • 472
  • 5
  • 15
rdo
  • 101
  • 1
  • 10

1 Answers1

3

Why dont you just change approach?

  • Create firefox profile which will be clean and name it somehow you know what it is. e.g. SELENIUM
  • When initializing the Webdriver:

     ProfilesIni allProfiles = new ProfilesIni();
     FirefoxProfile desiredProfile = allProfiles.getProfile("SELENIUM");
     WebDriver driver = new FirefoxDriver(desiredProfile);
    

That way, you assure that this profile will be used anytime you do the tests...

Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77
  • 2
    Unfortunatly, selenium copies data from input profile into temporal profile like anonymous5583304190515426768webdriver-profile, so all cookies will be in it(and be deleted after test shutdown). – rdo Oct 24 '12 at 08:56
  • 3
    @rdo you can get back that tmp profile just looking for `profile.path value`. Example with python bindings http://stackoverflow.com/a/33350778/2480481 – m3nda Apr 15 '16 at 00:55