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.opennms.smoketest.ProvisioningNewUIIT.java

License:Open Source License

/**
 * Test requisition UI.//from   ww w  .  jav a2s  .com
 *
 * @throws Exception the exception
 */
@Test
public void testRequisitionUI() throws Exception {
    setImplicitWait(2, TimeUnit.SECONDS);

    // Add a new requisition
    clickId("add-requisition", false);
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.cssSelector("form.bootbox-form > input.bootbox-input")));
    enterText(By.cssSelector("form.bootbox-form > input.bootbox-input"), REQUISITION_NAME);
    findElementByXpath("//div/button[text()='OK']").click();
    wait.until(
            ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='" + REQUISITION_NAME + "']")));

    // Edit the foreign source
    final String editForeignSourceButton = "button.btn[uib-tooltip='Edit detectors and policies of the "
            + REQUISITION_NAME + " Requisition']";
    wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(editForeignSourceButton))).click();
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("ul.nav-tabs > li > a.nav-link")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//h4[text()='Foreign Source Definition for Requisition " + REQUISITION_NAME + "']")));

    // Add a detector
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("add-detector")));
    clickId("add-detector", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form[name='detectorForm']")));
    enterText(By.xpath("//form[@name='detectorForm']//input[@ng-model='detector.name']"), NODE_SERVICE);
    enterText(By.xpath("//form[@name='detectorForm']//input[@ng-model='detector.class']"), "HTTP");
    findElementByXpath(
            "//form[@name='detectorForm']//ul[contains(@class, 'dropdown-menu')]/li/a/strong[text()='HTTP']")
                    .click();
    waitForDropdownClose();

    // Add a parameter to the detector
    clickId("add-detector-parameter", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("input[name='paramName']")));
    enterText(By.cssSelector("input[name='paramName']"), "po");
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@title='port']"))).click();
    enterText(By.cssSelector("input[name='paramValue']"), "8980");
    //enterText(By.cssSelector("input[name='paramValue']"), Keys.ENTER);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("save-detector"))).click();
    waitForModalClose();
    enterText(By.cssSelector("input[placeholder='Search/Filter Detectors'][ng-model='filters.detector']"),
            "HTTP-8980");
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='" + NODE_SERVICE + "']")));

    // Add a policy to the detector
    findElementByCss("#tab-policies .ng-binding").click();
    clickId("add-policy", false);
    findElementByCss("form[name='policyForm']");
    enterText(By.cssSelector("input#name"), "No IPs");
    enterText(By.cssSelector("input#clazz"), "Match IP Interface");
    enterText(By.cssSelector("input#clazz"), Keys.ENTER);
    enterText(By.xpath("(//input[@name='paramValue'])[1]"), "DO_NOT_PERSIST");
    enterText(By.xpath("(//input[@name='paramValue'])[1]"), Keys.ENTER);
    enterText(By.xpath("(//input[@name='paramValue'])[2]"), "NO_PARAMETERS");
    enterText(By.xpath("(//input[@name='paramValue'])[2]"), Keys.ENTER);
    clickId("save-policy", false);
    waitForModalClose();
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//td[text()='No IPs']")));

    // Save foreign source definition
    clickId("save-foreign-source", false);
    wait.until(ExpectedConditions
            .not(ExpectedConditions.visibilityOfElementLocated(By.id("save-foreign-source"))));

    // Go to the Requisition page
    clickId("go-back", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//h4[text()='Requisition " + REQUISITION_NAME + " (0 defined, 0 deployed)']")));

    // Add node to a requisition
    clickId("add-node", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("nodeLabel"))).clear();
    enterText(By.id("nodeLabel"), NODE_LABEL);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("foreignId"))).clear();
    enterText(By.id("foreignId"), NODE_FOREIGNID);
    saveNode();

    // Add an IP Interface
    clickId("tab-interfaces", false);
    findElementById("add-interface").click();
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("form[name='intfForm']")));
    final By ipaddrBy = By.cssSelector("input#ipAddress");
    wait.until(ExpectedConditions.visibilityOfElementLocated(ipaddrBy));
    enterText(ipaddrBy, NODE_IPADDR);

    // Add a service to the IP Interface
    findElementById("add-service").click();
    final By xpath = By.cssSelector("input[name='serviceName']");
    wait.until(ExpectedConditions.visibilityOfElementLocated(xpath));
    Thread.sleep(100);
    enterText(xpath, "HTTP-89");
    findElementByXpath("//a[@title='HTTP-8980']/strong").click();

    // Save the IP interface
    clickId("save-interface", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_IPADDR + "']")));

    // Add an asset to the node
    clickId("tab-assets", false);
    clickId("add-asset", false);
    findElementByCss("form[name='assetForm']");
    enterText(By.id("asset-name"), "countr");
    findElementByXpath("//a[@title='country']/strong").click();
    enterText(By.id("asset-value"), "USA");
    clickId("save-asset", false);
    waitForModalClose();

    // Add a category to the node
    clickId("tab-categories", false);
    clickId("add-category", false);
    Thread.sleep(100);
    enterText(By.cssSelector("input[name='categoryName']"), NODE_CATEGORY);
    findElementByXpath("//a[@title='" + NODE_CATEGORY + "']/strong").click();

    saveNode();

    // Go to the requisition page
    clickId("go-back", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_LABEL + "']")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//td[contains(@class,'ng-binding') and text()='" + NODE_FOREIGNID + "']")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//p[contains(@class,'ng-binding') and text()='" + NODE_IPADDR + " (P)']")));

    // Synchronize the requisition
    clickId("synchronize", false);
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.cssSelector(".modal-dialog button.btn.btn-success")));
    WebElement modal = findModal();
    modal.findElement(By.xpath("//div/button[text()='Yes']")).click();
    waitForModalClose();
    wait.until(new WaitForNodesInRequisition(REQUISITION_NAME, 1));
    wait.until(new WaitForNodesInDatabase(REQUISITION_NAME, 1));
    clickId("refresh", false);
    clickId("refreshDeployedStats", false);
    wait.until(ExpectedConditions.visibilityOfElementLocated(
            By.xpath("//h4[text()='Requisition " + REQUISITION_NAME + " (1 defined, 1 deployed)']")));

    // Go to the requisitions page
    clickId("go-back", false);

    // Wait until the node has been added to the database, using the ReST API
    m_driver.get(getBaseUrl() + "opennms/rest/nodes/" + REQUISITION_NAME + ":" + NODE_FOREIGNID
            + "/ipinterfaces/" + NODE_IPADDR + "/services/ICMP");
    m_driver.manage().timeouts().implicitlyWait(2000, TimeUnit.MILLISECONDS);
    try {
        for (int i = 0; i < 30; i++) {
            try {
                final WebElement e = m_driver
                        .findElement(By.xpath("//service/serviceType/name[text()='ICMP']"));
                if (e != null) {
                    break;
                }
            } catch (Exception e) {
            }
            m_driver.navigate().refresh();
        }
    } finally {
        m_driver.manage().timeouts().implicitlyWait(LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
    }

    // Open the nodes list page
    m_driver.get(getBaseUrl() + "opennms/");
    clickMenuItem("Info", "Nodes", "element/nodeList.htm");

    try {
        // Disable implicitlyWait
        m_driver.manage().timeouts().implicitlyWait(0, TimeUnit.MILLISECONDS);
        // If this is the only node on the system, we'll be sent directly to its node details page.
        findElementByXpath("//h3[text()='Availability']");
    } catch (NoSuchElementException e) {
        // If there are multiple nodes, we will be on the node list page, click through to the node
        findElementByLink(NODE_LABEL).click();
    } finally {
        // Restore the implicitlyWait timeout
        m_driver.manage().timeouts().implicitlyWait(LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
    }

    wait.until(ExpectedConditions.elementToBeClickable(By.linkText("ICMP")));
    findElementByXpath("//a[contains(@href, 'element/interface.jsp') and text()='" + NODE_IPADDR + "']");
    findElementByLink("HTTP-8980");
}

From source file:org.opennms.smoketest.ProvisioningTest.java

License:Open Source License

@Test
public void testRequisitionUI() throws Exception {
    final WebElement form = findElementByXpath("//form[@name='takeAction']");
    form.findElement(By.cssSelector("input[type=text][name=groupName]")).sendKeys(REQUISITION_NAME);
    form.submit();//from  w ww .  j  ava2  s . c  o  m

    // edit the foreign source
    findElementById("edit_fs_anchor_" + REQUISITION_NAME).click();

    // add a detector
    findElementByXpath("//input[@value='Add Detector']").click();
    String detectorNode = setTreeFieldsAndSave("foreignSourceEditForm", type("name", "HTTP-8980"),
            select("pluginClass", "HTTP"));

    // set the port to 8980
    findElementByXpath("//a[contains(@href, '" + detectorNode + "') and text() = '[Add Parameter]']").click();
    setTreeFieldsAndSave("foreignSourceEditForm", select("key", "port"), type("value", "8980"));

    findElementByXpath("//input[@value='Done']").click();

    // add a node
    findElementById("edit_req_anchor_" + REQUISITION_NAME).click();
    findElementByXpath("//input[@value='Add Node']").click();
    String nodeForNode = setTreeFieldsAndSave("nodeEditForm", type("nodeLabel", NODE_LABEL));

    // add the node interface
    findElementByXpath("//a[contains(@href, '" + nodeForNode + "') and text() = '[Add Interface]']").click();
    setTreeFieldsAndSave("nodeEditForm", type("ipAddr", "::1"));

    // add the interface service
    findElementByXpath("//a[text() = 'Add Service']").click();
    setTreeFieldsAndSave("nodeEditForm", select("serviceName", "HTTP-8980"));

    findElementByXpath("//input[@value='Done']").click();
    findElementByXpath("//input[@value='Synchronize']").click();

    assertTrue(wait.until(new WaitForNodesInDatabase(1)));
    LOG.debug("Found 1 node in the database.");

    clickMenuItem("Info", "Nodes", "element/nodeList.htm");

    try {
        findElementByXpath("//h3[text()='Availability']");
    } catch (final Exception e) {
        // We should be on the node list page, click through to the node
        findElementByLink(NODE_LABEL).click();
    }

    wait.until(ExpectedConditions.elementToBeClickable(By.linkText("ICMP")));
    findElementByXpath("//a[contains(@href, 'element/interface.jsp') and text()='"
            + InetAddressUtils.normalize("::1") + "']");
}

From source file:org.opennms.smoketest.QuickAddNodeIT.java

License:Open Source License

@Test
public void testQuickAddNode() throws Exception {
    adminPage();//from w w  w.ja  va2  s.co m
    clickMenuItem("name=nav-admin-top", "Quick-Add Node", "admin/ng-requisitions/app/quick-add-node.jsp");

    Thread.sleep(5000);

    long end = System.currentTimeMillis() + LOAD_TIMEOUT;
    do {
        // Basic fields
        findElementByCss("input#foreignSource");
        enterTextAutocomplete(By.id("foreignSource"), REQUISITION_NAME);
        enterText(By.id("ipAddress"), NODE_IPADDR);
        enterText(By.id("nodeLabel"), NODE_LABEL);
    } while (!textFieldsReady() && System.currentTimeMillis() < end);

    // Add a category to the node
    findElementById("add-category").click();
    findElementByCss("input[name='categoryName'");
    enterTextAutocomplete(By.cssSelector("input[name='categoryName']"), NODE_CATEGORY, Keys.ENTER);

    wait.until(ExpectedConditions.elementToBeClickable(By.id("provision"))).click();
    wait.until(ExpectedConditions
            .visibilityOfElementLocated(By.cssSelector(".modal-dialog button[data-bb-handler='main']")))
            .click();

    wait.until(new WaitForNodesInDatabase(1));
}

From source file:org.orcid.integration.blackbox.api.v2.rc1.BlackBoxBase.java

License:Open Source License

public void adminUnlockAccount(String adminUserName, String adminPassword, String orcidToUnlock) {
    // Login Admin
    adminSignIn(adminUserName, adminPassword);
    // Unlock the account
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    WebElement unLockProfileLink = webDriver.findElement(By.linkText("Unlock profile"));
    unLockProfileLink.click();/*ww w.ja  va2 s. c  om*/
    WebElement unLockProfileOrcidId = webDriver.findElement(By.id("orcid_to_unlock"));
    unLockProfileOrcidId.sendKeys(orcidToUnlock);
    WebElement unLockButton = webDriver.findElement(By.id("bottom-confirm-unlock-profile"));
    unLockButton.click();
    wait.until(ExpectedConditions.elementToBeClickable(By.id("btn-unlock")));
    WebElement confirmUnLockButton = webDriver.findElement(By.id("btn-unlock"));
    confirmUnLockButton.click();
    webDriver.quit();
}

From source file:org.orcid.integration.blackbox.api.v2.rc1.BlackBoxBase.java

License:Open Source License

public void adminLockAccount(String adminUserName, String adminPassword, String orcidToLock) {
    adminSignIn(adminUserName, adminPassword);
    // Lock the account
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    WebElement lockProfileLink = webDriver.findElement(By.linkText("Lock profile"));
    lockProfileLink.click();//w  w  w . j ava 2s.c  o  m
    WebElement lockProfileOrcidId = webDriver.findElement(By.id("orcid_to_lock"));
    lockProfileOrcidId.sendKeys(orcidToLock);
    WebElement lockButton = webDriver.findElement(By.id("bottom-confirm-lock-profile"));
    lockButton.click();
    wait.until(ExpectedConditions.elementToBeClickable(By.id("btn-lock")));
    WebElement confirmLockButton = webDriver.findElement(By.id("btn-lock"));
    confirmLockButton.click();
    webDriver.quit();
}

From source file:org.orcid.integration.blackbox.client.XPath.java

License:Open Source License

public WebElement waitToBeClickable(String xpath) {
    By by = By.xpath(xpath);//from w  ww .j  a v  a 2 s .  c om
    utils.getWait().until(ExpectedConditions.elementToBeClickable(by));
    WebElement webElement = webDriver.findElement(by);
    return webElement;
}

From source file:org.wso2.carbon.emm.integration.test.EMMIntegrationTest.java

License:Open Source License

/**
 * Performs the login operation to emm web-app using Selenium.
 *///  w ww  .  j  a  va 2s  .co  m
protected void loginToEmmWebAppViaWebDriver() {
    webDriver.get(EMMIntegrationTestConstants.EMM_CONSOLE_HTTP_ENDPOINT);
    webDriverWait.until(ExpectedConditions.elementToBeClickable(By.xpath("//div[contains(.,'Sign in')]")));
    webDriver.findElement(By.xpath("//input[@name='username']")).sendKeys("admin");
    webDriver.findElement(By.xpath("//input[@name='password']")).sendKeys("admin");
    webDriver.findElement(By.xpath("//button[contains(.,'Sign in')]")).click();
    webDriverWait.until(
            ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(.,'Devices By Ownership')]")));
}

From source file:org.wso2.emm.integration.ui.pages.CommonUtil.java

License:Open Source License

/**
 * Waits until the given element is clickable and perform the click event.
 *
 * @param driver  selenium web driver./*w  w w.  j  a  v a 2s  . co  m*/
 * @param locator locator of the element.
 * @throws InterruptedException If error occurs with thread execution.
 */
public static void waitAndClick(WebDriver driver, By locator) throws InterruptedException {
    Actions actions = new Actions(driver);
    WebDriverWait wait = new WebDriverWait(driver, 10);
    wait.until(ExpectedConditions.elementToBeClickable(locator));
    WebElement webElement = driver.findElement(locator);
    /*
    There is a issue in Selenium Chrome Driver where it performs click event in wrong places (#633). Mostly occur
    when the element to be clicked is placed outside the visible area. To overcome this issue scrolling the page to
    the element locator through a JavascriptExecutor
     */
    ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", webElement);
    Thread.sleep(500);
    actions.moveToElement(webElement).click().build().perform();
}

From source file:org.xframium.page.element.SeleniumElement.java

License:Open Source License

@Override
protected boolean _waitFor(long timeOut, TimeUnit timeUnit, WAIT_FOR waitType, String value) {
    long startTime = System.currentTimeMillis();
    if ("V_TEXT".equals(getBy().name().toUpperCase())) {
        boolean returnValue = Boolean.parseBoolean(PerfectoMobile.instance().imaging()
                .textExists(getExecutionId(), getDeviceName(), getKey(), (short) timeOut, 50).getStatus());

        PageManager.instance().addExecutionLog(getExecutionId(), getDeviceName(), getPageName(),
                getElementName(), "waitFor", System.currentTimeMillis(), System.currentTimeMillis() - startTime,
                returnValue ? StepStatus.SUCCESS : StepStatus.FAILURE, getKey(), null, 0, "", false,
                new String[] { waitType.name().toLowerCase() });

        return returnValue;
    } else {//from  w ww.  jav  a  2s  .c  o  m

        try {

            String currentContext = null;
            if (webDriver instanceof ContextAware)
                currentContext = ((ContextAware) webDriver).getContext();

            WebDriverWait wait = new WebDriverWait(webDriver, timeOut, 250);
            WebElement webElement = null;

            switch (waitType) {
            case CLICKABLE:
                webElement = wait.until(ExpectedConditions.elementToBeClickable(useBy()));
                break;

            case INVISIBLE:
                return wait.until(ExpectedConditions.invisibilityOfElementLocated(useBy()));

            case PRESENT:

                webElement = wait.until(ExpectedConditions.presenceOfElementLocated(useBy()));
                break;

            case SELECTABLE:
                return wait.until(ExpectedConditions.elementToBeSelected(useBy()));

            case TEXT_VALUE_PRESENT:
                return wait.until(ExpectedConditions.textToBePresentInElementValue(useBy(), value));

            case VISIBLE:
                webElement = wait.until(ExpectedConditions.visibilityOfElementLocated(useBy()));
                break;

            default:
                throw new IllegalArgumentException("Unknown Wait Condition [" + waitType + "]");
            }

            if (currentContext != null && webDriver instanceof ContextAware)
                ((ContextAware) webDriver).context(currentContext);

            PageManager.instance().addExecutionLog(getExecutionId(), getDeviceName(), getPageName(),
                    getElementName(), "waitFor", System.currentTimeMillis(),
                    System.currentTimeMillis() - startTime,
                    webElement != null ? StepStatus.SUCCESS : StepStatus.FAILURE, getKey(), null, 0, "",
                    webElement instanceof CachedElement, new String[] { waitType.name().toLowerCase() });
            return webElement != null;
        } catch (Exception e) {
            log.error(Thread.currentThread().getName() + ": Could not locate " + useBy(), e);
            throw new ObjectIdentificationException(getBy(), useBy());
        }
    }
}

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

License:LGPL

protected void processStep(StepType step) throws Exception {
    WebElement element = null;/* www.java2s. co  m*/
    Alert a = null;
    if (step.getScrollX() != null && step.getScrollY() != null) {
        JavascriptExecutor js = (JavascriptExecutor) getSuite().getDriver();
        js.executeScript("window.scrollTo(" + step.getScrollX() + ", " + step.getScrollY() + ");");
    }
    if (step.isBack() != null && step.isBack()) {
        getSuite().getDriver().navigate().back();
    }
    if (step.isForward() != null && step.isForward()) {
        getSuite().getDriver().navigate().forward();
    }
    Element e = null;
    if (step.getLoad() != null && step.getLoad().getKey() != null) {
        e = store.get(step.getLoad().getKey());
        element = findElement(e.getFinds());
    }
    if (step.getElement() != null) {
        if (step.getElement().getFinds() != null) {
            e = step.getElement();
            checkStore(e);

            element = checkWaitFor(e);
            if (element == null && step.getElement().isCheckNullElement()) {
                return;
            }
            checkStoreValue(e, element);
            checkSetValue(e, element);
            checkSendKeys(e, element);
            checkClick(e, element);
            checkChangeState(e);
            checkText(e, element);
            checkMoveX(e, element);
        }
    }
    if (step.getSwitchTo() != null) {
        Object to = switchTo(step.getSwitchTo());
        if (to instanceof Alert) {
            a = (Alert) to;
            if (step.getSwitchTo().getAlert() != null && step.getSwitchTo().getAlert().isAccept()) {
                a.accept();
            }
        } else {
            a = null;
        }
    }
    if (step.getSelect() != null) {
        org.xmlium.testsuite.Select stepSelect = step.getSelect();

        if (element != null && stepSelect.getSelectBy().getByIndex() != null) {
            Index index = stepSelect.getSelectBy().getByIndex();
            SelectData selectData = new SelectData();
            initSelectIndexes(element, index, selectData);
            if (selectData.selectIndex >= 0) {
                Select select = new Select(element);
                List<WebElement> options = select.getOptions();
                WebElement option = options.get(selectData.selectIndex);
                option.click();
            } else {
                throw new RuntimeException("selectedIndex=" + selectData.selectIndex);
            }
        } else {
            if (element == null) {
                element = findElement(step.getSelect().getFinds());
            }
            if (element != null) {
                Select select = new Select(element);
                if (step.getSelect().getSelectBy() != null) {
                    selectBy(select, step.getSelect().getSelectBy());
                }
            }
        }
    }
    if (step.getPrettySelect() != null) {
        PrettySelect stepSelect = step.getPrettySelect();
        if (element == null) {
            if (stepSelect.getFinds() != null) {
                element = findElement(stepSelect.getFinds());
            }
        }
        if (element != null && stepSelect.getSelectBy() != null) {
            SelectData selectData = new SelectData();
            Select select = null;
            select = new Select(element);
            Index index = null;
            if (stepSelect.getSelectBy().getByIndex() != null) {
                index = stepSelect.getSelectBy().getByIndex();
                initSelectIndexes(element, index, selectData);
            } else if (stepSelect.getSelectBy().getByVisibleText() != null) {
                List<WebElement> elems = select.getOptions();
                getOptionIndexBuVisibleText(stepSelect.getSelectBy().getByVisibleText(), elems, selectData);
            }

            if (selectData.selectIndex >= 0) {
                WebElement arrowArea = null;
                WebElement scrollArea = null;
                if (stepSelect.getSelectBy().getArrowArea() != null) {
                    arrowArea = findElement(stepSelect.getSelectBy().getArrowArea());
                } else {
                    throw new RuntimeException("arrowArea not defined in xml");
                }

                if (arrowArea != null) {
                    arrowArea.click();

                    if (stepSelect.getSelectBy().getScrollArea() != null) {
                        Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea();
                        if (scrollAreaFinds.getFind() != null) {
                            scrollArea = findElement(scrollAreaFinds.getFind());
                        } else if (scrollAreaFinds.getWaitFor() != null) {
                            scrollArea = waitFor(scrollAreaFinds.getWaitFor());
                        }
                        if (scrollArea == null) {
                            if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) {
                                String text = "";
                                if (scrollAreaFinds.getFind() != null
                                        && scrollAreaFinds.getFind().getByXPath() != null) {
                                    text = unformatValue(scrollAreaFinds.getFind().isUnformat(),
                                            scrollAreaFinds.getFind().getByXPath().getValue());
                                } else if (scrollAreaFinds.getWaitFor() != null
                                        && scrollAreaFinds.getWaitFor().getByXPath() != null) {
                                    text = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(),
                                            scrollAreaFinds.getWaitFor().getByXPath().getValue());
                                }

                                throw new RuntimeException("scrollArea not found: " + text);
                            } else {
                                throw new RuntimeException("scrollArea not defined in xml");
                            }
                        }
                    }

                    if (index.isFirst() != null || index.isLast() != null) {
                        Actions actions = new Actions(getSuite().getDriver());
                        String text = null;
                        if (index.isFirst() != null && index.isFirst()) {
                            actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform();
                        } else if (index.isLast() != null && index.isLast()) {
                            actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform();
                        }

                        if (index.isFirst() != null && index.isFirst()) {
                            text = select.getOptions().get(0).getText();
                        } else if (index.isLast() != null && index.isLast()) {
                            text = select.getOptions().get(select.getOptions().size() - 1).getText();
                        }
                        if (stepSelect.getSelectBy().getOptionsTag() != null) {
                            Find f = new Find();
                            ByXPath xPath = new ByXPath();
                            if (text != null && !text.isEmpty()) {
                                xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag()
                                        + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses()
                                        + "') and text()='" + text + "']");
                            } else {
                                xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag()
                                        + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses()
                                        + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]");
                            }
                            f.setByXPath(xPath);
                            WebElement optionElemnt = findElement(f);
                            WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30);
                            wait.until(ExpectedConditions.elementToBeClickable(optionElemnt));
                            optionElemnt.click();
                        }
                    } else {
                        if (selectData.selectIndex < 0
                                || selectData.selectIndex >= select.getOptions().size()) {
                            throw new RuntimeException("selectIndex: " + selectData.selectIndex
                                    + ", options.size: " + select.getOptions().size());
                        }
                        WebElement option = select.getOptions().get(selectData.selectIndex);
                        String text = option.getText();
                        if (text == null || text.isEmpty()) {
                            logger.debug("text is null or empty: " + option);
                            text = null;
                        }
                        if (stepSelect.getSelectBy().getOptionsTag() != null) {
                            Find f = new Find();
                            ByXPath xPath = new ByXPath();
                            if (text != null) {
                                xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag()
                                        + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses()
                                        + "') and text()='" + text + "']");
                            } else {
                                xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag()
                                        + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses()
                                        + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]");
                            }
                            f.setByXPath(xPath);
                            WebElement optionElemnt = findElement(f);

                            Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates();
                            coordinate.onPage();
                            coordinate.inViewPort();
                            WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30);
                            wait.until(ExpectedConditions.elementToBeClickable(optionElemnt));
                            optionElemnt.click();
                        }
                    }
                } else {
                    throw new RuntimeException("can't click the arrow");
                }
            } else if (stepSelect.getSelectBy().getByVisibleText() != null) {
                WebElement arrowArea = null;
                WebElement scrollArea = null;
                if (stepSelect.getSelectBy().getArrowArea() != null) {
                    arrowArea = findElement(stepSelect.getSelectBy().getArrowArea());
                } else {
                    throw new RuntimeException("arrowArea not defined in xml");
                }

                if (arrowArea != null) {
                    arrowArea.click();
                    String scrollAreaXPath = null;
                    if (stepSelect.getSelectBy().getScrollArea() != null) {
                        Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea();
                        if (scrollAreaFinds.getFind() != null) {
                            scrollArea = findElement(scrollAreaFinds.getFind());
                        } else if (scrollAreaFinds.getWaitFor() != null) {
                            scrollArea = waitFor(scrollAreaFinds.getWaitFor());
                        }

                        if (scrollAreaXPath == null) {
                            if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) {
                                if (scrollAreaFinds.getFind() != null
                                        && scrollAreaFinds.getFind().getByXPath() != null) {
                                    scrollAreaXPath = unformatValue(scrollAreaFinds.getFind().isUnformat(),
                                            scrollAreaFinds.getFind().getByXPath().getValue());
                                } else if (scrollAreaFinds.getWaitFor() != null
                                        && scrollAreaFinds.getWaitFor().getByXPath() != null) {
                                    scrollAreaXPath = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(),
                                            scrollAreaFinds.getWaitFor().getByXPath().getValue());
                                }
                                // throw new RuntimeException("scrollArea
                                // not found: " + text);
                            } else {
                                throw new RuntimeException("scrollArea not defined in xml");
                            }
                        }
                    }

                    Actions actions = new Actions(getSuite().getDriver());
                    String text = null;
                    // actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform();
                    WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30);
                    wait.until(ExpectedConditions.elementToBeClickable(scrollArea));
                    actions.moveToElement(scrollArea).build().perform();

                    text = stepSelect.getSelectBy().getByVisibleText();
                    logger.debug("text: " + text);
                    if (stepSelect.getSelectBy().getOptionsTag() != null) {
                        Find f = new Find();
                        ByXPath xPath = new ByXPath();
                        if (text != null) {

                            xPath.setValue(scrollAreaXPath + "/descendant::"
                                    + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '"
                                    + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text
                                    + "']");
                        } else {
                            xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag()
                                    + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses()
                                    + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]");
                        }
                        f.setByXPath(xPath);
                        logger.debug("xPath: " + xPath);
                        WebElement optionElemnt = findElement(f);

                        Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates();
                        coordinate.onPage();
                        coordinate.inViewPort();
                        wait = new WebDriverWait(getSuite().getDriver(), 30);
                        wait.until(ExpectedConditions.visibilityOf(optionElemnt));
                        actions.moveToElement(optionElemnt).click().build().perform();
                    }
                }
            } else {
                throw new RuntimeException("selectedIndex=" + selectData.selectIndex);
            }
        } else {
            if (element == null) {
                element = findElement(step.getPrettySelect().getFinds());
            }
            if (element != null) {
                Select select = new Select(element);
                if (step.getPrettySelect().getSelectBy() != null) {
                    selectBy(select, step.getPrettySelect().getSelectBy());
                }
            }
        }
    }

    if (step.getSleepAfter() != null) {
        long sleep = step.getSleepAfter().longValue();
        try {
            Thread.sleep(sleep);
        } catch (Exception e2) {
            // TODO: handle exception
        }
    }
}