-2

In my program, I try to find a css address then I do some other computations. I need to execute the next line of my code if FolderTest1 is null.

WebElement FolderTest1 = driverChrome.findElement(By.cssSelector("#nav-51846c7840975f97241367"));
driverChrome.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);

Thanks

beresfordt
  • 5,088
  • 10
  • 35
  • 43
Hoomii
  • 1
  • 1
    Your question is confusing, but to answer your *title*, yes, just put `try { Thread.sleep(10000); } catch (InterruptedException e1) { e1.printStackTrace(); }` before the line. – Shashank Mar 18 '15 at 21:08
  • 1
    possible duplicate of [How can I delay a Java program for a few seconds?](http://stackoverflow.com/questions/3342651/how-can-i-delay-a-java-program-for-a-few-seconds) – Artemis Mar 18 '15 at 21:11

1 Answers1

0

Something like this?

WebElement FolderTest1 = driverChrome.findElement(By.cssSelector("#nav-51846c7840975f97241367"));
if(FolderTest1 == null)
{
    try
    {
        Thread.sleep(10000);
    }
    catch(InterruptedException ie)
    {}    
} 
preston.m.price
  • 646
  • 1
  • 10
  • 17
  • no. In first line, if the program couldn't find the css address it does not do anything!! – Hoomii Mar 18 '15 at 21:38
  • I mean, I want to execute the rest of the code after 10 seconds, with or without finding css address. – Hoomii Mar 18 '15 at 21:39