Search in sources :

Example 6 with JavascriptExecutor

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);
    }
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Example 7 with JavascriptExecutor

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);
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Example 8 with JavascriptExecutor

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();
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor)

Example 9 with JavascriptExecutor

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);
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement)

Example 10 with JavascriptExecutor

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 };
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) ArrayList(java.util.ArrayList) Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension)

Aggregations

JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)40 WebElement (org.openqa.selenium.WebElement)20 PublicAtsApi (com.axway.ats.common.PublicAtsApi)9 WebDriver (org.openqa.selenium.WebDriver)7 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)4 ChromeDriver (org.openqa.selenium.chrome.ChromeDriver)4 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)3 Test (org.junit.Test)3 Dimension (org.openqa.selenium.Dimension)3 RemoteWebElement (org.openqa.selenium.remote.RemoteWebElement)3 Select (org.openqa.selenium.support.ui.Select)3 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)2 MobileDriver (com.axway.ats.uiengine.MobileDriver)1 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)1 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)1 MobileElementState (com.axway.ats.uiengine.utilities.mobile.MobileElementState)1 SafeJavascriptWait (com.github.timurstrekalov.saga.core.webdriver.SafeJavascriptWait)1