---
title: "Selenium IDE - Reducing time from 58 min to 15 min"
description: "This post is about hastening the execution of selenium tests."
canonical_url: "https://www.bigbinary.com/blog/how-i-reduced-selenium-test-run-time-from-58-minutes-to-15-minutes"
markdown_url: "https://www.bigbinary.com/blog/how-i-reduced-selenium-test-run-time-from-58-minutes-to-15-minutes.md"
---

# Selenium IDE - Reducing time from 58 min to 15 min

This post is about hastening the execution of selenium tests.

- Author: Prabhakar Battula
- Published: September 8, 2014
- Categories: Misc

I wrote a bunch of selenium tests using
[Selenium IDE](http://www.seleniumhq.org/download) for a project. The selenium
tests have proven to be very useful. However the tests take around 58 minutes to
complete the full run.

Here are the specific steps I took which brought the running time to under 15
minutes.

## Set to run at the maximum speed

<table>
  <tr>
    <td> Command </td>
    <td> Target </td>
    <td> Value </td>
  </tr>
  <tr>
    <td>setSpeed </td>
    <td>0 </td>
    <td></td>
  </tr>
</table>

`setSpeed` command takes `Target` value in milliseconds. By setting the value to
zero, I set the speed to maximum and the tests indeed ran fast. However, now I
had lots of tests failing which were previously passing.

What happened.

In our tests real firefox browser is fired up and real elements are clicked. The
application does make round trip to the rails server hosted on heroku.

By setting the selenium tests to the maximum speed the selenium tests started
asserting for elements on the page even before the pages were fully loaded by
the browser.

I needed sets of instructions using which I could tell selenium how long to wait
for before asserting for elements.

Selenium provides a wonderful suite of commands which helped me fine tune the
test run. Here I'm discussing some of those commands.

## waitForVisible

This command is used to tell selenium to wait until the specified element is
visible on the page.

In the below mentioned case, the Selenium IDE will wait until the element
`css=#text-a` is visible on the page.

<table>
  <tr>
    <td> Command</td>
    <td> Target</td>
    <td> Value</td>
  </tr>
  <tr>
    <td>waitForVisible</td>
    <td>css=#text-a</td>
    <td> </td>
  </tr>
</table>

## waitForText

This command is used to tell selenium to wait until a particular text is visible
in the specified element.

In the case mentioned below, Selenium IDE will wait until the text `violet` is
displayed in the element `css=#text-a`.

<table>
  <tr>
    <td> Command</td>
    <td> Target</td>
    <td> Value</td>
  </tr>
  <tr>
    <td>waitForText</td>
    <td>css=#text-a</td>
    <td>violet</td>
  </tr>
</table>

<br />

The difference between _waitForVisible_ and _waitForText_ is that
**waitForVisible waits until the specified element is visible on the page**
while **waitForText waits until a particular text is visible in the specified
element on the page**.

## waitForElementPresent

This command is used to tell Selenium to wait until the specified element is
displayed on the page.

In the below mentioned case, the Selenium IDE will wait until the element
`css=a.button` is displayed on the page.

<table>
  <tr>
    <td> Command</td>
    <td> Target</td>
    <td> Value</td>
  </tr>
  <tr>
    <td>waitForElementPresent</td>
    <td>css=a.button</td>
    <td></td>
  </tr>
</table>

_waitForVisible_ and _waitForElementPresent_ seem very similar. It seems both of
these commands do the same thing. There is a subtle difference though.

_waitForVisible_ waits until the specified element is visible. Visibility of an
element is manipulated by the settings of CSS properties. For example using
`display none;` one can make an element not be visible at all.

In contrast the command _waitForElementPresent_ waits until the specified
element is present on the page in the form of html markup. This command does not
give consideration to css settings.

## refreshAndWait

This command is used to tell Selenium to wait until the page is refreshed and
the targeted element is displayed on the web page.

In the example mentioned below, the Selenium IDE will wait until the page is
refreshed and the targeted element `css=span.button` is displayed on the page.

<table>
  <tr>
    <td> Command</td>
    <td> Target</td>
    <td> Value</td>
  </tr>
  <tr>
    <td>refreshAndWait</td>
    <td>css=span.button</td>
    <td></td>
  </tr>
</table>

## clickAndWait

This command is used to tell selenium to wait until a particular button is
clicked for submitting the form and the page starts reloading. The subsequent
commands are paused until, the page is reloaded after the element is clicked on
the page.

In the case mentioned below, Selenium IDE will wait until the page is reloaded
after the specified element `css=input#edit` is clicked.

<table>
  <tr>
    <td> Command</td>
    <td> Target</td>
    <td> Value</td>
  </tr>
  <tr>
    <td>clickAndWait</td>
    <td>css=input#edit</td>
    <td></td>
  </tr>
</table>

Selenium IDE commands used above and more are available at
[Selenium documentation](http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#selenium-commands-selenese)
.

## Links

- [Human page](https://www.bigbinary.com/blog/how-i-reduced-selenium-test-run-time-from-58-minutes-to-15-minutes)
