【发布时间】:2018-06-21 20:45:21
【问题描述】:
我正在为 UWP(通用 Windows 平台)编写一些用于自动化测试的代码,有时我需要等待某个元素。但是我遇到了以下问题:超时时间总是少于 60 秒(40~60 秒)。
函数调用:
waitForElementName(TimeSpan.FromSeconds(120).Seconds, "abcde");
功能:
protected static WindowsDriver<WindowsElement> desktopSession;
public static void waitForElementName(long timeout, string elementName)
{
WebDriverWait wait = new WebDriverWait(desktopSession, new TimeSpan(timeout));
wait.Until(ExpectedConditions.ElementIsVisible(OpenQA.Selenium.By.Name(elementName)));
}
在这种情况下,我想为元素等待 120 秒。但总是在 40~60 秒内,超时中断,调试器带有以下消息:
消息:测试方法抛出异常: System.InvalidOperationException:无法定位元素 使用给定搜索参数的页面。
谢谢!
【问题讨论】:
标签: c# selenium-webdriver uwp