setSpeed in Selenium WebDriver using Ruby

17,153

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.

Share:
17,153
Amey
Author by

Amey

Updated on June 30, 2022

Comments

  • Amey
    Amey almost 2 years

    Is there a way to set the Selenium Webdriver execution speed in ruby.

    In perl for selenium 1(RC) there was $sel->set_speed("500");

    But due to some constraints of Selenium RC, I had to shift to Selenium Webdriver and had to start using Ruby, and I cannot find the function for the same.

    Read somewhere the options "Slow", "Medium" and "Fast" as arguments to set speed in C# and Perl, but not in Ruby.

    Note - I do have timeouts set with this @driver.manage.timeouts.implicit_wait = 30 but i am looking for execution speed.

  • Amey
    Amey over 12 years
    Nope that does not work, these functions are part of the Selenium Client Idiomatic module, which is not included in the Webdriver module? I think.
  • Amey
    Amey over 12 years
    This is the error I get btw NoMethodError: undefined method execution_delay' for #<Selenium::WebDriver::Driver:0x101534678>`
  • Amey
    Amey over 12 years
    So whats the best way to resolve an issue, where on clicking a link- a popup opens, and I need to send keys to a textbox in that popup. The popup sometimes takes longer to load, due to which the find_element of that textbox id fails even though it does appear. I think the attempt to search the element id starts immediately and even though the popup loads well before 30 seconds(my explicit timeout), the scripts fails.
  • JimEvans
    JimEvans over 12 years
    You need some sort of explicit wait routine; implicit waits may not help you here. In the languages supported directly by the project (Java, .NET, Ruby, Python), this can be accomplished using the WebDriverWait class (or its equivalent). Also, the answer depends a little on what you mean by "popup". Is it a new browser window? If so, you'll need to use driver.switch_to.window() to put your focus in the correct context. If it's a "popup" created by, say, a JavaScript widget framework like jQuery or similar, your find_element in your wait routine.
  • Amey
    Amey over 12 years
    So its a new window popup, a linkedin Login authorization to be more accurate. And i do shift controls to the new window, by using handles = @driver.window_handles @driver.switch_to.window(handles[1])... but what happens is.. the popup takes may be like a second or two to actually "pop-up" during which the switching to window fails, and all steps there on obviously fail. I currently have put in place.. a sleep of 2 seconds (between clicking the link and waiting to switch to the new window). But I am sure there is a better way.
  • JimEvans
    JimEvans over 12 years
    Yes, there is. You're in Ruby, so you'll want to use a Selenium::WebDriver::Wait object, and wait for @driver.window_handles.size to be > 1. Then you can proceed forward and switch to the new window. You can see an example of this in the project wiki. Keep in mind, however, that the handles returned by driver.window_handles are not guaranteed to be in the order they were opened for every browser, so you can't necessarily rely on just taking driver.window_handles[1] and expecting that to be the new window handle.