Setspeed in Selenium Webdriver Using Ruby

setSpeed in Selenium WebDriver using Ruby

The methods to set the execution speed in WebDriver were deprecated for all language bindings some time ago. It is no longer possible to modify the execution speed of the running WebDriver code.

Selenium WebDriver- How to control the speed of running the test cases

If you are looking to explicitly control the 'speed' of the execution using methods,I have found this link wherein a similar issue is discussed/answered.

Apart from that I think , that if we are looking at speed with efficiency/accuracy in mind, we should follow good practices as in efficient locator strategies , among others.

Or in some cases wherein if we have to interact with Ajax, we could use wait judiciously.More info here.

Hope this is useful :).

The default value of timeouts on selenium webdriver

These three timeouts are managed by the server-side of the Selenium equation. Your script, be it in Java, Python, Ruby, C#, or whatever, is a client that sends commands to a server that lives in the browser. (There may be an intermediary that relays commands to the browser, like Selenium grid. Unfortunately, it is also sometimes called a "server".)

The WebDriver specification, which was derived from Selenium has settled on the following values:

  • For implicit waits: 0 seconds. This means that if a selenium command does not find an element immediately, it reports immediately, rather than wait until an element is found.

  • For page loads: 300 seconds.

  • For script timeouts: 30 seconds.

(The specification gives the values in milliseconds. I've converted them to seconds for ease of reading.)

Selenium now follows the WebDriver specification.


In the past Selenium has used other values for these, however. For instance, the Firefox driver used to define its timeouts like this:

  • The implicit wait timeout is set to 0 by default. This means that if a command that finds elements does not find anything, it won't wait.

  • The page load timeout is set to -1 by default. This means that Selenium will wait indefinitely for the page to load.

    What Saifur found is not the same as the page load timeout. That's a timeout between the Selenium client and the Selenium server, which is not particularly well explained on the page Saifur found.

  • The script timeout is set to 0 by default. A comment in the source code explains:

    The amount of time, in milliseconds, this session should wait for asynchronous scripts to finish executing. If set to 0, then the timeout will not fire until the next event loop after the script is executed. This will give scripts that employ a 0-based setTimeout to finish.

    So even if it set to zero, an asynchronous script can still execute but it has to complete before Selenium's timeout gets a chance to run again.

This is from the code that Selenium uses for Firefox. The other browsers use different code bases but they are supposed to behave consistently, at least with regards to things that are proper to Selenium itself, like these timeouts. So the values and their interpretations should be the same for other browsers too.

Timing page load times in Selenium

Your stopwatch function should work. In addition, for Selenium to capture the load time at reasonable precision, reduce the amount of wait time between commands.
I, typically, use the following logic -

StopWatch s = new StopWatch();
s.start();
while (selenium.isElementPresent("element_locator")) {
selenium.setSpeed("10");
Thread.sleep(10);
}
s.stop();
System.out.println("elapsed time in milliseconds: " + s.getElapsedTime());

Here is some more information on the StopWatch class.



Related Topics



Leave a reply



Submit