97

I´m using the Selenium IDE for Firefox and searching for a wait command. My problem is that I want to test a website with a embedded external map. This external map needs 3-5 seconds to load.

My commands:

open /Page/mysite.html
//Wait Command? (5 seconds)
ClickAndWait link=do something
0

11 Answers 11

116

Use the pause command and enter the number of milliseconds in the Target field.

Set speed to fastest (Actions --> Fastest), otherwise it won't work.

5
  • Thank you! I insered the command, but Selenium doesn´t pause. Command = pause, Value = 10000
    – LaPhi
    Jul 15, 2011 at 7:45
  • 58
    Use Target instead of Value. Command = Pause, Target = 1000.
    – khairul
    Mar 12, 2012 at 3:39
  • 1
    @Khairul glad you added that comment, it's been driving me mad as to why pause() won't work!
    – cchana
    May 18, 2012 at 11:13
  • Speed has no bearing on the pause command, it is as @Khairul says instead: Put it in the target.
    – Mendhak
    Oct 24, 2012 at 14:50
  • when you pause at the end of a test case when running a test suite it won't work Jul 11, 2014 at 6:02
94

This will delay things for 5 seconds:

Command: pause
Target: 5000
Value:

This will delay things for 3 seconds:

Command: pause
Target: 3000
Value:

Documentation:

http://release.seleniumhq.org/selenium-core/1.0/reference.html#pause

enter image description here enter image description here

2
  • 2
    So, set 5000 for 5 seconds Jul 29, 2015 at 7:04
  • 1
    That's insane that they would make the target the value to wait in milliseconds. Love it. Thank you for posting this as I did not even try to enter the value in the target.
    – John Z
    Mar 29, 2018 at 17:37
6

For those working with ant, I use this to indicate a pause of 5 seconds:

<tr>
    <td>pause</td>
    <td>5000</td>
    <td></td>
</tr>

That is, target: 5000 and value empty. As the reference indicates:

pause(waitTime)

Arguments:

  • waitTime - the amount of time to sleep (in milliseconds)

Wait for the specified amount of time (in milliseconds)

4

Your best bet is probably waitForCondition and writing a javascript function that returns true when the map is loaded.

3
2

In case when you use Chrome exctantion you can set timeout in 'Target'. It helps for me.

enter image description here

1

This will do what you are looking for in C# (WebDriver/Selenium 2.0)

var browser = new FirefoxDriver();
var overallTimeout = Timespan.FromSeconds(10);
var sleepCycle = TimeSpan.FromMiliseconds(50);
var wait = new WebDriverWait(new SystemClock(), browser, overallTimeout, sleepCycle);
var hasTimedOut = wait.Until(_ => /* here goes code that looks for the map */);

And never use Thread.Sleep because it makes your tests unreliable

1
  • Much better option in Selenium 2.
    – craastad
    Jul 3, 2013 at 14:16
0

The pause command can be used directly in the ide in the html format.

If using java or C you could use Thread.sleep(5000). Time is in milliseconds. Other languages support "sleep 5" or time.sleep(5). you have multiple options for just waiting for a set time.

2
  • 2
    Thread.Sleep is never a good idea and that's why Selenium provides wait primitives. If you use them you can specify much higher timeout value which makes tests more reliable without slowing them down as the condition can be evaluated as often as it's required, eg. every 50ms. Jul 17, 2011 at 7:06
  • My response in the thread.sleep is only related to answer the question for how to make it wait in the ide. As pause gets translated into thread.sleep when you convert from html to java or c in the ide. Jul 18, 2011 at 13:28
0

Before the command clickAndWait add the following code so the script will wait until the specific link to be visible:

   <tr>
        <td>waitForVisible</td>
        <td>link=do something</td>
        <td></td>
    </tr>

The practice of using the wait commands instead of pause is most of the times more efficient and more stable.

0

This will wait until your link has appeared, and then you can click it.

Command: waitForElementPresent Target: link=do something Value:

0

One that I've found works for the site I test is this one:

waitForCondition | selenium.browserbot.getUserWindow().$.active==0 | 20000

Klendathu

0

In Chrome, For "Selenium IDE", I was also struggling that it doesn't pause. It will pause, if you give as below:

  • Command: pause
  • Target: blank
  • Value: 10000

This will pause for 10 seconds.

2
  • 1
    Target should be 10000 and value should be blank
    – Sirmyself
    Mar 20, 2018 at 21:07
  • Not sure which browser's plugin you are trying but that worked fine for me in Chrome. Also depends which extension you are using.
    – TechSingh
    May 15, 2018 at 17:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.