use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BBBUtil method revokeApplicationsAccess.
public static void revokeApplicationsAccess(WebDriver webDriver) {
List<String> clientIds = new ArrayList<String>();
Properties prop = SystemPropertiesHelper.getProperties();
String clientId1 = prop.getProperty("org.orcid.web.testClient1.clientId");
if (!PojoUtil.isEmpty(clientId1)) {
clientIds.add(clientId1);
}
String clientId2 = prop.getProperty("org.orcid.web.testClient2.clientId");
if (!PojoUtil.isEmpty(clientId2)) {
clientIds.add(clientId2);
}
String userName = prop.getProperty("org.orcid.web.testUser1.username");
String password = prop.getProperty("org.orcid.web.testUser1.password");
String baseUrl = "https://localhost:8443/orcid-web";
if (!PojoUtil.isEmpty(prop.getProperty("org.orcid.web.baseUri"))) {
baseUrl = prop.getProperty("org.orcid.web.baseUri");
}
webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
webDriver.get(baseUrl + "/my-orcid");
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
SigninTest.signIn(webDriver, userName, password);
// Switch to accounts settings page
By accountSettingsMenuLink = By.id("accountSettingMenuLink");
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink), webDriver);
webDriver.get(baseUrl + "/account");
BBBUtil.extremeWaitFor(BBBUtil.documentReady(), webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
try {
boolean lookAgain = false;
do {
// Look for each revoke app button
By revokeAppBtn = By.id("revokeAppBtn");
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn);
boolean elementFound = false;
// client id
for (WebElement appElement : appsToRevoke) {
String nameAttribute = appElement.getAttribute("name");
if (clientIds.contains(nameAttribute)) {
BBBUtil.ngAwareClick(appElement, webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
// Wait for the revoke button
By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn");
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(confirmRevokeAppBtn), webDriver);
BBBUtil.ngAwareClick(webDriver.findElement(confirmRevokeAppBtn), webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
BBBUtil.noCboxOverlay(webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
// may need to put sleep back here
elementFound = true;
break;
}
}
if (elementFound) {
lookAgain = true;
} else {
lookAgain = false;
}
} while (lookAgain);
} catch (Exception e) {
// If it fail is because it couldn't find any other application
} finally {
logUserOut(baseUrl, webDriver);
}
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class OauthAuthorizationPageHelper method clickAuthorizeOnAuthorizeScreen.
private static void clickAuthorizeOnAuthorizeScreen(final WebDriver webDriver) {
By userIdElementLocator = By.id("authorize");
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
WebElement authorizeButton = webDriver.findElement(By.id("authorize"));
authorizeButton.click();
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals("ORCID Playground");
}
});
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class OauthAuthorizationPageHelper method loginAndAuthorize.
public static String loginAndAuthorize(String baseUrl, String clientId, String redirectUri, String scopes, String stateParam, String userId, String password, boolean longLife, Map<String, String> params, WebDriver webDriver) {
String formattedAuthorizationScreen = String.format(authorizationScreenUrl, baseUrl, clientId, scopes, redirectUri);
if (!PojoUtil.isEmpty(stateParam)) {
formattedAuthorizationScreen += "&state=" + stateParam;
}
if (params != null) {
for (String key : params.keySet()) {
formattedAuthorizationScreen += "&" + key + "=" + params.get(key);
}
}
formattedAuthorizationScreen += "#show_login";
webDriver.get(formattedAuthorizationScreen);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='userId']")), webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
By userIdElementLocator = By.id("userId");
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
WebElement userIdElement = webDriver.findElement(userIdElementLocator);
userIdElement.sendKeys(userId);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
WebElement passwordElement = webDriver.findElement(By.id("password"));
passwordElement.sendKeys(password);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
if (!longLife) {
// disablePersistentToken
WebElement persistentElement = webDriver.findElement(By.id("enablePersistentToken"));
if (persistentElement.isDisplayed()) {
if (persistentElement.isSelected()) {
BBBUtil.ngAwareClick(persistentElement, webDriver);
}
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
}
}
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("login-authorize-button")));
try {
BBBUtil.ngAwareClick(webDriver.findElement(By.id("login-authorize-button")), webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals("ORCID Playground");
}
});
} catch (TimeoutException e) {
//It might be the case that we are already in the ORCID Playground page, so, lets check for that case
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().equals("ORCID Playground");
}
});
}
return webDriver.getCurrentUrl();
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method changeKeywordsVisibility.
public static void changeKeywordsVisibility(Visibility visibility) {
int index = getPrivacyIndex(visibility);
String keywordsVisibilityXpath = "//div[@ng-repeat='keyword in keywordsForm.keywords']//ul[@class='privacyToggle']/li[" + index + "]";
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(keywordsVisibilityXpath)), webDriver);
List<WebElement> visibilityElements = webDriver.findElements(By.xpath(keywordsVisibilityXpath));
for (WebElement webElement : visibilityElements) {
BBBUtil.ngAwareClick(webElement, webDriver);
}
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method changeResearcherUrlsVisibility.
public static void changeResearcherUrlsVisibility(Visibility visibility) {
int index = getPrivacyIndex(visibility);
String researcherUrlsVisibilityXpath = "//div[@ng-repeat='website in websitesForm.websites']//ul[@class='privacyToggle']/li[" + index + "]";
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(researcherUrlsVisibilityXpath)), webDriver);
List<WebElement> visibilityElements = webDriver.findElements(By.xpath(researcherUrlsVisibilityXpath));
for (WebElement webElement : visibilityElements) {
BBBUtil.ngAwareClick(webElement, webDriver);
}
}
Aggregations