rdo
rdo

Reputation: 101

Save firefox profile generated by Selenuim Web Driver

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?

Upvotes: 5

Views: 6720

Answers (1)

Pavel Janicek
Pavel Janicek

Reputation: 14738

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...

Upvotes: 3

Related Questions