Home > Back-end >  How can I make my Java application wait a time before process the next line?
How can I make my Java application wait a time before process the next line?

Time:07-26

Im making a Selenium automation and I already tried this but no success:

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

and

TimeUnit.SECONDS.sleep(2);

and

driver.wait(2000);

CodePudding user response:

You can use this code:

Code:

System.out.println( "Hello" );

try{
    Thread.sleep( 1000 );
    System.out.println( "sleep 1 second" );
}catch( InterruptedException e ){
    throw new RuntimeException( e );
}

System.out.println( "World" );

Output:

Hello
sleep 1 second
World

Let me know if it helped.

CodePudding user response:

In Katalon you can use:

WebUI.delay(GlobalVariable.DELAY_1_SECONDS)

In Sellenium you can use:

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

Or:

WebDriverWait wait = new WebDriverWait(driver,30);

You can find more example in this post of Sadhvi Singh.

  • Related