更新时间:2023-08-24 09:57:40
waitforcontrol
有点方法是在控件类型上调用的。并且控件存在是正确的,但这并不意味着控件已准备就绪(可能正在加载)
The waitforcontrol
kinda methods are called on a control type. And control exist would be true, but it doesn't mean that the control is ready (It probably be loading)
一般做法是在超级控件上调用waitforcontrolready方法父母(说浏览器)。我已按照以下方法修改了您的方法,
The general practice is call the waitforcontrolready method on the super parent. (Say Browser). I've modified your method as below,
public void WaitForPageToLoad(BrowserWindow browser, int WaitTimeOut)
{
// Waiting on all threads enable to wait for any background process to complete
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
// Wait
browser.WaitForControlReady(WaitTimeOut * 1000);
// Revert the playback settings (As waiting on all threads may sometime have a toll on execution speed
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.UIThreadOnly;
}
然后只要在页面加载的任何地方调用方法来等待,切记以秒为单位传递浏览器和超时。
then just call the method to wait, where ever you do a page load. Remember to pass browser and timeout in seconds as a parameter. Something like,
ClickButton(Repo.LeftButton(Browser));
WaitForPageLoad(Browser, 120);
希望有帮助!