gpt4 book ai didi

c# - Selenium Webdriver/C# - 如何在点击后确认页面加载?

转载 作者:行者123 更新时间:2023-11-30 18:28:27 25 4
gpt4 key购买 nike

我尝试调用的网站基本上使用 .ascx 和 aspx 页面来呈现它们的项目。为了导航,您必须使用 click 事件而不是 goto url。目前我正在使用 Thread.Sleep(3000),但那很笨拙,我认为这不是最好的方法。

为了确保页面已从点击事件加载,您可以添加什么?

IWebElement myLink;

myLink = driver.FindElement(By.Id("ctl00_ctl00_cphContentArea_cphContentArea_ucwaag_lnkbtnDate" + i.ToString()));
myLink.Click();
Thread.Sleep(5000); //yeah need to fix this

最佳答案

这与我们在尝试使用 Selenium 时遇到的问题完全相同。

我们通过使用等待条件解决了这个问题。

wait.Until(ExpectedConditions.ElementExists(locator));
wait.Until(ExpectedConditions.ElementIsVisible(locator));

我们不得不同时使用 ElementExists 和 ElementIsVisible 来解决控件在页面上但还不可见的问题

关于c# - Selenium Webdriver/C# - 如何在点击后确认页面加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24997936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com