Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to speed up the Selenium Server load time?

Tags:

java

selenium

By design, Selenium makes a new copy of your Firefox profile each time a new test is run. I find this copy time is a considerable bottleneck, especially when running 100s of tests. (5-15 seconds to copy the profile anew).

Does anyone know of any override behavior for this? I'd prefer my Selenium server to just reuse the same firefox profile. I know this violates the "cleanly set up your test fixtures" philosophy, but it's a shortcut I'm willing to take, as my tests don't materially alter my firefox profile enough to jeopardize future tests.

like image 603
Aaron Fi Avatar asked Apr 03 '09 16:04

Aaron Fi


3 Answers

I agree this is a problem. It's nice to have a new copy of a Firefox process each time, but a bit overkill to double the startup time by regenerating the Firefox profile. If you open a bug report on http://jira.openqa.org and email me at [email protected] I'll be happy to make sure we get a solution in place.

PS: I've solved this problem as a one-off for myself. We use the same Firefox profile and just nuke out the cache and cookies DB. But I really should just patch that change back to the Selenium source.

like image 154
Patrick Lightbody Avatar answered Nov 10 '22 09:11

Patrick Lightbody


It's simply a matter of moving the code below outside of your test setup and into the fixture setup and keeping a global of the selenium instance (code assumes NUnit.)

[TestFixtureSetUp()]
public void FixtureSetup()
{
    selenium = New DefaultSelenium("localhost", 4444, "*firefox", "http://localhost/");
    selenium.Start();
    selenium.SetTimeout("30000");
    selenium.Open("/");
}

Your test setup should then look something like this:

[SetUp()]
public void SetUpTest()
{
    selenium.Open("default.aspx");
    selenium.WaitForPageToLoad("30000");
}
like image 40
Gavin Miller Avatar answered Nov 10 '22 09:11

Gavin Miller


One small way to reduce the time to load on the profile is to remove the larger files out of the firefox profile. In order to do so, set up your own profile by running the command firefox.exe -p. Once the profile is made, go into the options and turn off caching and other fluff that is not needed for the web tests. Then copy your profile to a new location and remove the sql files that are not needed. (otherwise when you open it up again, you restore the deleted files that keep the profile very small). When you start the selenium test, reference your profile in its new location. Previous to this, I was copying over a 50MB profile at each test start-up, and now it copies over a 3-4MB profile, and the startup time is almost instant.

Again, this isnt a way to use the same profile again, but it will decrease your copy time of each profile.

like image 1
Ben Avatar answered Nov 10 '22 09:11

Ben