Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Selenium RC so slow?

For some time I have been investigating Selenium RC in order to do functional testing of my web application. I have now found a test strategy that is so effective, that I do not want to move away from Selenium RC (after spending weeks trying to figure out a good way to validate ASP.NET validation controls).

But now that my Selenium RC adventure is moving from a POC to be something that I actually use, I'm running into a problem. It is insanely slow. Executing a single test that loads a page, fills in some fields, and clicks a button takes in the magnitude of seconds to execute. When it is executing, I can easily see each individual field being filled out one at a time. Using Selenium IDE in Firefox is not that slow.

I found this page, that clearly specifies that Selenium RC is slow http://selenium-grid.seleniumhq.org/how_it_works.html

But why is that? Is it because the browser is polling the selenium server? If so, can this polling interval not be modified? Or is there another reason. I am not accustomed to a remote call taking a humanly noticable amount of time to execute.

It is horrible that executing a few tests should take so long. I can execute my entire presentation (MVP), business, and database layer test suite (500+ tests) way quicker than it takes to run 10 tests for a single web page.

like image 549
Pete Avatar asked Mar 01 '10 08:03

Pete


People also ask

Why Selenium is too slow?

The Selenium WebDriver scripts are very slow because they run through the browser. There are multiple things that can improve the Selenium WebDriver scripts' speed: use fast selectors. use fewer locators.

Is Selenium WebDriver slower than Selenium RC?

The WebDriver scripts execution is much faster than the Selenium RC as it works directly with the browser. RC script execution is slower than the Selenium WebDriver since it works on the principle of JavaScript program. The Selenium Core directly controls the browser.

Is Selenium RC deprecated?

Selenium was introduced as a part of version 1.0 of Selenium. Selenium WebDriver was introduced as a part of version 2.0 of Selenium. Selenium RC is deprecated and obsolete now.


3 Answers

Are you testing with IE and Selenium in multiwindow mode? This is extremely slow and you should try to start the seleniumserver with -singlewindow

like image 96
Udo Avatar answered Nov 14 '22 23:11

Udo


Functional/Integration tests will take longer to run especially since they are running in a Browser. This means that it they have to load up all 3 layers of your MVC and then execute and the same when it is doing anything on the page. So every action has the potential to go down to the database. This is inherently a long running tasks compared to unit tests.

The tests start by doing an open on that page which then waits for everything to load. So if this is taking a long time then it could be taking a long time for your user if they were to access the page. E.g. Lots of images, unminified JavaScript/CSS, poor expiries on downloads.

What that page from Selenium is saying that the server is a bottleneck because it implies that you are running the tests synchronisely and if you moved to Selenium Grid it can run them in parallel to make the test suite complete faster. It is not suggesting that the selenium server is polling to see what it should do but instead the Selenium Servers poll the Grid hub to see if it is still alive and to show they are still alive.

The other reason the tests are running slow is Selenium's base language is JavaScript which interacts with the DOM. The DOM can slow things down a lot especially if your tests are using XPath as locators. XPath + JavaScript + IE + Selenium == Painful and there is nothing that we Selenium Developers can do more to fine tune it. Well there is and that is going to be Selenium 2 which is in alpha and can be downloaded from http://selenium.googlecode.com/ . I have been working on the .NET implementation am seeing huge speed improvements at the moment. I have blogged about it because the changes astounded me. I was seeing upto 8 tests running in the same time it used to take Selenium 1 to run 1 test

like image 44
AutomatedTester Avatar answered Nov 15 '22 00:11

AutomatedTester


Is it possible that your default execution speed is too low? Check out getSpeed() and setSpeed() methods on DefaultSelenium.

like image 32
c_maker Avatar answered Nov 15 '22 00:11

c_maker