use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class AddWorksTest method addSimple.
public static void addSimple(String workName, WebDriver webDriver) {
WebDriverWait wait = new WebDriverWait(webDriver, 10);
waitWorksLoaded(wait, webDriver);
BBBUtil.noSpinners(webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
// Selenium is having issues finding this element, I supect do to CSS transformations
// Run the function directly
((JavascriptExecutor) webDriver).executeScript("angular.element('[ng-controller=WorkCtrl]').scope().addWorkModal()");
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//select[@ng-model='editWork.workCategory.value']")), webDriver);
BBBUtil.ngAwareSendKeys("conference", "workCategory", webDriver);
BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//option[text()='Conference paper']")), webDriver);
BBBUtil.ngAwareSendKeys("string:conference-abstract", "workType", webDriver);
//Pick the identifier type from the list
BBBUtil.extremeWaitFor(ExpectedConditions.elementToBeClickable(By.id("worksIdType0")), webDriver);
WebElement input = findElement(By.id("worksIdType0"));
input.sendKeys("doi");
BBBUtil.extremeWaitFor(ExpectedConditions.elementToBeClickable(By.xpath("//a[starts-with(@title,\"doi\")]")), webDriver);
((JavascriptExecutor) webDriver).executeScript("$(\"a:contains('doi:')\").click()");
//Set other identifier attributes
BBBUtil.ngAwareSendKeys("10.10/" + System.currentTimeMillis(), "worksIdValue0", webDriver);
BBBUtil.ngAwareSendKeys(workName, "work-title", webDriver);
//wait for angular to register that values have been typed.
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
BBBUtil.ngAwareClick(webDriver.findElement(By.xpath("//button[@id='save-new-work']")), webDriver);
SigninTest.colorBoxIsClosed(wait);
waitWorksLoaded(wait, webDriver);
BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName)), webDriver);
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class AddWorksTest method deleteAllByWorkName.
public static void deleteAllByWorkName(String workName, WebDriver webDriver) {
WebDriverWait wait = new WebDriverWait(webDriver, 10);
waitWorksLoaded(wait, webDriver);
BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
List<WebElement> wList = webDriver.findElements(By.xpath("//*[@orcid-put-code and descendant::span[text() = '" + workName + "']]"));
if (wList.size() > 0)
for (WebElement we : wList) {
String putCode = we.getAttribute("orcid-put-code");
putCode = "" + putCode;
String deleteJsStr = "angular.element(document.body).injector().get('worksSrvc').deleteWork('" + putCode + "');";
((JavascriptExecutor) webDriver).executeScript(deleteJsStr);
waitWorksLoaded(wait, webDriver);
}
BBBUtil.extremeWaitFor(ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName))), webDriver);
assertTrue(0 == webDriver.findElements(byWorkTitle(workName)).size());
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class LocalXPath method waitToBeClickable.
public WebElement waitToBeClickable(String xpath) {
By by = By.xpath(xpath);
WebElement webElement = baseElement.findElement(by);
return webElement;
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class LocalXPath method click.
public void click(String xpath) {
WebElement webElement = waitToBeClickable(xpath);
webElement.click();
}
use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.
the class XPath method click.
public void click(String xpath) {
WebElement webElement = waitToBeClickable(xpath);
webElement.click();
}
Aggregations