Testsuite PoC - Add support for html unit (#32338)
* Testsuite PoC - Add support for html unit Signed-off-by: stianst <stianst@gmail.com> * Update test-poc/framework/src/main/java/org/keycloak/test/framework/config/Config.java Signed-off-by: Stian Thorgersen <stian@redhat.com> --------- Signed-off-by: stianst <stianst@gmail.com> Signed-off-by: Stian Thorgersen <stian@redhat.com>
This commit is contained in:
parent
c18a79bfe7
commit
4450e0e455
9 changed files with 46 additions and 10 deletions
|
@ -32,7 +32,8 @@
|
|||
<description>PoC JUnit 5 testing framework for Keycloak</description>
|
||||
|
||||
<properties>
|
||||
<selenium.version>4.21.0</selenium.version>
|
||||
<selenium.version>4.23.1</selenium.version>
|
||||
<selenium.html.unit.version>4.23.0</selenium.html.unit.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -66,6 +67,11 @@
|
|||
<version>${selenium.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>htmlunit3-driver</artifactId>
|
||||
<version>${selenium.html.unit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testcontainers</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
|
|
|
@ -18,7 +18,7 @@ public class Config {
|
|||
}
|
||||
|
||||
public static String getAdminClientId() {
|
||||
return "admin";
|
||||
return "temp-admin";
|
||||
}
|
||||
|
||||
public static String getAdminClientSecret() {
|
||||
|
|
|
@ -5,11 +5,13 @@ import org.keycloak.test.framework.injection.InstanceContext;
|
|||
import org.keycloak.test.framework.injection.LifeCycle;
|
||||
import org.keycloak.test.framework.injection.RequestedInstance;
|
||||
import org.keycloak.test.framework.injection.Supplier;
|
||||
import org.openqa.selenium.MutableCapabilities;
|
||||
import org.openqa.selenium.PageLoadStrategy;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.remote.AbstractDriverOptions;
|
||||
import org.openqa.selenium.remote.CapabilityType;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractWebDriverSupplier implements Supplier<WebDriver, InjectWebDriver> {
|
||||
|
||||
|
@ -45,9 +47,9 @@ public abstract class AbstractWebDriverSupplier implements Supplier<WebDriver, I
|
|||
|
||||
public abstract WebDriver getWebDriver();
|
||||
|
||||
public void setGlobalOptions(AbstractDriverOptions<?> options) {
|
||||
options.setImplicitWaitTimeout(Duration.ofSeconds(5));
|
||||
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
|
||||
public void setCommonCapabilities(MutableCapabilities capabilities) {
|
||||
capabilities.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, PageLoadStrategy.NORMAL.toString());
|
||||
capabilities.setCapability("timeouts", Map.of("implicit", Duration.ofSeconds(5).toMillis()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class ChromeHeadlessWebDriverSupplier extends AbstractWebDriverSupplier {
|
|||
@Override
|
||||
public WebDriver getWebDriver() {
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
setGlobalOptions(options);
|
||||
setCommonCapabilities(options);
|
||||
options.addArguments(
|
||||
"--headless",
|
||||
"--disable-gpu",
|
||||
|
|
|
@ -14,7 +14,7 @@ public class ChromeWebDriverSupplier extends AbstractWebDriverSupplier {
|
|||
@Override
|
||||
public WebDriver getWebDriver() {
|
||||
ChromeOptions options = new ChromeOptions();
|
||||
setGlobalOptions(options);
|
||||
setCommonCapabilities(options);
|
||||
return new ChromeDriver(options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class FirefoxHeadlessWebDriverSupplier extends AbstractWebDriverSupplier
|
|||
@Override
|
||||
public WebDriver getWebDriver() {
|
||||
FirefoxOptions options = new FirefoxOptions();
|
||||
setGlobalOptions(options);
|
||||
setCommonCapabilities(options);
|
||||
options.addArguments("-headless");
|
||||
return new FirefoxDriver(options);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class FirefoxWebDriverSupplier extends AbstractWebDriverSupplier {
|
|||
@Override
|
||||
public WebDriver getWebDriver() {
|
||||
FirefoxOptions options = new FirefoxOptions();
|
||||
setGlobalOptions(options);
|
||||
setCommonCapabilities(options);
|
||||
return new FirefoxDriver(options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.keycloak.test.framework.webdriver;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
|
||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||
|
||||
public class HtmlUnitWebDriverSupplier extends AbstractWebDriverSupplier {
|
||||
|
||||
@Override
|
||||
public String getAlias() {
|
||||
return "htmlunit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebDriver getWebDriver() {
|
||||
DesiredCapabilities capabilities = new DesiredCapabilities();
|
||||
setCommonCapabilities(capabilities);
|
||||
|
||||
capabilities.setBrowserName("htmlunit");
|
||||
capabilities.setCapability(HtmlUnitDriver.DOWNLOAD_IMAGES_CAPABILITY, false);
|
||||
capabilities.setCapability(HtmlUnitDriver.JAVASCRIPT_ENABLED, true);
|
||||
|
||||
HtmlUnitDriver driver = new HtmlUnitDriver(capabilities);
|
||||
driver.getWebClient().getOptions().setCssEnabled(false);
|
||||
return driver;
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ org.keycloak.test.framework.realm.UserSupplier
|
|||
org.keycloak.test.framework.server.DistributionKeycloakTestServerSupplier
|
||||
org.keycloak.test.framework.server.EmbeddedKeycloakTestServerSupplier
|
||||
org.keycloak.test.framework.server.RemoteKeycloakTestServerSupplier
|
||||
org.keycloak.test.framework.webdriver.HtmlUnitWebDriverSupplier
|
||||
org.keycloak.test.framework.webdriver.ChromeHeadlessWebDriverSupplier
|
||||
org.keycloak.test.framework.webdriver.ChromeWebDriverSupplier
|
||||
org.keycloak.test.framework.webdriver.FirefoxHeadlessWebDriverSupplier
|
||||
|
|
Loading…
Reference in a new issue