setSpeed
: Set execution speed (i.e., set the millisecond length of a delay which will follow each selenium operation). By default, there is no such delay, i.e., the delay is 0 milliseconds.
Thread.sleep
: It causes the current thread to suspend execution for a specified period.
So the main difference between them is setSpeed
sets a speed while will apply delay time before every selenium operation takes place. But one thread.sleep()
will set up wait only for once. So, if we have 3 selenium operations written like below:
Opeartion 1
Opeartion 2
Opeartion 3
and we want to set a delay time 2000 for each of these, defining setSpeed()
method once will accomplish the task something like below:
selenium.setSpeed("2000");
Opeartion 1
Opeartion 2
Opeartion 3
But if we use Thread.sleep()
, it will be something like below:
Thread.sleep(2000);
Opeartion 1
Thread.sleep(2000);
Opeartion 2
Thread.sleep(2000);
Opeartion 3