Hey Eric, some of the drawbacks of using thread.sleep() command are:
-
If given a wait of 5000 Milliseconds(5 seconds) and an element just take just 1-2 seconds to load, script will still wait for another 3 seconds which is bad as it is unnecessarily increasing the execution time. So thread.sleep() increases the execution time in cases where elements are loaded in no due time.
-
When using Thread.sleep(), we have to mention wait time in advance, there is no guarantee that the element will be displayed in that specific wait time, there may be case when it will takes may be more than 5 seconds to load and again the script would fail.
-
You need to write sleep() method whenever we need to make webdriver wait. So if you want to wait for two web elements, you need to write Thread.sleep() twice just before you locate web elements.
-
It is not good programming practice. Instead you can use implicit or explicit waits.