Example usage for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions elementToBeClickable.

Prototype

public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) 

Source Link

Document

An expectation for checking an element is visible and enabled such that you can click it.

Usage

From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java

License:LGPL

protected void checkClick(Element e, WebElement element) throws Exception {
    if (e.isClick() != null && e.isClick().booleanValue()) {
        if (e.isCheckNullElement()) {
            if (element != null) {
                WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30);
                wait.until(ExpectedConditions.elementToBeClickable(element));
                element.click();//  w w w . j a va  2s. c  om
            }
        } else {
            try {
                element = findElement(e.getFinds());
                WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30);
                wait.until(ExpectedConditions.elementToBeClickable(element));
                element.click();
            } catch (Exception e1) {
                logger.debug("element: " + element);
                logger.debug("element: " + e);
                throw e1;
            }
        }
    }
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void addFolder(String folderName) {
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.pagesCategory));
    this.displayPlus(this.pagesCategory);
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.pagesPlusIcon));
    this.pagesPlusIcon.click();
    this.addFolderLink.click();
    this.folderNameInput.sendKeys(folderName);
    this.addFolderButton.click();

    By menuElmt = By.cssSelector(".hierarchy-toggleFolder[data-space=\"" + folderName + "\"]");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void addPageInTestProjectSpace(String pageName, Integer isItem) {
    WebElement spaceElmt = getDriver()/*  w w  w .  jav  a  2s.  c om*/
            .findElementByCssSelector(".hierarchy-toggleFolder[data-space=\"TestProject\"]");
    WebElement plusElmt = getDriver()
            .findElementByXPath("//*[@id=\"hierarchyCategory_pages\"]/li[1]/div[1]/span");
    WebElement linkElmt = getDriver()
            .findElementByXPath("//*[@id=\"hierarchyCategory_pages\"]/li[1]/div[1]/ul/li/a");
    By menuElmt;
    this.openCategory("pages");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(spaceElmt));
    this.displayPlus(spaceElmt);
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(plusElmt));
    plusElmt.click();
    linkElmt.click();
    this.pageNameInput.sendKeys(pageName);
    if (isItem == 1) {
        getDriver().findElementByXPath("//*[@id=\"hierarchyAddPageTypeBlock\"]/label[2]").click();
        menuElmt = By.cssSelector(".editObject[data-page=\"" + pageName + "\"][data-space=\"TestProject\"]");
    } else {
        menuElmt = By.cssSelector(".editPage[data-page=\"" + pageName + "\"][data-space=\"TestProject\"]");
    }
    this.addPageButton.click();

    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void addExistingPage(String spaceName, String pageName) {
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.pagesCategory));
    this.displayPlus(this.pagesCategory);
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.pagesPlusIcon));
    this.pagesPlusIcon.click();
    this.addExistingPageLink.click();
    this.existingPageNameInput.sendKeys(spaceName + "." + pageName);
    this.addExistingPageButton.click();

    By menuElmt = By.cssSelector(".editPage[data-page=\"" + pageName + "\"][data-space=\"" + spaceName + "\"]");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void addClass(String className) throws InterruptedException {
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.classesCategory));
    this.displayPlus(this.classesCategory);
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.classesPlusIcon));
    this.classesPlusIcon.click();
    this.addClassLink.click();
    // TODO: remove next 2 lines when the "Add class" modal will have auto-focus
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(this.classNameInput));
    new Actions(getDriver()).moveToElement(classNameInput).click().perform();
    this.classNameInput.sendKeys(className);
    this.addClassButton.click();

    By menuElmt = By.cssSelector(".editAWM[data-page=\"" + className + "Class\"]");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void addGlobal(String category, String name) {
    WebElement plusIcon = getDriver().findElementByCssSelector("#hierarchyMainList > li:nth-child("
            + categoryNumber(category) + ") > div.btn-group.hierarchyAddNewElement > span");
    WebElement categoryElmt = getDriver()
            .findElementByCssSelector(".hierarchy-toggleCategory[data-category=\"" + category + "\"]");
    WebElement addElmtLink = getDriver().findElementByCssSelector("#hierarchyMainList > li:nth-child("
            + categoryNumber(category) + ") > div.btn-group.hierarchyAddNewElement > ul > li > a");
    WebElement addObjectInput = getDriver().findElementById("hierarchyObjectPageInput");
    WebElement addObjectButton = getDriver().findElementById("hierarchyAddObject");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(categoryElmt));
    this.displayPlus(categoryElmt);
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(plusIcon));
    plusIcon.click();//from w w  w.jav  a2 s  .  c o m
    addElmtLink.click();
    if (!category.equals("uix")) {
        addObjectInput.sendKeys(name);
    }
    addObjectButton.click();

    By menuElmt = By.cssSelector("#hierarchyCategory_" + category + " .wikiinternallink a");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void deletePage(String space, String name, String className, String category)
        throws InterruptedException {
    getDriver().manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
    if (!className.equals("")) {
        this.goToObject(space, name, className, category);
    } else {/*from   ww w .j a  v  a  2 s. c  o m*/
        this.goToPage(space, name);
    }
    WebElement wed = getDriver().findElementById("hierarchyDeleteButtonIDE");
    new WebDriverWait(getDriver(), 3).until(ExpectedConditions.elementToBeClickable(wed));
    wed.click();
    WebElement menuElmt;
    if (!className.equals("")) {
        this.deleteObjectButton.click();
        menuElmt = getDriver().findElement(By.cssSelector(".editObject[data-page=\"" + name
                + "\"][data-space=\"" + space + "\"][data-object=\"" + className + "\"]"));
    } else {
        this.deletePageButton.click();
        menuElmt = getDriver().findElement(
                By.cssSelector(".editPage[data-page=\"" + name + "\"][data-space=\"" + space + "\"]"));
    }
    new WebDriverWait(getDriver(), 3).until(ExpectedConditions.stalenessOf(menuElmt));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void editPage(String space, String name, String className, String category) throws InterruptedException {
    getDriver().manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
    if (!className.equals("")) {
        this.goToObject(space, name, className, category);
        WebElement textarea = getDriver().findElementByCssSelector("#tab_object_" + space + "_" + name + "_"
                + className.replace(".", "2E") + "_0 .editorCodeField > textarea");
        new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(textarea));
        new Actions(getDriver()).moveToElement(textarea).click().perform();
        textarea.clear();//  ww  w .j  a v  a 2  s .  c o  m
        textarea.sendKeys("New content of the page, edited by the functional tests.");
    } else {
        this.goToPage(space, name);
        WebElement textarea = getDriver()
                .findElementById("content_tab_wiki_" + space + "_" + name + "_default");
        new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(textarea));
        new Actions(getDriver()).moveToElement(textarea).click().perform();
        textarea.clear();
        textarea.sendKeys("New content of the page, edited by the functional tests.");
    }
    WebElement wes = getDriver().findElementById("hierarchySaveViewButtonIDE");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wes));
    wes.click();

    WebElement oldPageElmt = getDriver().findElement(By.id("editorBlock"));
    new WebDriverWait(getDriver(), 3).until(ExpectedConditions.stalenessOf(oldPageElmt));
    By pageElmt = By.id("xwikicontent");
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.presenceOfElementLocated(pageElmt));
    String textContent;
    if (!className.equals("")) {
        getUtil().gotoPage(space, name, "edit", "editor=object");
        textContent = getDriver().findElementById(className + "_0_code").getText();
    } else {
        textContent = getDriver().findElementByCssSelector("#xwikicontent > p").getText();
    }
    Assert.assertTrue(textContent.equals("New content of the page, edited by the functional tests."));
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void goToPage(String space, String page) throws InterruptedException {
    this.openCategory("pages");
    this.openSpace(space);
    WebElement wep = getDriver()//ww w  . j  a  v a 2 s  . c om
            .findElement(By.cssSelector(".editPage[data-page=\"" + page + "\"][data-space=\"" + space + "\"]"));
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wep));
    wep.click();
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

public void goToObject(String space, String page, String className, String category)
        throws InterruptedException {
    this.openCategory(category);
    if ("pages".equals(category))
        this.openSpace(space);
    WebElement weo = getDriver().findElement(By.cssSelector(".editObject[data-page=\"" + page
            + "\"][data-space=\"" + space + "\"][data-object=\"" + className + "\"]"));
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(weo));
    weo.click();//  w  w  w .  ja va  2 s. c  o  m
}