Selenium using too much RAM with Firefox

前端 未结 5 1109
刺人心
刺人心 2020-11-30 11:51

I am using selenium with Firefox to automate some tasks on Instagram. It basically goes back and forth between user profiles and notifications page and does tasks based on w

5条回答
  •  粉色の甜心
    2020-11-30 12:35

    Creating new firefox profile and use it every time while running test cases in Firefox shall eventually increase the performance of execution as without doing so always new profile would be created and caching information would be done there and if driver.quit does not get called somehow before failure then in this case, every time we end up having new profiles created with some cached information which would be consuming memory.

    // ------------ Creating a new firefox profile -------------------

    1. If Firefox is open, close Firefox.
    2. Press Windows +R on the keyboard. A Run dialog will open.
    3. In the Run dialog box, type in firefox.exe -P
    Note: You can use -P or -ProfileManager(either one should work).
    4. Click OK.
    5. Create a new profile and sets its location to the RAM Drive.
    

    // ----------- Associating Firefox profile -------------------

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile myprofile = profile.getProfile("automation_profile");
    WebDriver driver = new FirefoxDriver(myprofile);
    

    Please share execution performance with community if you plan to implement this way.

提交回复
热议问题