Modify LoginPage.login() to work with old and new login screens
Merging and closing, thanks .
* Make login work with both versions of the classic Login page
* Put the newer version at the top. Add comment to clarify.
* Remove some extra whitespace
@@ -24,7 +24,16 @@ public class LoginPage implements WebDriverMixin {
open();
find("#j_username").sendKeys(admin.username);
find("input[name=j_password]").sendKeys(admin.password);
+ // JENKINS-50477 introduced a new login screen, which was released in core 2.128.
+ // This allows us to log in with both login screens - starting with the new style.
+ if (find("input[name=Submit]").isPresent()) {
+ logger.info("Logging in via post-2.128 style log in page");
+ find("input[name=Submit]").click();
+ } else {
+ logger.info("Logging in via pre-2.128 style log in page");
find("//button[contains(text(), 'log')]").click();
+ }
+
find("//a[contains(@href, 'logout')]").isDisplayed();
logger.info("Logged in as " + admin.username);
}
