Improve a11y by providing the current language (#20213)
This commit is contained in:
parent
8aeee928e8
commit
403632438a
4 changed files with 20 additions and 5 deletions
|
@ -38,6 +38,9 @@ public class LoginPage extends LanguageComboboxAwarePage {
|
|||
@ArquillianResource
|
||||
protected OAuthClient oauth;
|
||||
|
||||
@FindBy(xpath = "//html")
|
||||
protected WebElement htmlRoot;
|
||||
|
||||
@FindBy(id = "username")
|
||||
protected WebElement usernameInput;
|
||||
|
||||
|
@ -68,7 +71,6 @@ public class LoginPage extends LanguageComboboxAwarePage {
|
|||
@FindBy(className = "alert-success")
|
||||
private WebElement loginSuccessMessage;
|
||||
|
||||
|
||||
@FindBy(className = "alert-info")
|
||||
private WebElement loginInfoMessage;
|
||||
|
||||
|
@ -109,12 +111,15 @@ public class LoginPage extends LanguageComboboxAwarePage {
|
|||
usernameInput.sendKeys(username);
|
||||
passwordInput.clear();
|
||||
clickLink(submitButton);
|
||||
|
||||
}
|
||||
|
||||
public void missingUsername() {
|
||||
clearUsernameInputAndWaitIfNecessary();
|
||||
clickLink(submitButton);
|
||||
}
|
||||
|
||||
public String getHtmlLanguage() {
|
||||
return htmlRoot.getAttribute("lang");
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
|
@ -168,6 +173,7 @@ public class LoginPage extends LanguageComboboxAwarePage {
|
|||
public String getSuccessMessage() {
|
||||
return loginSuccessMessage != null ? loginSuccessMessage.getText() : null;
|
||||
}
|
||||
|
||||
public String getInfoMessage() {
|
||||
try {
|
||||
return getTextFromElement(loginInfoMessage);
|
||||
|
@ -176,7 +182,6 @@ public class LoginPage extends LanguageComboboxAwarePage {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean isCurrent() {
|
||||
String realm = "test";
|
||||
return isCurrent(realm);
|
||||
|
|
|
@ -120,6 +120,16 @@ public class LoginPageTest extends AbstractI18NTest {
|
|||
assertEquals("Deutsch", loginPage.getLanguageDropdownText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void htmlLangAttribute() {
|
||||
loginPage.open();
|
||||
assertEquals("en", loginPage.getHtmlLanguage());
|
||||
|
||||
oauth.uiLocales("de");
|
||||
loginPage.open();
|
||||
assertEquals("de", loginPage.getHtmlLanguage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void acceptLanguageHeader() throws IOException {
|
||||
try(CloseableHttpClient httpClient = (CloseableHttpClient) new HttpClientBuilder().build()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<#macro mainLayout active bodyClass>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<html<#if realm.internationalizationEnabled> lang="${locale.currentLanguageTag}"</#if>>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<#macro registrationLayout bodyClass="" displayInfo=false displayMessage=true displayRequiredFields=false>
|
||||
<!DOCTYPE html>
|
||||
<html class="${properties.kcHtmlClass!}">
|
||||
<html class="${properties.kcHtmlClass!}"<#if realm.internationalizationEnabled> lang="${locale.currentLanguageTag}"</#if>>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
|
Loading…
Reference in a new issue