Display results as :

Rechercher Advanced Search

Latest topics
» Selenium WebDriver Integration
Yesterday at 1:06 pm by azharuddin

» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce


Is There any alternative for Thread.sleep?

View previous topic View next topic Go down

Is There any alternative for Thread.sleep?

Post by on Tue Jul 16, 2013 8:05 pm

I have 2 drop down. By selecting one value from the first drop down, second drop down value will be populated.
Here I have to put a Thread.sleep(2000) after selecting value from first drop down other wise it is throwing exception for not getting the id of second drop down.
Is there any alternative for Thread.sleep here. 
Note: Its not a page load event

Posts : 1
Join date : 2013-07-16

Back to top Go down

Re: Is There any alternative for Thread.sleep?

Post by ccox on Sat Jul 20, 2013 1:56 am

I know it still uses Sleep, but you could do a waitForElementPresent command.  This will check if the element is there every second for 60 seconds.  

 for (int second = 0;; second++) {
    if (second >= 60) Assert.Fail("timeout");
        if (IsElementPresent(By.Id("link"))) break;
    catch (Exception)


Posts : 205
Join date : 2012-01-06
Age : 32
Location : Denver, CO

Back to top Go down

Re: Is There any alternative for Thread.sleep?

Post by rohit13 on Mon Sep 16, 2013 7:16 pm

You can use implicit wait
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS );

Radical QA

Posts : 180
Join date : 2012-03-29
Age : 31
Location : INDIA

Back to top Go down

User webdriverwait

Post by akbbhatt on Wed Sep 18, 2013 3:07 pm

I would go with explicit wait approach here. You can explicitly wait till an element is present using WebDriverWait class. 
For more info check this documentation tab at: "" search for "Explicit and Implicit Waits"



Posts : 1
Join date : 2013-09-18

Back to top Go down

Re: Is There any alternative for Thread.sleep?

Post by Sponsored content

Sponsored content

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum