Control Webdriver Execution speed

12,895 views
Skip to first unread message

Arun Kumaresan

unread,
Nov 21, 2011, 10:17:48 AM11/21/11
to Selenium Users
Hi,
I am using selenium 2.13.0.

How do I manage the execution speed.
I am not able to get the option of setting and getting speed of
execution using Webdriver object.

I tried the following code and couldnt get the method to set and get
speed.

WebDriver driver = new FirefoxDriver(firefoxProfile);
driver.manage().???

Can you pls help?

Regards,
Arun Kumaresan

cassio kenji

unread,
Nov 21, 2011, 10:40:36 AM11/21/11
to seleniu...@googlegroups.com
Hello,

could you try the selenium.setSpeed(String miliseconds)?

Hope it helps

2011/11/21 Arun Kumaresan <arunku...@gmail.com>
Arun Kumaresan

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Luke Inman-Semerau

unread,
Nov 21, 2011, 12:01:20 PM11/21/11
to seleniu...@googlegroups.com
In webdriver you do not "setSpeed". You need to add waits to your code if an element is not available to be interacted with:

Arun Kumaresan

unread,
Nov 21, 2011, 12:14:30 PM11/21/11
to seleniu...@googlegroups.com
I have used selenium.setSpeed before but I thought this would affect only selenium object.
 
In otherwords, if I set some speed using selenium.setSpeed, would it also reduce the speed of the corresponing webdriver object execution.

On Mon, Nov 21, 2011 at 7:40 AM, cassio kenji <chaos...@gmail.com> wrote:



--
Regards,
Arun Kumaresan

Arun Kumaresan

unread,
Nov 21, 2011, 12:17:39 PM11/21/11
to seleniu...@googlegroups.com
Pls correct me if I am wrong.
But looks like implicit and explicit waits are used only for waiting on a certain object in the UI.
 
But that doesnt slow down the execution of the webdriver script execution per se (If all the required objects are available).
 
I was looking for something in webdriver that is anologus to selenium.setSpeed()

Regards,
Arun Kumaresan

Luke Inman-Semerau

unread,
Nov 21, 2011, 12:44:51 PM11/21/11
to seleniu...@googlegroups.com
There isn't... you shouldn't. The only reason I can think of is if you are trying to demo the automation to someone (like management). In that case you can set a break point in your code and step through the execution for them to see... and then wow them by running it without the breakpoints to show them how quickly it runs ;)

If you let me know your use-case I can try to recommend something.

cassio kenji

unread,
Nov 21, 2011, 1:50:22 PM11/21/11
to seleniu...@googlegroups.com
You are assuming that his problem is wait for an element?
His question is clear about what he wants: set the speed of execution.

Sorry I can't help you with that, Arun :(


2011/11/21 Luke Inman-Semerau <luke.s...@gmail.com>

Arun Kumaresan

unread,
Nov 21, 2011, 5:57:01 PM11/21/11
to seleniu...@googlegroups.com
Well, what I have noticed is that sometimes (Especially on firefox), the execution is so fast that the action on the UI gets skipped. For example, in a sequence like this,
 
type <find Criteria>
Click<Find Button>
Click<Find Result>
the click on Find button gets skipped sometimes and the script fails. The execution goes through if I do a break and step through the execution.
NOTE: Find button is always there even before I try to click.
 
And on IE I have seen some strange behaviours where it just fails on IE7 (Unfortunately we still have to support it although its old version)
 
Regards,
Arun Kumaresan.

Adam

unread,
Dec 2, 2011, 5:22:28 PM12/2/11
to Selenium Users
This would be very helpful with AJAX apps. The key part is that all of
the waits wait BEFORE using an element if it isn't there. What about
when the wait must happen after the action? Slowing the whole test may
be far easier than trying to add little waits after every input.

Adam

On Nov 21, 10:44 am, Luke Inman-Semerau <luke.seme...@gmail.com>
wrote:


> There isn't... you shouldn't. The only reason I can think of is if you are
> trying to demo the automation to someone (like management). In that case
> you can set a break point in your code and step through the execution for
> them to see... and then wow them by running it without the breakpoints to
> show them how quickly it runs ;)
>
> If you let me know your use-case I can try to recommend something.
>

> On Mon, Nov 21, 2011 at 9:17 AM, Arun Kumaresan <arunkumare...@gmail.com>wrote:
>
> > Pls correct me if I am wrong.
> > But looks like implicit and explicit waits are used only for waiting on a
> > certain object in the UI.
>
> > But that doesnt slow down the execution of the webdriver script execution
> > per se (If all the required objects are available).
>
> > I was looking for something in webdriver that is anologus to
> > selenium.setSpeed()
>
> > On Mon, Nov 21, 2011 at 9:01 AM, Luke Inman-Semerau <
> > luke.seme...@gmail.com> wrote:
>
> >> In webdriver you do not "setSpeed". You need to add waits to your code if
> >> an element is not available to be interacted with:
>

> >>http://seleniumhq.org/docs/04_webdriver_advanced.html#explicit-and-im...


>
> >> On Mon, Nov 21, 2011 at 7:40 AM, cassio kenji <chaosci...@gmail.com>wrote:
>
> >>> Hello,
>
> >>> could you try the selenium.setSpeed(String miliseconds)?
>
> >>> Hope it helps
>

> >>> 2011/11/21 Arun Kumaresan <arunkumare...@gmail.com>

bis

unread,
Dec 3, 2011, 2:11:12 PM12/3/11
to seleniu...@googlegroups.com
what do you mean wait after the action happens?

I would assume that when you do an action you wait for the next element you need to see to continue your flow. can i get an example of why you would need to wait after you click something?

Kenneth Koontz

unread,
Dec 3, 2011, 2:19:17 PM12/3/11
to Selenium Users
bis,

With an AJAX application a click can fire off javascript that
webdriver has no way of knowing when the javascript executed has
finished. This is why you need to some sort of wait to manage the flow
of the test.

I wrote up a short article discussing waits in webdriver. This might
help:

http://www.decipherinc.com/n/blog/development-and-engineering-team/2011/11/selenium-tests-when-wait-webdriver

bis

unread,
Dec 3, 2011, 5:35:10 PM12/3/11
to seleniu...@googlegroups.com
right but im thinking that you click the ajax action and there is usually some sort of loading or spinner that tells you something is happening why not do a wait while that is present. then when its gone move on with your test

http://selenium.googlecode.com/svn/trunk/docs/api/rb/Selenium/Client/Extensions.html

Thomas Perraudin

unread,
Jan 13, 2012, 12:25:32 PM1/13/12
to seleniu...@googlegroups.com
Arun, I have the same problem !
Have you found a solution ??
Message has been deleted
Message has been deleted

Vishal Mishra

unread,
Mar 19, 2012, 1:15:41 AM3/19/12
to seleniu...@googlegroups.com
# Get execution delay in milliseconds, i.e. a pause delay following
      # each selenium operation. By default, there is no such delay
      # (value is 0).
      def execution_delay
        string_command "getSpeed"
      end

      # Set the execution delay in milliseconds, i.e. a pause delay following
      # each selenium operation. By default, there is no such delay.
      #
      # Setting an execution can be useful to troubleshoot or capture videos
      def execution_delay=(delay_in_milliseconds)
        remote_control_command "setSpeed", [delay_in_milliseconds]
      end
http://selenium.googlecode.com/svn/tags/selenium-2.20.0/rb/lib/selenium/client/idiomatic.rb

Brian Kitchener

unread,
Mar 19, 2012, 10:10:55 AM3/19/12
to seleniu...@googlegroups.com
It would be pretty easy to add something like that to a property.  

Let's suppose you have a variable holding the WebDriver Driver.  We want to add a half second (as an example) delay between each command fired with webdriver.  Make the WebDriver Driver a property, and add a Sleep() command in the get.  
You could obviously make this a variable in a config file so you could modify it. 
WebDriver _Driver;
WebDriver Driver 
get 
Thread.Sleep(500);
return _Driver
}
set
{
_Driver = value;
}
}

On Monday, November 21, 2011 8:40:36 AM UTC-7, chaoscifer wrote:
Hello,

could you try the selenium.setSpeed(String miliseconds)?

Hope it helps

2011/11/21 Arun Kumaresan <arunku...@gmail.com>
Hi,
I am using selenium 2.13.0.

How do I manage the execution speed.
I am not able to get the option of setting and getting speed of
execution using Webdriver object.

I tried the following code and couldnt get the method to set and get
speed.

WebDriver driver = new FirefoxDriver(firefoxProfile);
driver.manage().???

Can you pls help?

Regards,
Arun Kumaresan

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

Arun Kumaresan

unread,
Mar 19, 2012, 11:39:34 AM3/19/12
to seleniu...@googlegroups.com
Sorry, I couldnt find a solution so far.
I am just trying to make use of implicit and explicit wait where ever possible.

I wish the getSpeed and setSpeed gets implemented in the future.

On Fri, Jan 13, 2012 at 9:25 AM, Thomas Perraudin <goo...@perraudin.fr> wrote:
Arun, I have the same problem !
Have you found a solution ??

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/YumLy0fGA9IJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.



--
Regards,
Arun Kumaresan

Mark Collin

unread,
Jun 4, 2013, 5:03:30 AM6/4/13
to seleniu...@googlegroups.com
I guess the real questions is why are you trying to slow down execution speed?


On 03/06/2013 16:15, moiz virani wrote:
There is no straight forward way. But there is a hack that you can use, you can override methods of webdriver and introduce a explicit sleep to slow down your tests eg. overriding findElement method

public class _WebDriver extends FirefoxDriver {

@Override
public WebElement findElement(By by) {
    try {
        Thread.sleep(500);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return by.findElement((SearchContext) this);
}

}}
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

moiz virani

unread,
Jun 4, 2013, 10:40:59 AM6/4/13
to seleniu...@googlegroups.com
In theory selenium script should run immaterial of the speed of execution but when there is delay in display of dom(due to ajax or js) it becomes some time necessary to wait to make script efficient. Adding explicit wait should be more suitable.  

ballingam nalla

unread,
Oct 25, 2013, 5:41:17 AM10/25/13
to seleniu...@googlegroups.com
To decrease Execution speed of selenium web driver u can use Thread.sleep(milliseconds);  After Every Server Request. 

nikhilreddy...@gmail.com

unread,
Jun 8, 2018, 11:47:49 AM6/8/18
to Selenium Users
hi Arun,

even I am working on same stuff. please let me know if you get any solution for that. 
Reply all
Reply to author
Forward
0 new messages