+
Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void clickConfirmAction() {
}

public boolean isErrorMessageDisplayed() {
return driver.findElements(By.cssSelector(".alert-error")).size() == 1;
return driver.findElements(By.cssSelector(".pf-v5-c-alert")).size() == 1;
}

public String getErrorMessageText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@
*/
public class FeedbackMessage {

private final String SUCCESS = "success";
private final String WARNING = "warning";
private final String ERROR = "error";
private final String INFO = "info";

@FindBy(css = "div[class^='alert']")
private final static String SUCCESS = "success";
private final static String WARNING = "warning";
private final static String ERROR = "danger";
private final static String INFO = "info";

private static final Pattern ALERT_TYPE_CLASS_PATTERN = Pattern.compile("(pf-m|alert)-("
+ SUCCESS + "|"
+ WARNING + "|"
+ ERROR + "|"
+ INFO
+ ")");

@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert']")
private WebElement alertRoot;

@FindBy(css = "span[id^='input-error']")
Expand Down Expand Up @@ -71,7 +78,7 @@ public String getText() {
public String getType() {
try {
String cssClass = alertRoot.getAttribute("class");
Matcher classMatcher = Pattern.compile("alert-(.+)").matcher(cssClass);
Matcher classMatcher = ALERT_TYPE_CLASS_PATTERN.matcher(cssClass);
if (!classMatcher.find()) {
throw new RuntimeException("Failed to identify feedback message type");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OneTimeCode extends Authenticate {
@FindBy(xpath = ".//label[@for='otp']")
private WebElement otpInputLabel;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginErrorMessage;

@FindBy(id = "input-error-otp-code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class LoginPasswordUpdatePage {
@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginErrorMessage;

public void changePassword(String newPassword, String passwordConfirm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class IdpConfirmLinkPage extends LanguageComboboxAwarePage {
@FindBy(id = "linkAccount")
private WebElement linkAccountButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement message;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class IdpConfirmOverrideLinkPage extends LanguageComboboxAwarePage {
@FindBy(id = "confirmOverride")
private WebElement confirmOverrideButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement message;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class InstalledAppRedirectPage extends AbstractPage {
@FindBy(id = "kc-page-title")
private WebElement pageTitle;

@FindBy(className = "alert-error")
@FindBy(className = "pf-v5-c-alert")
private WebElement errorBox;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import org.junit.Assert;
import org.keycloak.testsuite.util.DroneUtils;
import org.keycloak.testsuite.util.WaitUtils;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
Expand All @@ -33,12 +37,18 @@
*/
public abstract class LanguageComboboxAwarePage extends AbstractPage {

@FindBy(id = "kc-current-locale-link")
@FindBy(xpath = "//select[@aria-label='languages']/option[@selected]")
private WebElement languageText;

@FindBy(id = "kc-locale-dropdown")
@FindBy(xpath = "//select[@aria-label='languages']")
private WebElement localeDropdown;

@FindBy(id = "kc-current-locale-link")
private WebElement languageTextBase; // base theme

@FindBy(id = "kc-locale-dropdown")
private WebElement localeDropdownBase; // base theme

@FindBy(id = "try-another-way")
private WebElement tryAnotherWayLink;

Expand All @@ -52,13 +62,26 @@ public abstract class LanguageComboboxAwarePage extends AbstractPage {
private WebElement accountLink;

public String getLanguageDropdownText() {
return languageText.getText();
try {
final String text = languageText.getText();
return text == null ? text : text.trim();
} catch (NoSuchElementException ex) {
return languageTextBase.getText();
}
}

public void openLanguage(String language){
WebElement langLink = localeDropdown.findElement(By.xpath("//a[text()[contains(.,'" + language + "')]]"));
String url = langLink.getAttribute("href");
DroneUtils.getCurrentDriver().navigate().to(url);
try {
WebElement langLink = localeDropdown.findElement(By.xpath("//option[text()[contains(.,'" + language + "')]]"));
String url = langLink.getAttribute("value");
DroneUtils.getCurrentDriver().navigate().to(new URI(DroneUtils.getCurrentDriver().getCurrentUrl()).resolve(url).toString());
} catch (NoSuchElementException ex) {
WebElement langLink = localeDropdownBase.findElement(By.xpath("//a[text()[contains(.,'" + language + "')]]"));
String url = langLink.getAttribute("href");
DroneUtils.getCurrentDriver().navigate().to(url);
} catch (URISyntaxException ex) {
Assert.fail(ex.getMessage());
}
WaitUtils.waitForPageToLoad();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class LoginConfigTotpPage extends LogoutSessionsPage {
@FindBy(id = "mode-manual")
private WebElement manualLink;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginAlertErrorMessage;

@FindBy(id = "input-error-otp-code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public class LoginPage extends LanguageComboboxAwarePage {
@FindBy(linkText = "Forgot Password?")
private WebElement resetPasswordLink;

@FindBy(className = "alert-error")
@FindBy(className = "pf-m-danger")
private WebElement loginErrorMessage;

@FindBy(className = "alert-success")
@FindBy(className = "pf-m-success")
private WebElement loginSuccessMessage;

@FindBy(className = "alert-info")
@FindBy(className = "pf-m-info")
private WebElement loginInfoMessage;

@FindBy(className = "instruction")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public class LoginPasswordResetPage extends LanguageComboboxAwarePage {
@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-success")
@FindBy(className = "pf-v5-c-success")
private WebElement emailSuccessMessage;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement emailErrorMessage;

@FindBy(partialLinkText = "Back to Login")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LoginPasswordUpdatePage extends LogoutSessionsPage {
@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginErrorMessage;

@FindBy(className = "kc-feedback-text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class LoginTotpPage extends LanguageComboboxAwarePage {
@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginErrorMessage;

@FindBy(id = "input-error-otp-code")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public class LoginUpdateProfilePage extends AbstractPage {
@Page
private UpdateProfileErrors errorsPage;

@FindBy(id = "firstName")
@FindBy(name = "firstName")
private WebElement firstNameInput;

@FindBy(id = "lastName")
@FindBy(name = "lastName")
private WebElement lastNameInput;

@FindBy(id = "email")
@FindBy(name = "email")
private WebElement emailInput;

@FindBy(id = "department")
@FindBy(name = "department")
private WebElement departmentInput;

@FindBy(css = "input[type=\"submit\"]")
Expand All @@ -58,7 +58,7 @@ public class LoginUpdateProfilePage extends AbstractPage {
@FindBy(name = "cancel-aia")
private WebElement cancelAIAButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginAlertErrorMessage;

public void update(String firstName, String lastName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class OAuth2DeviceVerificationPage extends LanguageComboboxAwarePage {
@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(className = "pf-v5-c-alert")
private WebElement verifyErrorMessage;

public void submit(String userCode) {
Expand Down Expand Up @@ -108,7 +108,7 @@ private boolean isInvalidUserCodePage() {
try {
driver.findElement(By.id("device-user-code"));
return driver.findElement(By.id("kc-page-title")).getText().equals("Device Login")
&& driver.findElement(By.className("kc-feedback-text")).getText().equals("Invalid code, please try again.");
&& driver.findElement(By.className("pf-m-danger")).getText().equals("Invalid code, please try again.");
} catch (Throwable t) {
}
}
Expand All @@ -120,7 +120,7 @@ private boolean isExpiredUserCodePage() {
try {
driver.findElement(By.id("device-user-code"));
return driver.findElement(By.id("kc-page-title")).getText().equals("Device Login")
&& driver.findElement(By.className("kc-feedback-text")).getText().equals("The code has expired. Please go back to your device and try connecting again.");
&& driver.findElement(By.className("pf-m-danger")).getText().equals("The code has expired. Please go back to your device and try connecting again.");
} catch (Throwable t) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class PasswordPage extends LanguageComboboxAwarePage {
@FindBy(name = "login")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginErrorMessage;

@FindBy(linkText = "Forgot Password?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@ public class RegisterPage extends AbstractPage {
@Page
private PasswordFields.PasswordErrors passwordErrors;

@FindBy(id = "firstName")
@FindBy(name = "firstName")
private WebElement firstNameInput;

@FindBy(id = "lastName")
@FindBy(name = "lastName")
private WebElement lastNameInput;

@FindBy(id = "email")
@FindBy(name = "email")
private WebElement emailInput;

@FindBy(id = "username")
@FindBy(name = "username")
private WebElement usernameInput;

@FindBy(id = "password")
@FindBy(name = "password")
private WebElement passwordInput;

@FindBy(id = "password-confirm")
@FindBy(name = "password-confirm")
private WebElement passwordConfirmInput;

@FindBy(id = "department")
@FindBy(name = "department")
private WebElement departmentInput;

@FindBy(id = "termsAccepted")
@FindBy(name = "termsAccepted")
private WebElement termsAcceptedInput;

@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginAlertErrorMessage;

@FindBy(className = "instruction")
Expand Down Expand Up @@ -136,7 +136,7 @@ public void register(String firstName, String lastName, String email, String use

if (attributes != null) {
for (Entry<String, String> attribute : attributes.entrySet()) {
driver.findElement(By.id(Constants.USER_ATTRIBUTES_PREFIX + attribute.getKey())).sendKeys(attribute.getValue());
driver.findElement(By.name(Constants.USER_ATTRIBUTES_PREFIX + attribute.getKey())).sendKeys(attribute.getValue());
}
}

Expand Down Expand Up @@ -238,7 +238,7 @@ public boolean isDepartmentEnabled() {

public boolean isDepartmentPresent() {
try {
return driver.findElement(By.id("department")).isDisplayed();
return driver.findElement(By.name("department")).isDisplayed();
} catch (NoSuchElementException nse) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@

public class UpdateAccountInformationPage extends LanguageComboboxAwarePage {

@FindBy(id = "username")
@FindBy(name = "username")
private WebElement usernameInput;

@FindBy(id = "email")
@FindBy(name = "email")
private WebElement emailInput;

@FindBy(id = "firstName")
@FindBy(name = "firstName")
private WebElement firstNameInput;

@FindBy(id = "lastName")
@FindBy(name = "lastName")
private WebElement lastNameInput;

@FindBy(id = "department")
@FindBy(name = "department")
private WebElement departmentInput;

@FindBy(css = "input[type=\"submit\"]")
Expand Down Expand Up @@ -106,7 +106,7 @@ public String getLabelForField(String fieldId) {

public boolean isDepartmentPresent() {
try {
return driver.findElement(By.id("department")).isDisplayed();
return driver.findElement(By.name("department")).isDisplayed();
} catch (NoSuchElementException nse) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ public class VerifyProfilePage extends AbstractPage {
@Page
private AccountFields.AccountErrors accountErrors;

@FindBy(id = "firstName")
@FindBy(name = "firstName")
private WebElement firstNameInput;

@FindBy(id = "lastName")
@FindBy(name = "lastName")
private WebElement lastNameInput;

@FindBy(id = "email")
@FindBy(name = "email")
private WebElement emailInput;

@FindBy(id = "department")
@FindBy(name = "department")
private WebElement departmentInput;


@FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton;

@FindBy(className = "alert-error")
@FindBy(css = "div[class^='pf-v5-c-alert'], div[class^='alert-error']")
private WebElement loginAlertErrorMessage;


Expand Down
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载