Implicitlywait command issue

Hi Lakshay,

I have added implicitlyWaiwait after success full login, but it is not waiting for 30seconds it is directly clicking on logout. This is code ( from your website ). Is this the wrong way to add implicitlyWaiwait command. Please suggest me.

driver.findElement(By.id("pwd")).sendKeys("Test@123");
// Now submit the form. WebDriver will find the form for us from the element

driver.findElement(By.id("login")).click();
// Print a Log In message to the screen

System.out.println(" Login Successfully, now it is the time to Log Off buddy after 30 seconds.");
// Find the element that's ID attribute is 'account_logout' (Log Out)

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

driver.findElement (By.xpath(".//*[@id='account_logout']/a")).click();
// Close the driver

driver.quit();

}

}
Train Asked on August 26, 2014 in Selenium WebDriver.
Add Comment
  • 6 Answer(s)

    Hi Ravi,

    Both of the above two chaps are correct about Implicit Wait  and Thread Sleep. But still if you want to know more about wait commands and different wait, you can follow the link:

    http://www.toolsqa.com/selenium-webdriver/wait-commands/

    Regards,
    Lakshay Sharma

    Professor Answered on August 26, 2014.
    Add Comment

    Hi ravipatil,

    You can give thread sleep command. It will delay the execution for certain seconds. The syntax for thread sleep is Thread.sleep(any number). It will take the numbers in milli seconds. In your case, for 30 seconds you can specify as Thread.sleep(30000L);. I think it may help you.

    Regards,
    Vaidy

    Doctor Answered on August 26, 2014.
    Add Comment

    Hi Ravipatil

    implicitlyWait(30, TimeUnit.SECONDS);

    In Case of this it Will Wait Maximum 30 seconds for elements
    but if Element is Found Before that 30-second Duration it will Perform Operation on that

    But if Element is not Found in 30 sec it will throw a Element not Found Exception After 30 sec

    I hope this is Clear to You

    Thanx
    Ankit

    Vice Professor Answered on August 26, 2014.
    Add Comment

    Thanks all for support.

    Train Answered on August 26, 2014.

    Hi ravi,

    Dont forget to mark the question as ANSWERED.

    Regards,
    Vaidy

    on August 26, 2014.
    Add Comment

    Hi Vaid,

    Thread.sleep(30000L); is not accepting. It is throwing thread cannot be resolved.  

    Train Answered on August 26, 2014.

    I think it is Thread.sleep(30000);

    on August 26, 2014.
    Add Comment

    Hi Lakshay,

    I tried it is not working.

    Train Answered on August 26, 2014.

    hi ravi

    Do  you Have “throws Exception”  After Name of Your Method..?

    on August 26, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.