Tuesday 7 January 2014

difference between thread. Sleep () and selenium. Set Speed ("2000")

       What is the difference between thread. Sleep () and selenium. Set Speed ("2000")?

If the application is taking time to load the page then we use selenium.waitforpageload(" "). This command is doesn’t wait upto the given time whenever the page load is completed.
If the application is taking time to refresh the page, then we use Thread. Sleep ( ).it is a standard wait it simply wait to the given time.
selenium.setSpeed
 1. Takes a single argument in string format
 Ex: selenium.setSpeed("2000") - will wait for 2 seconds
 2. Runs each command in after setSpeed delay by the number of milliseconds mentioned in set Speed.
 thread.sleep
 1. Takes a single argument in integer format
 ex: thread. Sleep(2000) - will wait for 2 seconds
 2. Waits for only once at the command given at sleep.



9 comments:

  1. Where we need to set this?
    within a Test ? / Class ? / ?????

    ReplyDelete
    Replies
    1. set in the metod which is inside the class

      Delete
  2. Is this "Sleep" or "Speed"?

    ReplyDelete
    Replies
    1. these are both Sleep is the method which is used to keep delay the process

      and

      speed same as sleep but in selenium you are using setSpeed(integer value)
      to execute your script as fast or slow depends on your given value
      1sec =1000

      Delete
  3. setSpeed() command is not available in WebDriver, Alternate always we can use Implicit and explicit waits.

    Note: check in selenium IDE, we can use setSpeed method

    ReplyDelete
    Replies
    1. so you can use Thread.sleep("integer value") this also same as setSpeed Method

      Delete
  4. Sol : of Amit: SET in the method which is inside the class

    ReplyDelete
  5. While doing refreshing the page i prefer thread.sleep(),
    But regularly i am using implicit wait only
    Is thsi correct way?

    Thanks
    Swathi bommavaram

    ReplyDelete