Nunit 等待页面Waitforcomplete()或system.threading.thread.sleep()上的元素的更好方法是什么
我在watiN中使用WaitforComplete(),但它似乎工作不好。当它执行下一条语句时,即使您已给它更长的等待时间。我正在使用thread.sleep()停止我的应用程序,直到它获得所需的页面或元素。但问题是页面是如此动态,以至于有时需要更长的时间 没有更好的解决办法。任何能够捕获页面的东西都会动态返回,并且不会执行应用程序中的下一个语句 代码示例Nunit 等待页面Waitforcomplete()或system.threading.thread.sleep()上的元素的更好方法是什么,nunit,cruisecontrol.net,watin,Nunit,Cruisecontrol.net,Watin,我在watiN中使用WaitforComplete(),但它似乎工作不好。当它执行下一条语句时,即使您已给它更长的等待时间。我正在使用thread.sleep()停止我的应用程序,直到它获得所需的页面或元素。但问题是页面是如此动态,以至于有时需要更长的时间 没有更好的解决办法。任何能够捕获页面的东西都会动态返回,并且不会执行应用程序中的下一个语句 代码示例 'Show Details page Assert.AreEqual("Confirmation", _internetEx
'Show Details page
Assert.AreEqual("Confirmation", _internetExplorer.Title)
If (_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Exists) Then
_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Click()
Else
Assert.Fail("Could not Find Finish Booking Button on Confirmation Page")
End If
System.Threading.Thread.Sleep(100000)
'显示预订摘要页面
Assert.AreEqual(“显示预订”,_internetExplorer.Title)
我想要动态检测页面返回的东西。如果它正在执行下一个语句,那么它应该查找相应的元素,而不是给出一些常量值。。我建议发布一个您正在尝试的代码示例。如果它正在执行下一条语句,则应该查找相应的元素。我建议您发布一个您正在尝试的代码示例。WaitForComplete只有在某些操作后有回发时才有效。否则你就得找别的东西等。下面是一个关于如何等待指定标题的示例:
_internetExplorer.Element("title", "Confirmation").WaitUntilExists();
我总是更喜欢使用WaitXXX方法之一而不是线程。睡眠是因为WaitXXX方法只等待满足约束条件。其中,睡眠等待您指定的时间。如果它太长,时间就太长了。如果它太短,问题就会出现
嗯,,
JeroenWaitForComplete只有在某些操作后有回发时才能正常工作。否则你就得找别的东西等。下面是一个关于如何等待指定标题的示例:
_internetExplorer.Element("title", "Confirmation").WaitUntilExists();
我总是更喜欢使用WaitXXX方法之一而不是线程。睡眠是因为WaitXXX方法只等待满足约束条件。其中,睡眠等待您指定的时间。如果它太长,时间就太长了。如果它太短,问题就会出现
嗯,,
Jeroen一旦浏览器将其readystate设置为comllete,将busy状态设置为false,WaitForComplete方法就会立即启动 我通常做的是尝试访问您需要的内容,然后执行一个线程。睡眠半秒钟,然后重试。我还有一个全局超时,在10秒后退出
int timeout = 20;
bool controlFound = false;
for (int i = 0; i < timeout; i++)
{
if (_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Exists)
{
_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Click();
controlFound = true;
break;
}
else
{
System.Threading.Thread.Sleep(500);
}
}
if (!controlFound)
{
Assert.Fail("Control not found");
}
int超时=20;
bool controlFound=false;
for(int i=0;i
一旦浏览器将其readystate设置为comllete,并将busy状态设置为false,WaitForComplete方法就会继续运行
我通常做的是尝试访问您需要的内容,然后执行一个线程。睡眠半秒钟,然后重试。我还有一个全局超时,在10秒后退出
int timeout = 20;
bool controlFound = false;
for (int i = 0; i < timeout; i++)
{
if (_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Exists)
{
_internetExplorer.Button(Find.ById(New Regex("btnFinish"))).Click();
controlFound = true;
break;
}
else
{
System.Threading.Thread.Sleep(500);
}
}
if (!controlFound)
{
Assert.Fail("Control not found");
}
int超时=20;
bool controlFound=false;
for(int i=0;i