我如何等待特定的帧加载?我正在使用Selenium WebDriver 2.24 [英] How do i wait for a specific frame to load? I'm using selenium webdriver 2.24

查看:78
本文介绍了我如何等待特定的帧加载?我正在使用Selenium WebDriver 2.24的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了由webdriver支持的硒来等待特定帧的加载.因为在某些情况下,由于尚未加载特定框架而导致切换到特定框架失败. 我使用的代码是

I used the webdriver backed selenium to wait for a specific frame to load. since in certain cases the switching to a specific frame fails because the frame hasn't loaded. The code I use is

selenium.waitForFrameToLoad(frameJCLeft, strTimeOut);
driver.switchTo().defaultContent();
driver.switchTo().frame(frameJCLeft);

请告诉我是否有一种方法,因为我打算消除硒支持的webdriver,而仅使用webdriver api

Please let me know if there's a method as I'm planning to eliminate selenium backed webdriver and only use the webdriver api

推荐答案

您可以使用Web Driver Wait and Expected Condition类来实现此目的.

You can use Web Driver Wait and Expected Condition class to achieve this.

尝试此代码.

  WebDriverWait wait = new WebDriverWait(driver,10);
  wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(frameName);

上面的代码将等待given frame up to 10 seconds.如果该框架可用,则它将切换到给定的框架.否则,它将引发TimeoutException.

The above code will wait for a given frame up to 10 seconds. If the frame is available then it switches to the given frame. Otherwise, it throws a TimeoutException.

时间限制取决于应用程序和用户的意愿.

The time limit depends upon the application and user wish.

更多信息 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆