Selenium中的waitForPageToLoad替代方法

编程入门 行业动态 更新时间:2024-10-26 13:31:40
本文介绍了Selenium中的waitForPageToLoad替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在一个页面上有一系列链接,需要不同的时间来加载...我想捕获每次使用的时间量...我遇到的问题是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替代方法

本文发布于:2023-11-15 17:28:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1596499.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   Selenium   waitForPageToLoad

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!