Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Regarding Alert Interface
Yesterday at 2:00 pm by karthikeyakumar

» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Is There any alternative for Thread.sleep?

View previous topic View next topic Go down

Is There any alternative for Thread.sleep?

Post by padmajam@orioninc.com 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

padmajam@orioninc.com

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");
    try
    {
        if (IsElementPresent(By.Id("link"))) break;
    }
    catch (Exception)
    {}
    Thread.Sleep(1000);
}

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
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
       
Code:
driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS );

_________________
Radical QA
http://radical-qa.blogspot.in/

rohit13
Master
Master

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

http://radical-qa.blogspot.in/

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

Regards,
Anil.

akbbhatt

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