使用Java的WebDriver中是否有任何方法可以控制浏览器的速度? [英] Is there any method in WebDriver with Java for controlling speed of browser?

查看:153
本文介绍了使用Java的WebDriver中是否有任何方法可以控制浏览器的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Selenium RC时,有一种方法setSpeed为:

When I use Selenium RC there is a method setSpeed as:

selenium.setSpeed("500");

selenium.setSpeed("500");

在Selenium WebDriver中控制浏览器速度的方法是什么?

What is the way to control speed of browser in Selenium WebDriver?

推荐答案

您可以使用任何运行Webdriver的语言使用Thread.Sleep(500)(或等效语言).这将导致线程暂停确切的毫秒数.

You can use Thread.Sleep(500) (or equivalent) in whatever language you are using to run webdriver. This will cause the thread to pause for an exact number of milliseconds.

或者,您也可以使用显式隐式等待这里.

Alternatively you can use explicit or implicit waits described here.

  • 显式等待使您可以定义ExpectedCondition. Webdriver将每500毫秒检查一次条件,直到返回true(此后将立即恢复执行).

  • Explicit waits allow you to define an ExpectedCondition. Webdriver will check the condition every 500 milliseconds until it returns true, (after which execution will resume immediately).

隐式等待导致Webdriver继续重试尝试在DOM中查找内容.一旦找到该元素,执行将立即恢复.

Implicit waits cause webdriver to keep retry attempting to locate something in the DOM. Execution will resume immediately once the element is found.

请注意,隐式或显式等待都不能保证500毫秒的暂停.

Note that neither implicit nor explicit waits will guarantee a 500 millisecond pause.

这篇关于使用Java的WebDriver中是否有任何方法可以控制浏览器的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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