Search in sources :

Example 56 with WebElement

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

Example 57 with WebElement

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

Example 58 with WebElement

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

Example 59 with 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();
}
Also used : WebElement(org.openqa.selenium.WebElement)

Example 60 with WebElement

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

Aggregations

WebElement (org.openqa.selenium.WebElement)520 Test (org.junit.Test)96 WebDriver (org.openqa.selenium.WebDriver)85 PublicAtsApi (com.axway.ats.common.PublicAtsApi)57 Actions (org.openqa.selenium.interactions.Actions)55 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)46 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 By (org.openqa.selenium.By)36 URL (java.net.URL)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)34 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)30 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)21 NoSuchElementException (org.openqa.selenium.NoSuchElementException)21 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)19 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)13 Select (org.openqa.selenium.support.ui.Select)13 TimeoutException (org.openqa.selenium.TimeoutException)12 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)11 List (java.util.List)10