如何使用JAVA添加时间延迟

时间:2017-09-07 10:06:52

标签: java automated-tests

我试图在导航到Facebook后插入5/10秒的时间延迟,但这不起作用:

public FacebookLoginPage clickSignInWithFacebook() {
        WebElement facebookBtn = waitForElementDisplay(loginPageObjects.signInWithFacebookBtn);
        facebookBtn.click();
        TimeUnit.SECONDS.sleep(5);
        return FacebookLoginPage.getInstance();

1 个答案:

答案 0 :(得分:0)

https://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html

Thread.sleep(milliseconds);

所以对你的情况来说:

Thread.sleep(5000);