What are the drawbacks of using thread sleep command in Selenium Webdriver

0 votes
What are the drawbacks of using thread.sleep() command in Selenium Webdriver?
Jul 4, 2019 in Selenium by Eric
11,707 views

1 answer to this question.

+1 vote

Hey Eric, some of the drawbacks of using thread.sleep() command are:

  1. 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.

  2. 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.

  3. 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.

  4.  It is not good programming practice. Instead you can use implicit or explicit waits.

answered Jul 5, 2019 by Abha
• 28,140 points

Related Questions In Selenium

0 votes
1 answer

What is Xpath and what are the types of it in Selenium Webdriver?

Hi Piyush, XPath is defined as XML path. It is ...READ MORE

answered May 9, 2019 in Selenium by Pratibha
• 3,690 points
5,377 views
0 votes
1 answer

What are the different types of TestNG listeners in Selenium Webdriver?

Hello Jagrati, some of the TestNG listeners ...READ MORE

answered Jun 12, 2019 in Selenium by Anvi
• 14,150 points
1,817 views
0 votes
1 answer

What are the main types of regex quantifiers used in Selenium Webdriver?

Hi Andrew, some of the regex quantifiers ...READ MORE

answered Jun 26, 2019 in Selenium by Abha
• 28,140 points
5,616 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,687 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,150 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,230 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,881 views
0 votes
1 answer

What are some of the browser commands used in Selenium Webdriver?

Hi Nakul, some of the most frequently ...READ MORE

answered May 14, 2019 in Selenium by Abha
• 28,140 points
808 views
0 votes
1 answer

What are the main disadvantages of using implicit wait in Selenium?

Hey Aaron, the main disadvantage of implicit ...READ MORE

answered Jun 1, 2019 in Selenium by Abha
• 28,140 points
8,442 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP