use of org.openqa.selenium.JavascriptExecutor in project ORCID-Source by ORCID.
the class SigninTest method dismissVerifyEmailModal.
public static void dismissVerifyEmailModal(WebDriver webDriver) {
WebDriverWait wait = new WebDriverWait(webDriver, 10);
List<WebElement> weList = webDriver.findElements(By.xpath("//div[@ng-controller='VerifyEmailCtrl']"));
if (weList.size() > 0) {
// we need to wait for the color box to appear
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[@ng-controller='VerifyEmailCtrl' and @orcid-loading='false']")));
((JavascriptExecutor) webDriver).executeScript("$.colorbox.close();");
colorBoxIsClosed(wait);
}
}
use of org.openqa.selenium.JavascriptExecutor 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.JavascriptExecutor in project ORCID-Source by ORCID.
the class BBBUtil method executeJavaScript.
public static String executeJavaScript(String javaScript, WebElement webElement, WebDriver driver) {
JavascriptExecutor je = (JavascriptExecutor) driver;
Object result = je.executeScript(javaScript, webElement);
return result == null ? null : result.toString();
}
use of org.openqa.selenium.JavascriptExecutor 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.JavascriptExecutor in project selenium-tests by Wikia.
the class Shooter method getBoundingClientRect.
private Object[] getBoundingClientRect(WebElement element, WebDriver driver) {
JavascriptExecutor js = (JavascriptExecutor) driver;
ArrayList<String> list = (ArrayList<String>) js.executeScript("var rect = arguments[0].getBoundingClientRect();" + "return [ '' + parseInt(rect.left), '' + parseInt(rect.top), '' + parseInt(rect.width), '' + parseInt(rect.height) ]", element);
Point start = new Point(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1)));
Dimension size = new Dimension(Integer.parseInt(list.get(2)), Integer.parseInt(list.get(3)));
return new Object[] { start, size };
}
Aggregations