use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method createEducation.
public static void createEducation(String institutionName) {
String institutionNameXpath = "//input[@ng-model='editAffiliation.affiliationName.value']";
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(institutionNameXpath)), webDriver);
BBBUtil.ngAwareSendKeys(institutionName, "affiliationName", webDriver);
String cityXpath = "//input[@ng-model='editAffiliation.city.value']";
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(cityXpath)), webDriver);
BBBUtil.ngAwareSendKeys("Test land", "city", webDriver);
String countryXpath = "//select[@ng-model='editAffiliation.country.value']";
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(countryXpath)), webDriver);
WebElement countryInput = findElement(By.xpath(countryXpath));
Select input = new Select(countryInput);
input.selectByValue(Iso3166Country.US.value());
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
((JavascriptExecutor) webDriver).executeScript("$('#save-affiliation').click();");
BBBUtil.noCboxOverlay(webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method createAddress.
public static void createAddress(String countryCode) {
By addNew = By.xpath("//a[@ng-click='addNewModal()']/span");
waitForElementVisibility(addNew);
waitForAngular();
ngAwareClick(findElement(addNew));
waitForAngular();
By emptyInput = By.xpath("(//select[@ng-model='country.iso2Country.value'])[last()]//option[@value = " + Quotes.escape(countryCode) + "]");
waitForElementVisibility(emptyInput);
WebElement countryElement = findElement(emptyInput);
BBBUtil.ngAwareClick(countryElement, webDriver);
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method changeAddressVisibility.
public static void changeAddressVisibility(Visibility visibility) {
int index = getPrivacyIndex(visibility);
String countriesVisibilityXpath = "//div[@ng-repeat='country in countryForm.addresses']//descendant::div[@id='privacy-bar']/ul/li[" + index + "]/a";
BBBUtil.extremeWaitFor(ExpectedConditions.elementToBeClickable(By.xpath(countriesVisibilityXpath)), webDriver);
List<WebElement> visibilityElements = webDriver.findElements(By.xpath(countriesVisibilityXpath));
for (WebElement webElement : visibilityElements) {
BBBUtil.ngAwareClick(webElement, webDriver);
}
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method adminUnlockAccount.
public void adminUnlockAccount(String adminUserName, String adminPassword, String orcidToUnlock) {
// Login Admin
adminSignIn(adminUserName, adminPassword);
try {
// Unlock the account
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='unlockProfileDiv']/p[1]/a[2]")));
BBBUtil.ngAwareClick(webDriver.findElement(By.xpath("//div[@id='unlockProfileDiv']/p[1]/a[2]")), webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
WebElement unLockProfileOrcidId = webDriver.findElement(By.id("orcid_to_unlock"));
unLockProfileOrcidId.sendKeys(orcidToUnlock);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("bottom-confirm-unlock-profile")));
BBBUtil.ngAwareClick(webDriver.findElement(By.id("bottom-confirm-unlock-profile")), webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("btn-unlock")));
BBBUtil.ngAwareClick(webDriver.findElement(By.id("btn-unlock")), webDriver);
(new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
} catch (TimeoutException t) {
//Account might be already unlocked
}
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class BlackBoxBase method deleteEducation.
public static void deleteEducation(String institutionName) {
By byInstitutionName = By.xpath("//span[@ng-bind-html='group.getActive().affiliationName.value' and text()='" + institutionName + "']");
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@id='workspace-publications' and @orcid-loaded='true']")), webDriver);
List<WebElement> wList = webDriver.findElements(By.xpath("//*[@education-put-code and descendant::span[text() = '" + institutionName + "']]"));
if (wList.size() > 0)
for (WebElement we : wList) {
String putCode = we.getAttribute("education-put-code");
putCode = "" + putCode;
String deleteJsStr = "angular.element(document.body).injector().get('affiliationsSrvc').deleteAffiliation({'putCode': {'value': '" + putCode + "'},'affiliationType': {'value': 'education'}});";
((JavascriptExecutor) webDriver).executeScript(deleteJsStr);
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@id='workspace-publications' and @orcid-loaded='true']")), webDriver);
}
BBBUtil.extremeWaitFor(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(byInstitutionName)), webDriver);
assertTrue(0 == webDriver.findElements(byInstitutionName).size());
}
Aggregations