Merge pull request #1841 from vramik/master
arquillian-testsuite: Customizable waiting timeouts in class WaitUtil…
This commit is contained in:
commit
261d32f8e7
2 changed files with 29 additions and 14 deletions
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package org.keycloak.testsuite.util;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import static org.jboss.arquillian.graphene.Graphene.waitAjax;
|
||||
|
@ -31,24 +32,35 @@ import org.openqa.selenium.WebElement;
|
|||
*/
|
||||
public final class WaitUtils {
|
||||
|
||||
public static final String PAGELOAD_TIMEOUT_PROP = "pageload.timeout";
|
||||
public static final String IMPLICIT_TIMEOUT_PROP = "implicit.timeout";
|
||||
public static final String SCRIPT_TIMEOUT_PROP = "script.timeout";
|
||||
public static final String POLLING_INTERVAL_PROP = "polling.interval";
|
||||
|
||||
public static final Integer PAGELOAD_TIMEOUT = Integer.parseInt(System.getProperty(PAGELOAD_TIMEOUT_PROP, "5000"));
|
||||
public static final Integer IMPLICIT_TIMEOUT = Integer.parseInt(System.getProperty(IMPLICIT_TIMEOUT_PROP, "3000"));
|
||||
public static final Integer SCRIPT_TIMEOUT = Integer.parseInt(System.getProperty(SCRIPT_TIMEOUT_PROP, "3000"));
|
||||
|
||||
public static final Integer POLLING_INTERVAL = Integer.parseInt(System.getProperty(POLLING_INTERVAL_PROP, "1000"));
|
||||
|
||||
public static void waitAjaxForElement(WebElement element) {
|
||||
waitAjax().until()
|
||||
.element(element).is().present();
|
||||
waitAjax().withTimeout(SCRIPT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until().element(element).is().present();
|
||||
}
|
||||
|
||||
public static void waitAjaxForElementNotPresent(WebElement element) {
|
||||
waitAjax().until()
|
||||
.element(element).is().not().present();
|
||||
waitAjax().withTimeout(SCRIPT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until().element(element).is().not().present();
|
||||
}
|
||||
|
||||
public static void waitAjaxForElementNotVisible(WebElement element) {
|
||||
waitAjax().until()
|
||||
.element(element).is().not().visible();
|
||||
waitAjax().withTimeout(SCRIPT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until().element(element).is().not().visible();
|
||||
}
|
||||
|
||||
public static void waitGuiForElement(By element, String message) {
|
||||
waitGui().until(message)
|
||||
.element(element).is().present();
|
||||
waitGui().withTimeout(IMPLICIT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until(message).element(element).is().present();
|
||||
}
|
||||
|
||||
public static void waitGuiForElement(By element) {
|
||||
|
@ -60,11 +72,13 @@ public final class WaitUtils {
|
|||
}
|
||||
|
||||
public static void waitGuiForElementPresent(WebElement element, String message) {
|
||||
waitGui().until(message).element(element).is().present();
|
||||
waitGui().withTimeout(IMPLICIT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until(message).element(element).is().present();
|
||||
}
|
||||
|
||||
public static void waitGuiForElementNotPresent(WebElement element) {
|
||||
waitGui().until().element(element).is().not().present();
|
||||
waitGui().withTimeout(IMPLICIT_TIMEOUT, TimeUnit.MILLISECONDS).pollingEvery(POLLING_INTERVAL, TimeUnit.MILLISECONDS)
|
||||
.until().element(element).is().not().present();
|
||||
}
|
||||
|
||||
public static void pause(long millis) {
|
||||
|
@ -74,5 +88,5 @@ public final class WaitUtils {
|
|||
Logger.getLogger(WaitUtils.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.keycloak.testsuite.auth.page.account.Account;
|
|||
import org.keycloak.testsuite.auth.page.login.OIDCLogin;
|
||||
import org.keycloak.testsuite.auth.page.login.UpdatePassword;
|
||||
import org.keycloak.testsuite.util.Timer;
|
||||
import org.keycloak.testsuite.util.WaitUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -116,9 +117,9 @@ public abstract class AbstractKeycloakTest {
|
|||
}
|
||||
|
||||
protected void driverSettings() {
|
||||
driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
|
||||
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
|
||||
driver.manage().timeouts().setScriptTimeout(3, TimeUnit.SECONDS);
|
||||
driver.manage().timeouts().pageLoadTimeout(WaitUtils.PAGELOAD_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
driver.manage().timeouts().implicitlyWait(WaitUtils.IMPLICIT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
driver.manage().timeouts().setScriptTimeout(WaitUtils.SCRIPT_TIMEOUT, TimeUnit.MILLISECONDS);
|
||||
driver.manage().window().maximize();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue