KEYCLOAK-7805 Fix PayPal and Bitbucket Social Login tests

This commit is contained in:
vmuzikar 2018-07-10 16:07:55 +02:00 committed by Pavel Drozd
parent 4a82979792
commit 0432a566dd
2 changed files with 35 additions and 6 deletions

View file

@ -18,25 +18,40 @@
package org.keycloak.testsuite.pages.social;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.keycloak.testsuite.util.UIUtils.clickLink;
import static org.keycloak.testsuite.util.WaitUtils.pause;
/**
* @author Vaclav Muzikar <vmuzikar@redhat.com>
*/
public class BitbucketLoginPage extends AbstractSocialLoginPage {
@FindBy(name = "username")
@FindBy(id = "username")
private WebElement usernameInput;
@FindBy(name = "password")
@FindBy(id = "password")
private WebElement passwordInput;
@FindBy(name = "commit")
private WebElement loginButton;
@FindBy(xpath = "//div[contains(@class,'additional-auths')]/p/a")
private WebElement loginWithAtlassianButton;
@Override
public void login(String user, String password) {
try {
clickLink(loginWithAtlassianButton); // BitBucket no longer has it's own login page yet sometimes it's
// displayed even though we need to use the Atlassian login page
}
catch (NoSuchElementException e) {
log.info("Already on Atlassian login page");
}
usernameInput.sendKeys(user);
usernameInput.sendKeys(Keys.RETURN);
pause(1000);
passwordInput.sendKeys(password);
passwordInput.sendKeys(Keys.RETURN);
}

View file

@ -21,6 +21,8 @@ import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import static org.keycloak.testsuite.util.UIUtils.clickLink;
/**
* @author Petter Lysne (petterlysne at hotmail dot com)
*/
@ -34,6 +36,9 @@ public class PayPalLoginPage extends AbstractSocialLoginPage {
@FindBy(name = "btnLogin")
private WebElement loginButton;
@FindBy(name = "btnNext")
private WebElement nextButton;
@FindBy(name = "continueLogin")
private WebElement continueLoginButton;
@ -42,11 +47,20 @@ public class PayPalLoginPage extends AbstractSocialLoginPage {
try {
usernameInput.clear(); // to remove pre-filled email
usernameInput.sendKeys(user);
try {
clickLink(nextButton); // sometimes the login process is just a one step,
// sometimes it's two steps so we need to click the 'Next' button
}
catch (NoSuchElementException e) {
// one step login process, no need to click the 'Next' button
}
passwordInput.sendKeys(password);
loginButton.click();
clickLink(loginButton);
}
catch (NoSuchElementException e) {
continueLoginButton.click(); // already logged in, just need to confirm it
clickLink(continueLoginButton); // already logged in, just need to confirm it
}
}
}