Running Selenium TestRunner slowly


Posted in: testing | Save to del.icio.us | Twit This! 23 Nov 2009

By default Selenium TestRunner executes the test blindingly fast. You can however slow down the execution by using the speed controller slider in the right pane, which adds a maximum delay of 1 second after every command execution. But you have to do that manually for every test, and the maximum delay you get is 1 second. You can however increase the delay and also set the default delay rate by editing the selenium-testrunner.js file.

Editing the selenium-testrunner.js file

First you have to find the ’selenium-testrunner.js’ file. It is located in your ‘Windows\Application Data’ directory. The rough path is given below:

Documents and Settings\Application Data\Mozilla\Firefox\
Profiles\extensions\{a6fd85ed-t567-s34f-a5af-ddf48bda539f}\content-files

Your exact directory path will be different. It is best do do a search for the file in your ‘Mozilla’ directory. Once you have found it, you can look for the following lines of code:

reset: function() {
        this.runInterval = this.speedController.value;
        this._switchContinueButtonToPause();
    },

and replace it with:

reset: function() {
        this.runInterval = 2000;
        this._switchContinueButtonToPause();
    },

This will by default add a 2 second delay after every command execution. Note that as we have made hardcoded changes to the speed variables, the speed slider in the TestRunner window will no longer have any effect on the execution.

Setting the default speed controller delay to a high value

In view of a recent comment, you can also set the default high delay for your slider by replacing the following lines in ’selenium-testrunner.js’.

this.speedController = new Control.Slider('speedHandle', 'speedTrack', {
            range: $R(0, 1000),
            onSlide: fnBindAsEventListener(this.setRunInterval, this),
            onChange: fnBindAsEventListener(this.setRunInterval, this)
        });

with

this.speedController = new Control.Slider('speedHandle', 'speedTrack', {
            range: $R(100, 5000),
            onSlide: fnBindAsEventListener(this.setRunInterval, this),
            onChange: fnBindAsEventListener(this.setRunInterval, this)
        });

Which will set the default delay to 100 milliseconds and the maximum to 5 seconds. Now you can also use the speed slider.




Share this post

Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Digg
Share on Technorati
Share on Reddit
Feeds RSS Subscribe to site Feed

Other related posts



3 Responses

1

Rule

November 25th, 2009 at 2:05 am

why not use


reset: function() {
this.runInterval = (this.speedController.value * 2);
this._switchContinueButtonToPause();
},

That way you can still use the slider, but have your maximum 2 seconds :)

sameer

November 25th, 2009 at 3:21 am

The point was to set the default value to something high without manual intervention. As the default ’speedController’ value is ‘0′, the above code will set the default to ‘0′. To increase the default value and also use the slider, we can edit the following lines:


this.speedController = new Control.Slider('speedHandle', 'speedTrack', {
range: $R(0, 1000),
onSlide: fnBindAsEventListener(this.setRunInterval, this),
onChange: fnBindAsEventListener(this.setRunInterval, this)
});

to


this.speedController = new Control.Slider('speedHandle', 'speedTrack', {
range: $R(100, 5000),
onSlide: fnBindAsEventListener(this.setRunInterval, this),
onChange: fnBindAsEventListener(this.setRunInterval, this)
});

3

harendra

February 6th, 2010 at 6:04 am

Please let me know if I can set the “Highlight Elements” option checked by default.

Thanks,

Comment Form

Use the html <code> tag to insert small source code snippets

For longer code examples use http://pastie.org/.

Get latest updates by E-mail

About this blog

This site is a digital habitat of Sameer, a freelance web developer working from Pune.More

Recent Comments

  • sameer: My apologies! I'm not conversant with SharePoint. [...]
  • avanthi: Is it possible to automate share point people picker control through selenium. When i record throug [...]
  • sameer: Check to see if the 'IDE > options > format' is set to HTML. [...]
  • sameer: Google strips any newline characters form the text. Although it does accept it with the online trans [...]
  • Arjan: Fiddler is a debugging tool for IE (not Microsoft's Fiddler) [...]
  • Susan Martin: while creating a test for site, command icons on IDE greyed out and do not respond when selected. I [...]
  • Saar: Thanks for this example. helped me a lot. I have 1 problem, I am translating chunks of code, but I [...]
  • sameer: You can add extra GET variables in the options array as below: $pager_options = array( 'mode [...]

  • Users Online

    • 9 Users Online
    • 8 Guests, 1 Bot