Skip to content

Commit 7a886aa

Browse files
rmartincmposolda
authored andcommitted
Use sendKeys instead of click for the webauthn tests
Closes #33362 Closes #33037 Closes #32548 Signed-off-by: rmartinc <[email protected]>
1 parent 54b6cd6 commit 7a886aa

File tree

4 files changed

+29
-6
lines changed

4 files changed

+29
-6
lines changed

testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.keycloak.testsuite.util.OAuthClient;
2525
import org.keycloak.testsuite.util.WaitUtils;
2626
import org.openqa.selenium.By;
27+
import org.openqa.selenium.Keys;
2728
import org.openqa.selenium.NoSuchElementException;
2829
import org.openqa.selenium.WebElement;
2930
import org.openqa.selenium.chrome.ChromeDriver;
@@ -216,8 +217,7 @@ public void assertCurrent(String realm) {
216217
}
217218

218219
public void clickRegister() {
219-
registerLink.click();
220-
WaitUtils.waitForPageToLoad();
220+
clickLink(registerLink);
221221
}
222222

223223
public void clickSocial(String alias) {

testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/pages/LoginTotpPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private By getXPathForLookupCardWithName(String credentialName) {
129129
public void selectOtpCredential(String credentialName) {
130130
WebElement webElement = driver.findElement(
131131
getXPathForLookupCardWithName(credentialName));
132-
UIUtils.clickLink(webElement);
132+
UIUtils.click(webElement);
133133
}
134134

135135

testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/UIUtils.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.openqa.selenium.WebDriver;
1111
import org.openqa.selenium.WebElement;
1212
import org.openqa.selenium.firefox.FirefoxDriver;
13-
import org.openqa.selenium.interactions.Actions;
1413
import org.openqa.selenium.support.ui.ExpectedConditions;
1514
import org.openqa.selenium.support.ui.Select;
1615
import org.openqa.selenium.support.ui.WebDriverWait;
@@ -69,11 +68,35 @@ public static void refreshPageAndWaitForLoad() {
6968
performOperationWithPageReload(() -> getCurrentDriver().navigate().refresh());
7069
}
7170

71+
/**
72+
* The method executes click or sendKeys(Keys.ENTER) in the element.
73+
* In the chrome driver click is emulated by pressing the ENTER key. Since
74+
* the upgrade to chrome 128 some clicks are missed and that triggers CI
75+
* failures. The method is intended to be used for buttons and links which
76+
* accept clicking by pressing the ENTER key. If the element passed does
77+
* not allow clicking using keys use the {@link #click(WebElement) click}
78+
* method.
79+
*
80+
* @param element The element to click
81+
*/
7282
public static void clickLink(WebElement element) {
7383
WebDriver driver = getCurrentDriver();
7484

7585
waitUntilElement(element).is().clickable();
7686

87+
performOperationWithPageReload(BrowserDriverUtil.isDriverChrome(driver)
88+
? () -> element.sendKeys(Keys.ENTER)
89+
: element::click);
90+
}
91+
92+
/**
93+
* The method executes click in the element. This method always uses click and
94+
* is not emulated by key pressing in chrome.
95+
*
96+
* @param element The element to click
97+
*/
98+
public static void click(WebElement element) {
99+
waitUntilElement(element).is().clickable();
77100
performOperationWithPageReload(element::click);
78101
}
79102

testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/webauthn/pages/fragments/AbstractHeader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.openqa.selenium.WebElement;
2121

2222
import static org.junit.Assert.assertEquals;
23-
import static org.keycloak.testsuite.util.UIUtils.clickLink;
23+
import static org.keycloak.testsuite.util.UIUtils.click;
2424
import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
2525
import static org.keycloak.testsuite.util.UIUtils.isElementVisible;
2626

@@ -49,7 +49,7 @@ public void assertLogoutBtnVisible(boolean expected) {
4949

5050
protected void clickToolsBtn(WebElement btn) {
5151
clickOptions();
52-
clickLink(btn);
52+
click(btn);
5353
}
5454

5555
protected boolean isToolsBtnVisible(WebElement btn) {

0 commit comments

Comments
 (0)