Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
padmajam@orioninc.com
Posts : 1
Join date : 2013-07-16

Is There any alternative for Thread.sleep? Empty Is There any alternative for Thread.sleep?

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
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO

Is There any alternative for Thread.sleep? Empty Re: Is There any alternative for Thread.sleep?

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");
    try
    {
        if (IsElementPresent(By.Id("link"))) break;
    }
    catch (Exception)
    {}
    Thread.Sleep(1000);
}
rohit13
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 37
Location : INDIA
http://radical-qa.blogspot.in/

Is There any alternative for Thread.sleep? Empty Re: Is There any alternative for Thread.sleep?

Mon Sep 16, 2013 7:16 pm
You can use implicit wait
       
Code:
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS );
avatar
akbbhatt
Posts : 1
Join date : 2013-09-18

Is There any alternative for Thread.sleep? Empty User webdriverwait

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: "docs.seleniumhq.org" search for "Explicit and Implicit Waits"

Regards,
Anil.
Sponsored content

Is There any alternative for Thread.sleep? Empty Re: Is There any alternative for Thread.sleep?

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