Selenium IDE - Command to wait for 5 seconds

2019-01-31 22:26发布

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

10条回答
2楼-- · 2019-01-31 22:53

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.

查看更多
仙女界的扛把子
3楼-- · 2019-01-31 22:55

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

查看更多
时光不老,我们不散
4楼-- · 2019-01-31 22:58

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

Command: waitForElementPresent Target: link=do something Value:

查看更多
做自己的国王
5楼-- · 2019-01-31 22:59

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

查看更多
女痞
6楼-- · 2019-01-31 23:00

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

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

Klendathu

查看更多
何必那么认真
7楼-- · 2019-01-31 23:03

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

查看更多
登录 后发表回答