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