Refactor element identifiers from ID to class (#28690)

Closes #24462

Signed-off-by: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com>
This commit is contained in:
Dinesh Solanki 2024-05-07 17:26:21 +05:30 committed by GitHub
parent e23db5d0b5
commit 2172741eb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 13 deletions

View file

@ -37,17 +37,17 @@ import static org.keycloak.testsuite.util.UIUtils.getTextFromElementOrNull;
*/ */
public class WebAuthnAuthenticatorsList { public class WebAuthnAuthenticatorsList {
@FindBy(id = "kc-webauthn-authenticator") @FindBy(className = "kc-webauthn-authenticator")
private List<WebElement> authenticators; private List<WebElement> authenticators;
public List<WebAuthnAuthenticatorItem> getItems() { public List<WebAuthnAuthenticatorItem> getItems() {
try { try {
List<WebAuthnAuthenticatorItem> items = new ArrayList<>(); List<WebAuthnAuthenticatorItem> items = new ArrayList<>();
for (WebElement auth : authenticators) { for (WebElement auth : authenticators) {
String name = getTextFromElementOrNull(() -> auth.findElement(By.id("kc-webauthn-authenticator-label"))); String name = getTextFromElementOrNull(() -> auth.findElement(By.className("kc-webauthn-authenticator-label")));
String createdAt = getTextFromElementOrNull(() -> auth.findElement(By.id("kc-webauthn-authenticator-created"))); String createdAt = getTextFromElementOrNull(() -> auth.findElement(By.className("kc-webauthn-authenticator-created")));
String createdAtLabel = getTextFromElementOrNull(() -> auth.findElement(By.id("kc-webauthn-authenticator-created-label"))); String createdAtLabel = getTextFromElementOrNull(() -> auth.findElement(By.className("kc-webauthn-authenticator-created-label")));
String transport = getTextFromElementOrNull(() -> auth.findElement(By.id("kc-webauthn-authenticator-transport"))); String transport = getTextFromElementOrNull(() -> auth.findElement(By.className("kc-webauthn-authenticator-transport")));
items.add(new WebAuthnAuthenticatorItem(name, createdAt, createdAtLabel, transport)); items.add(new WebAuthnAuthenticatorItem(name, createdAt, createdAtLabel, transport));
} }
return items; return items;

View file

@ -35,7 +35,7 @@ public class WebAuthnLoginPage extends LanguageComboboxAwarePage {
@FindBy(id = "authenticateWebAuthnButton") @FindBy(id = "authenticateWebAuthnButton")
private WebElement authenticateButton; private WebElement authenticateButton;
@FindBy(id = "kc-webauthn-authenticator-label") @FindBy(className = "kc-webauthn-authenticator-label")
private List<WebElement> authenticatorsLabels; private List<WebElement> authenticatorsLabels;
@Page @Page

View file

@ -30,19 +30,19 @@
<div class="${properties.kcFormClass!}"> <div class="${properties.kcFormClass!}">
<#list authenticators.authenticators as authenticator> <#list authenticators.authenticators as authenticator>
<div id="kc-webauthn-authenticator" class="${properties.kcSelectAuthListItemClass!}"> <div class="kc-webauthn-authenticator ${properties.kcSelectAuthListItemClass!}">
<div class="${properties.kcSelectAuthListItemIconClass!}"> <div class="${properties.kcSelectAuthListItemIconClass!}">
<i class="${(properties['${authenticator.transports.iconClass}'])!'${properties.kcWebAuthnDefaultIcon!}'} ${properties.kcSelectAuthListItemIconPropertyClass!}"></i> <i class="${(properties['${authenticator.transports.iconClass}'])!'${properties.kcWebAuthnDefaultIcon!}'} ${properties.kcSelectAuthListItemIconPropertyClass!}"></i>
</div> </div>
<div class="${properties.kcSelectAuthListItemBodyClass!}"> <div class="${properties.kcSelectAuthListItemBodyClass!}">
<div id="kc-webauthn-authenticator-label" <div
class="${properties.kcSelectAuthListItemHeadingClass!}"> class=" kc-webauthn-authenticator-label ${properties.kcSelectAuthListItemHeadingClass!}">
${kcSanitize(msg('${authenticator.label}'))?no_esc} ${kcSanitize(msg('${authenticator.label}'))?no_esc}
</div> </div>
<#if authenticator.transports?? && authenticator.transports.displayNameProperties?has_content> <#if authenticator.transports?? && authenticator.transports.displayNameProperties?has_content>
<div id="kc-webauthn-authenticator-transport" <div
class="${properties.kcSelectAuthListItemDescriptionClass!}"> class="kc-webauthn-authenticator-transport ${properties.kcSelectAuthListItemDescriptionClass!}">
<#list authenticator.transports.displayNameProperties as nameProperty> <#list authenticator.transports.displayNameProperties as nameProperty>
<span>${kcSanitize(msg('${nameProperty!}'))?no_esc}</span> <span>${kcSanitize(msg('${nameProperty!}'))?no_esc}</span>
<#if nameProperty?has_next> <#if nameProperty?has_next>
@ -53,10 +53,10 @@
</#if> </#if>
<div class="${properties.kcSelectAuthListItemDescriptionClass!}"> <div class="${properties.kcSelectAuthListItemDescriptionClass!}">
<span id="kc-webauthn-authenticator-created-label"> <span class="kc-webauthn-authenticator-created-label">
${kcSanitize(msg('webauthn-createdAt-label'))?no_esc} ${kcSanitize(msg('webauthn-createdAt-label'))?no_esc}
</span> </span>
<span id="kc-webauthn-authenticator-created"> <span class="kc-webauthn-authenticator-created">
${kcSanitize(authenticator.createdAt)?no_esc} ${kcSanitize(authenticator.createdAt)?no_esc}
</span> </span>
</div> </div>