8000 WIP [#29298] Arquillian Drone removal (dependencies, parameters, drivers,annotations, code), setup new WebDriver Lifecycle (browser management). by lhanusov · Pull Request #29305 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
8000
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions misc/keycloak-test-helper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
16 changes: 1 addition & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
<jmeter.version>2.10</jmeter.version>
<junit.version>4.13.2</junit.version>
<picketlink.version>2.7.0.Final</picketlink.version>
<selenium.version>2.35.0</selenium.version>
<selenium.version>4.20.0</selenium.version>
<!-- Needs to be aligned with Quarkus, see e.g. https://github.com/quarkusio/quarkus-quickstarts/blob/2.13.5.Final/getting-started-async/pom.xml#L14 -->
<surefire-plugin.version>3.0.0-M7</surefire-plugin.version>
<xml-apis.version>1.4.01</xml-apis.version>
Expand Down Expand Up @@ -699,20 +699,6 @@
<artifactId>api-ldap-codec-standalone</artifactId>
<version>${apacheds.codec.version}</version>
</dependency>

<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_java</artifactId>
Expand Down
26 changes: 3 additions & 23 deletions testsuite/integration-arquillian/HOW-TO-RUN.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ mvn -f testsuite/integration-arquillian/tests/other/pom.xml clean test \
If you try to run WebAuthn tests with Chrome browser and you see error like:

```
Caused by: java.lang.RuntimeException: Unable to instantiate Drone via org.openqa.selenium.chrome.ChromeDriver(Capabilities):
Caused by: java.lang.RuntimeException: Unable to instantiate WebDriver via org.openqa.selenium.chrome.ChromeDriver(Capabilities):
org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 78
```

Expand Down Expand Up @@ -441,29 +441,9 @@ Although technically they can be run with almost every test in the testsuite, th
* **Driver download required:** [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) that corresponds with your version of the browser
* **Run with:** `-Dbrowser=chrome -Dwebdriver.chrome.driver=path/to/chromedriver`

#### [DEPRECATED] Mozilla Firefox with legacy driver
* **Supported test modules:** `console`
* **Supported version:** [52 ESR](http://ftp.mozilla.org/pub/firefox/releases/52.9.0esr/) ([Extended Support Release](https://www.mozilla.org/en-US/firefox/organizations/))
* **Driver download required:** no
* **Run with:** `-Dbrowser=firefox -DfirefoxLegacyDriver=true -Dfirefox_binary=path/to/firefox-52-esr/binary`

#### Automatic driver downloads
You can rely on automatic driver downloads which is provided by [Arquillian Drone](http://arquillian.org/arquillian-extension-drone/#_automatic_download). To do so just omit the `-Dwebdriver.{browser}.driver` CLI argument when running the tests.
By default latest driver version is always downloaded. To download a specific version, add `-DfirefoxDriverVersion` or `-DchromeDriverVersion` CLI argument.

#### Mobile browsers
The support for testing with the mobile browsers is implemented using the [Appium](http://appium.io/) project.
This means the tests can be run with a real mobile browser in a real mobile OS. However, only emulators/simulators of mobile devices are supported at the moment (no physical devices) in our testsuite.

First, you need to install the Appium server. If you have Node.js and npm installed on your machine, you can do that with: `npm install -g appium`. For further details and requirements please refer to the [official Appium documentation](http://appium.io/docs/en/about-appium/intro/).
The tests will try to start the Appium server automatically but you can do it manually as well (just by executing `appium`).

To use a mobile browser you need to create a virtual device. The most convenient way to do so is to install the desired platform's IDE - either [Android Studio](https://developer.android.com/studio/) (for Android devices) or [Xcode](https://developer.apple.com/xcode/) (for iOS devices) - then you can create a device (smartphone/tablet) there. For details please refer to documentation of those IDEs.

**Tips & tricks:**
* If the AVD name contains any spaces, you need to replace them with underscores when specifying the `-Dappium.avd=...`.
* It's probable that a freshly created device will contain an outdated Chrome version. To update to the latest version (without using the Play Store) you need to download an `.apk` for Chrome and install it with `adb install -r path/to/chrome.apk`.
* Chrome on Android uses ChromeDriver similarly to regular desktop Chrome. The ChromeDriver is bundled with the Appium server. To use a newer ChromeDriver please follow the [Appium documentation](http://appium.io/docs/en/writing-running-appium/web/chromedriver/).
You can rely on automatic driver downloads which is provided by [Selenium WebDriver Manager](https://www.selenium.dev/documentation/selenium_manager/).
The latest driver version is always downloaded by default. To download a specific version, add `-DbrowserVersion` CLI argument.

## Disabling TLS (SSL) in the tests

Expand Down
4 changes: 2 additions & 2 deletions testsuite/integration-arquillian/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ and the URL hierarchy is modeled by the class inheritance hierarchy (subclasses/
### Browsers

The default browser for UI testing is `htmlunit` which is used for fast "headless" testing.
Other browsers can be selected with the `-Dbrowser` property, for example `firefox`.
See [HOW-TO-RUN.md](HOW-TO-RUN.md) and Arquillian Drone documentation for more details.
Other browsers can be selected with the `-Dbrowser` property, for example `chrome` or `firefox`.
See [HOW-TO-RUN.md](HOW-TO-RUN.md) and Selenium WebDriver documentation for more details.

### Utils classes
UI testing is sometimes very tricky due to different demands and behaviours of different browsers and their drivers. So there are some very useful Utils classes which are already dealing with some common stability issues while testing. See `UIUtils`, `URLUtils` and `WaitUtils` classes in the Base Testsuite.
Expand Down
54 changes: 3 additions & 51 deletions testsuite/integration-arquillian/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
<arquillian-core.version>1.8.0.Final</arquillian-core.version>
<!--the version of shrinkwrap_resolver should align with the version in arquillian-bom-->
<shrinkwrap-resolver.version>3.2.1</shrinkwrap-resolver.version>
<selenium.version>3.14.0</selenium.version>
<arquillian-drone.version>2.5.5</arquillian-drone.version>
<selenium.version>4.20.0</selenium.version>
<arquillian-graphene.version>3.0.0-alpha.3</arquillian-graphene.version>
<arquillian-wildfly-container.version>3.0.1.Final</arquillian-wildfly-container.version>
<arquillian-wls-container.version>1.0.1.Final</arquillian-wls-container.version>
Expand All @@ -57,7 +56,6 @@
<undertow.version>${undertow-jakarta.version}</undertow.version>
<undertow-embedded.version>1.0.0.Final</undertow-embedded.version>
<version.org.wildfly.extras.creaper>1.6.1</version.org.wildfly.extras.creaper>
<appium.client.version>6.1.0</appium.client.version>
<jakarta.persistence-legacy.version>2.2.3</jakarta.persistence-legacy.version>
<smallrye.jandex.version>3.0.5</smallrye.jandex.version>

Expand Down Expand Up @@ -93,41 +91,22 @@
<scope>import</scope>
</dependency>

<!-- Selenium Server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>${selenium.version}</version>
</dependency>

<!-- Selenium dependencies -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-leg-rc</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>lift</artifactId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>

<!-- Drivers -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
Expand All @@ -140,27 +119,7 @@
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-ie-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-edge-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-safari-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-opera-driver</artifactId>
<artifactId>htmlunit3-driver</artifactId>
<version>${selenium.version}</version>
</dependency>

Expand All @@ -178,13 +137,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-drone-bom</artifactId>
<version>${arquillian-drone.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.infinispan.arquillian.container</groupId>
<artifactId>infinispan-arquillian-impl</artifactId>
Expand Down
12 changes: 12 additions & 0 deletions testsuite/integration-arquillian/tests/base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit3-driver</artifactId>
<version>${selenium.version}</version>
</dependency>

<!-- FIXME: Override in order to prevent NoClassDefFoundError: org/jboss/threads/AsyncFuture in ClientContainerController -->
<dependency>
<groupId>org.jboss.threads</groupId>
Expand All @@ -208,6 +214,12 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.8.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.openqa.selenium.support.FindBy;

import jakarta.ws.rs.core.UriBuilder;
import org.keycloak.testsuite.util.JavascriptBrowser;

import static org.keycloak.testsuite.util.WaitUtils.waitUntilElement;

Expand All @@ -28,12 +27,10 @@ public UriBuilder createUriBuilder() {

// First variant for Fuse 7.1, 7.2, the second variant for Fuse 7.3
@FindBy(xpath = "//a[@id ='userDropdownMenu'] | //button[@id ='userDropdownMenu']")
@JavascriptBrowser
private WebElement dropDownMenu;

// First variant for Fuse 7.1, 7.2, the second variant for Fuse 7.3
@FindBy(xpath = "//a[@ng-click='userDetails.logout()'] | //a[@ng-focus='authService.logout()']")
@JavascriptBrowser
private WebElement logoutButton;

public void logout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.openqa.selenium.support.FindBy;

import jakarta.ws.rs.core.UriBuilder;
import org.keycloak.testsuite.util.JavascriptBrowser;

import java.util.concurrent.TimeUnit;

Expand All @@ -34,15 +33,12 @@ public UriBuilder createUriBuilder() {
}

@FindBy(xpath = "//a[@class='dropdown-toggle' and @data-original-title='Preferences and log out']")
@JavascriptBrowser
private WebElement dropDownMenu;

@FindBy(xpath = "//a[@ng-click='logout()']")
@JavascriptBrowser
private WebElement logoutButton;

@FindBy(xpath = "//input[@type='submit' and @value='Yes']")
@JavascriptBrowser
private WebElement modal;

public void logout(WebDriver jsDriver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.net.MalformedURLException;
import java.net.URL;
import org.keycloak.tes 10BC8 tsuite.util.DroneUtils;
import org.keycloak.testsuite.util.WebDriverUtils;

/**
*
Expand Down Expand Up @@ -55,7 +55,7 @@ public URL getInjectedUrl() {
public void navigateTo() {
super.navigateTo();

if (DroneUtils.getCurrentDriver().getPageSource().contains("<html><head></head><body></body></html>")) {
if (WebDriverUtils.getCurrentDriver().getPageSource().contains("<html><head></head><body></body></html>")) {
log.debug("Page wasn't properly loaded - redirecting.");
super.navigateTo();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
import org.keycloak.testsuite.arquillian.provider.SuiteContextProvider;
import org.keycloak.testsuite.arquillian.provider.TestContextProvider;
import org.keycloak.testsuite.arquillian.provider.URLProvider;
import org.keycloak.testsuite.drone.HtmlUnitScreenshots;
import org.keycloak.testsuite.drone.KeycloakDronePostSetup;
import org.keycloak.testsuite.drone.KeycloakWebDriverConfigurator;
import org.keycloak.testsuite.utils.arquillian.fuse.KeycloakOSGiApplicationArchiveProcessor;

/**
Expand Down Expand Up @@ -81,13 +78,6 @@ public void register(ExtensionBuilder builder) {
.override(ResourceProvider.class, CustomizableURLResourceProvider.class, URLProvider.class)
.override(ApplicationArchiveProcessor.class, OSGiApplicationArchiveProcessor.class, KeycloakOSGiApplicationArchiveProcessor.class)
.override(ResourceProvider.class, ContainerCustomizableURLResourceProvider.class, URLProvider.class);

builder
.observer(KeycloakWebDriverConfigurator.class)
.observer(HtmlUnitScreenshots.class)
.observer(KeycloakDronePostSetup.class);


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import org.keycloak.common.util.CollectionUtil;
import org.keycloak.models.AuthenticatedClientSessionModel;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.WebDriverUtils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand Down Expand Up @@ -58,9 +58,9 @@ public void cancel() {
}

public boolean isCurrent(WebDriver driver1) {
DroneUtils.addWebDriver(driver1);
WebDriverUtils.addWebDriver(driver1);
boolean ret = super.isCurrent();
DroneUtils.removeWebDriver();
WebDriverUtils.removeWebDriver();
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.keycloak.testsuite.auth.page.login;

import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.WebDriverUtils;

/**
*
Expand All @@ -36,7 +36,7 @@ public boolean isCurrent() {
}

public boolean isCurrent(String realm) {
return DroneUtils.getCurrentDriver().getTitle().equals("Sign in to " + realm) || DroneUtils.getCurrentDriver().getTitle().equals("Anmeldung bei " + realm);
return WebDriverUtils.getCurrentDriver().getTitle().equals("Sign in to " + realm) || WebDriverUtils.getCurrentDriver().getTitle().equals("Anmeldung bei " + realm);
}

}
Loading
0