我在一个页面上有一系列链接,需要不同的时间来加载...我想捕获每次使用的时间量...我遇到的问题是waitForPageToLoad的时间(如果超出)会导致测试失败,我的其他链接没有被测试...我知道我可以跳过测试中的可疑链接或设置超出预期的时间限制,但我希望有一个替代waitForPageToLoad可以用于在Selenium中加载页面时陷阱,以便如果一个页面花费的时间超过一分钟加载它不会结束脚本。
I have a series of links on a page that take different times to load... I want to capture the amount of time each takes... The problem I am having is that the waitForPageToLoad time if exceeded causes the test to fail and the rest of my links do not get tested... I know I could just skip suspected links in the test or set the time limit way beyond expectation, but I was hoping there was an alternative to the waitForPageToLoad that could be used to trap when a page is loaded in Selenium, so that if a page takes longer than a minute to load it doesn't end the script.
推荐答案Wawa的回答对我来说非常棒,我只需要将增量添加到第二个var。
Wawa's answer worked great for me, I just had to add the increment to the second var.
我也只想等5秒钟,所以我更改了休息条件。
I also only wanted to wait 5 seconds, so I changed the break criteria.
int second = 0; while(!selenium.IsElementPresent(mylink)) { if(second >= 5) break; Thread.Sleep(1000); second++; }更多推荐
Selenium中的waitForPageToLoad替代方法
发布评论