Example usage for org.openqa.selenium WebElement isEnabled

List of usage examples for org.openqa.selenium WebElement isEnabled

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement isEnabled.

Prototype

boolean isEnabled();

Source Link

Document

Is the element currently enabled or not?

Usage

From source file:com.qulix.ft.teachingSite.Conditions.ExpectedConditions.java

License:Apache License

/**
 * An Expectation for checking an element is enabled
 *///from w w w. ja v  a  2 s . c om
public static ExpectedCondition<WebElement> elementToBeEnabled(final By locator) {
    return new ExpectedCondition<WebElement>() {

        public ExpectedCondition<WebElement> visibilityOfElementLocated = ExpectedConditions
                .visibilityOfElementLocated(locator);

        public WebElement apply(WebDriver driver) {
            WebElement element = visibilityOfElementLocated.apply(driver);
            try {
                if (element != null && element.isEnabled()) {
                    return element;
                } else {
                    return null;
                }
            } catch (StaleElementReferenceException e) {
                return null;
            }
        }

        @Override
        public String toString() {
            return "element to be enabled: " + locator;
        }
    };
}

From source file:com.qulix.ft.teachingSite.Conditions.ExpectedConditions.java

License:Apache License

/**
 * Wait until an element is no longer attached to the DOM.
 *
 * @param element The element to wait for.
 * @return false is the element is still attached to the DOM, true
 *         otherwise./*from   w w w .  j a  v a  2 s. c  om*/
 */
public static ExpectedCondition<Boolean> stalenessOf(final WebElement element) {
    return new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver ignored) {
            try {
                // Calling any method forces a staleness check
                element.isEnabled();
                return false;
            } catch (StaleElementReferenceException expected) {
                return true;
            }
        }

        @Override
        public String toString() {
            return String.format("element (%s) to become stale", element);
        }
    };
}

From source file:com.redskyit.scriptDriver.RunTests.java

License:MIT License

private void info(WebElement element, String selector, boolean verify) throws Exception {
    do {/* www.  j a va2  s .  com*/
        try {
            Point loc = element.getLocation();
            Dimension size = element.getSize();
            String tag = element.getTagName();
            System.out
                    .print(null == selector ? "test-id \"" + element.getAttribute("test-id") + "\"" : selector);
            System.out.print(" info");
            System.out.print(" tag " + tag);
            System.out.print((element.isDisplayed() ? "" : " not") + " displayed");
            System.out.print(" at " + loc.x + "," + loc.y);
            System.out.print(" size " + size.width + "," + size.height);
            System.out.print((element.isEnabled() ? "" : " not") + " enabled");
            System.out.print((element.isSelected() ? "" : " not") + " selected");
            if (tag.equals("input") || tag.equals("select")) {
                System.out.print(" check \"" + element.getAttribute("value") + "\"");
            } else {
                String text = tag.equals("textarea") ? element.getAttribute("value") : element.getText();
                if (text.indexOf('\n') != -1) {
                    CRC32 crc = new CRC32();
                    crc.update(text.getBytes());
                    System.out.print(" checksum \"crc32:" + crc.getValue() + "\"");
                } else {
                    System.out.print(" check \"" + element.getText() + "\"");
                }
            }
            System.out.println();
            return;
        } catch (StaleElementReferenceException e) {
            // If element has gone stale during a dump, ignore it
            if (!verify)
                return;
            // element has gone stale, re-select it
            System.out.println("// EXCEPTION : StaleElementReference");
        } catch (Exception e) {
            if (verify)
                throw e;
            return;
        }
        sleepAndReselect(100);
    } while (_waitFor > 0 && (new Date()).getTime() < _waitFor);
}

From source file:com.smartqa.engine.WebEngine.java

License:Apache License

/**
 * check web page web element status// w w w . ja va  2  s. c  om
 * 
 * @param name - name stands for web element
 * @param condition - currently support: display, enable
 * @param args - possible need dynamic args to build xpath
 * @return WebEngine
 */
public boolean should(String name, String condition, String... args) {
    String xpath = path.getPath(namespace, name);

    if (args != null && args.length > 0)
        for (int i = 0; i < args.length; i++) {
            String flag = "\\{" + i + "\\}";
            if (xpath.contains("{" + i + "}"))
                xpath = xpath.replaceAll(flag, args[i]);
        }

    if (StringUtils.isEmpty(xpath))
        throw new InvalidPathException(name, namespace);

    WebElement element = driver.findElement(By.xpath(xpath));
    if (element == null)
        throw new ElementNotFoundException(xpath);

    if ("display".equalsIgnoreCase(condition) || "show".equalsIgnoreCase(condition))
        return element.isDisplayed();
    else if ("enable".equalsIgnoreCase(condition))
        return element.isEnabled();

    return false;
}

From source file:com.springer.omelet.common.ExpectedConditionExtended.java

License:Apache License

/***
 * wait for the WebElement to be Clickable
 * /*  w w w  .ja v a 2s . c  o m*/
 * @param element
 *            : WebElement
 * @return
 */
public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) {
    return new ExpectedCondition<WebElement>() {

        public WebElement apply(WebDriver driver) {

            try {
                if (element.isDisplayed() && element.isEnabled()) {
                    return element;
                } else {
                    return null;
                }
            } catch (StaleElementReferenceException e) {
                return null;
            } catch (NoSuchElementException e) {
                return null;
            }
        }

        @Override
        public String toString() {
            return "Element is not enabled";
        }
    };
}

From source file:com.springer.omelet.common.ExpectedConditionExtended.java

License:Apache License

/***
 * wait for the Element to be Disabled//  w w w.ja  v  a2 s  .  c o  m
 * 
 * @param element
 * @return
 */
public static ExpectedCondition<Boolean> elementToBeDisabled(final WebElement element) {
    return new ExpectedCondition<Boolean>() {

        public ExpectedCondition<WebElement> visibilityOfElement = ExpectedConditions.visibilityOf(element);

        public Boolean apply(WebDriver driver) {
            WebElement element = visibilityOfElement.apply(driver);
            try {
                if (element != null && !(element.isEnabled())) {
                    return true;
                } else {
                    return false;
                }
            } catch (StaleElementReferenceException e) {
                return false;
            }
        }

        @Override
        public String toString() {
            return "element to be clickable: " + element;
        }
    };
}

From source file:com.springer.omelet.common.ExpectedConditionExtended.java

License:Apache License

/***
 * This method accepts n number of WebElements and check for click ability if
 * any of the WebElement is not click able will return false
 * /*from ww  w . ja v  a2 s .  c o  m*/
 * @param elements
 * @return
 */
public static ExpectedCondition<Boolean> elementsToBeClickable(final WebElement... elements) {
    final List<Boolean> statusList = new ArrayList<Boolean>();

    return new ExpectedCondition<Boolean>() {
        final StringBuilder sb = new StringBuilder();

        public Boolean apply(WebDriver driver) {
            for (WebElement w : elements) {
                try {
                    if (w.isDisplayed() && w.isEnabled()) {
                        statusList.add(true);
                    } else {
                        statusList.add(false);
                    }
                } catch (StaleElementReferenceException e) {
                    statusList.add(false);
                }

            }
            if (statusList.contains(false)) {
                statusList.clear();
                return false;
            }
            return true;
        }

        @Override
        public String toString() {
            return "elements to be clickable: " + sb;
        }
    };
}

From source file:com.springer.omelet.common.ExpectedConditionExtended.java

License:Apache License

/***
 * Check clikability for the list of WebElement
 * @param elements/*from   ww  w .j av a2  s .  c o  m*/
 * @return
 */
public static ExpectedCondition<Boolean> elementToBeClickable(final List<WebElement> elements) {
    final List<Boolean> statusList = new ArrayList<Boolean>();
    return new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver driver) {
            if (elements.size() == 0)
                return false;
            statusList.clear();
            for (WebElement w : elements) {
                try {
                    if (w != null && w.isEnabled() && w.isDisplayed()) {
                        statusList.add(true);
                    } else {
                        return false;
                    }
                } catch (StaleElementReferenceException e) {
                    return false;
                }
            }
            LOGGER.debug(
                    "element size is:" + elements.size() + " and is sucesfull list is:" + statusList.size());
            return statusList.size() == elements.size() ? true : false;
        }

        @Override
        public String toString() {
            return "One of the Element is not clickable:";
        }
    };
}

From source file:com.testmax.runner.SeleniumTestRunner.java

License:CDDL license

protected WebElement executeMobileAll() throws TestMaxException {
    long executionTime = System.currentTimeMillis();
    List<WebElement> controls = null;
    try {//from   w  w  w  . jav  a  2 s  .com
        this.setImpilicitTimeInMiliSec(new Integer(timeout));

        //handle custom operations
        if (this.isBypassCustomMethod()) {
            if (method.equalsIgnoreCase("get")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                this.waitToPageLoad(new Integer(timeout));
                if (!url.contains("http") && !url.contains("file:")) {
                    url = this.baseUrl + url;
                }
                url = url.replace("[env]", ConfigLoader.getConfig("QA_TEST_ENV"));

                if (this.baseUrl.contains("https")) {
                    url = url.replace("http:", "https:");
                }
                this.printCommand(this.tagdesc + " URL=" + url);
                driver.get(url);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Executed Open URL= " + url + " for Control=" + this.controlIdentifier + ":"
                        + addMessage());
                return null;
            } else if (method.equalsIgnoreCase("closewindow")) {
                this.driver.close();
                return null;
            } else if (method.equalsIgnoreCase("sleep")) {
                this.executeSleep();
                return null;
            } else if (method.equalsIgnoreCase("executescript")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                Thread.sleep(100);
                this.executeScript();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + "\n Script=" + addMessage());
                //printMessage("**** Executed Java Script= "+addMessage()+ " for Control="+this.controlIdentifier +":"+ addMessage());      
                return null;
            } else if (method.equalsIgnoreCase("executeoperation")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                Thread.sleep(100);
                this.executeOperation();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                //printMessage("**** Executed Java Script= "+addMessage()+ " for Control="+this.controlIdentifier +":"+ addMessage());      
                return null;
            } else if (this.method.equalsIgnoreCase("urlextract")) {
                String currenturl = this.driver.getCurrentUrl();
                if (currenturl != null && !currenturl.isEmpty()) {

                    this.addTestExtract(this.value, currenturl);
                    printMessage("#### Extracted parameters from URL=" + currenturl);
                }
                return null;

            } else if (method.equalsIgnoreCase("closewindow")) {
                this.driver.close();
                return null;
            }
        }
        controls = this.getWebElements();

        for (WebElement control : controls) {
            this.setImpilicitTimeInMiliSec(new Integer(timeout));
            if (!isBypassDisplay()) {
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
            }
            if (method.equalsIgnoreCase("click")) {
                try {
                    printMessage("**** Clicking " + this.controlIdentifier);
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                    control.click();
                    printMessage("**** Clicked " + this.controlIdentifier + ":" + addMessage());
                    return control;
                } catch (Exception e) {
                    WebElement target = executeClick(control);
                    if (target != null) {
                        return target;
                    }
                }
            } else if (method.equalsIgnoreCase("selectByValue")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).selectByValue(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Selected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("deselectByVisibleText")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).deselectByVisibleText(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Deselected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("selectByVisibleText")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).selectByVisibleText(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Selected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("clear")) {
                try {
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    while (!control.isDisplayed()) {
                        this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    }
                    Thread.sleep(100);
                    if (control.isEnabled())
                        control.clear();
                    this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                    printMessage("**** Cleared " + this.controlIdentifier + ":" + addMessage());
                    return control;
                } catch (Exception e) {
                    this.clearElement();
                    Thread.sleep(500);
                    return control;
                }
            } else if (method.equalsIgnoreCase("movemouse")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                this.mouseMove(control);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Moved Mouse " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("download")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                this.downloadFile(control);
                if (this.value != null && !this.value.isEmpty() && this.value.contains("[")) {
                    this.modifyexcel(this.value);
                }
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Download File " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("uploadfile")) {

                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                String dest = ConfigLoader.getWmOutputWebServicePath() + "modifytest.xls";
                File mfile = new File(dest);
                String modifyfile = mfile.getCanonicalPath();
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " file=" + modifyfile);
                control.sendKeys(modifyfile);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Entered Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("submit")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                control.submit();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Submitted " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("asserttext")) {
                try {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    Thread.sleep(100);
                    String actual = control.getText();
                    if (actual == null || actual.isEmpty()) {
                        actual = control.getAttribute("value");
                        printMessage(
                                "**** Control won't have Text Value. Extracted Value using attribute Name=value. Found value= "
                                        + actual + " for " + this.controlIdentifier + ":" + addMessage());
                    }
                    this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                            + " value=" + addMessage() + ", actual=" + actual);
                    printMessage("**** verifying Text Value= " + actual + " for " + this.controlIdentifier + ":"
                            + addMessage());
                    if (actual != null && !actual.isEmpty()) {
                        if (value != null && value.contains("@")) {
                            this.addTestExtract(value, actual);
                        } else {
                            this.assertText(value, actual);
                        }
                        return control;
                    }
                } catch (Exception e) {
                }
            } else if (method.equalsIgnoreCase("sendKeys")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                control.sendKeys(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Entered Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            }

        }
    } catch (NumberFormatException e) {

        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        // TODO Auto-generated catch block
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);
    } catch (InterruptedException e) {

        // TODO Auto-generated catch block
        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);
    }

    //if you are here then quit
    //driver.quit();

    return null;
}

From source file:com.testmax.runner.SeleniumTestRunner.java

License:CDDL license

protected WebElement executeAll() throws TestMaxException {
    long executionTime = System.currentTimeMillis();
    List<WebElement> controls = null;
    try {/* w w  w .ja va 2  s  .  c  o m*/
        this.setImpilicitTimeInMiliSec(new Integer(timeout));

        //handle custom operations
        if (this.isBypassCustomMethod()) {
            if (method.equalsIgnoreCase("get")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                this.waitToPageLoad(new Integer(timeout));
                if (!url.contains("http") && !url.contains("file:")) {
                    url = this.baseUrl + url;
                }
                url = url.replace("[env]", ConfigLoader.getConfig("QA_TEST_ENV"));

                if (this.baseUrl.contains("https")) {
                    url = url.replace("http:", "https:");
                }
                this.printCommand(this.tagdesc + " URL=" + url);
                driver.get(url);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Executed Open URL= " + url + " for Control=" + this.controlIdentifier + ":"
                        + addMessage());
                return null;
            } else if (method.equalsIgnoreCase("closewindow")) {
                this.driver.close();
                return null;
            } else if (method.equalsIgnoreCase("sleep")) {
                this.executeSleep();
                return null;
            } else if (method.equalsIgnoreCase("executescript")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                Thread.sleep(100);
                this.executeScript();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + "\n Script=" + addMessage());
                printMessage("**** Executed Java Script= " + addMessage() + " for Control="
                        + this.controlIdentifier + ":" + addMessage());
                return null;
            } else if (method.equalsIgnoreCase("executeoperation")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                Thread.sleep(100);
                this.executeOperation();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                printMessage("**** Executed Java Script= " + addMessage() + " for Control="
                        + this.controlIdentifier + ":" + addMessage());
                return null;
            } else if (this.method.equalsIgnoreCase("urlextract")) {
                String currenturl = this.driver.getCurrentUrl();
                if (currenturl != null && !currenturl.isEmpty()) {

                    this.addTestExtract(this.value, currenturl);
                    printMessage("#### Extracted parameters from URL=" + currenturl);
                }
                return null;

            }
        }
        controls = this.getWebElements();

        for (WebElement control : controls) {
            this.setImpilicitTimeInMiliSec(new Integer(timeout));
            if (!isBypassDisplay()) {
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
            }
            if (method.equalsIgnoreCase("click")) {
                try {
                    printMessage("**** Clicking " + this.controlIdentifier);
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                    control.click();
                    printMessage("**** Clicked " + this.controlIdentifier + ":" + addMessage());
                    return control;
                } catch (Exception e) {
                    WebElement target = executeClick(control);
                    if (target != null) {
                        return target;
                    }
                }
            } else if (method.equalsIgnoreCase("selectByValue")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).selectByValue(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Selected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("deselectByVisibleText")) {
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).deselectByVisibleText(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Deselected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("selectByVisibleText")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                new Select(control).selectByVisibleText(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Selected Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("clear")) {
                try {
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    while (!control.isDisplayed()) {
                        this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    }
                    Thread.sleep(100);
                    if (control.isEnabled())
                        control.clear();
                    this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                    printMessage("**** Cleared " + this.controlIdentifier + ":" + addMessage());
                    return control;
                } catch (Exception e) {
                    this.clearElement();
                    Thread.sleep(500);
                    return control;
                }
            } else if (method.equalsIgnoreCase("movemouse")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                this.mouseMove(control);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Moved Mouse " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("download")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                this.downloadFile(control);
                if (this.value != null && !this.value.isEmpty() && this.value.contains("[")) {
                    this.modifyexcel(this.value);
                }
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Download File " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("uploadfile")) {

                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                String dest = ConfigLoader.getWmOutputWebServicePath() + "modifytest.xls";
                File mfile = new File(dest);
                String modifyfile = mfile.getCanonicalPath();
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " file=" + modifyfile);
                control.sendKeys(modifyfile);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Entered Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("submit")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier);
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                control.submit();
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Submitted " + this.controlIdentifier + ":" + addMessage());
                return control;
            } else if (method.equalsIgnoreCase("asserttext")) {
                try {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                    Thread.sleep(100);
                    String actual = control.getText();
                    if (actual == null || actual.isEmpty()) {
                        actual = control.getAttribute("value");
                        printMessage(
                                "**** Control won't have Text Value. Extracted Value using attribute Name=value. Found value= "
                                        + actual + " for " + this.controlIdentifier + ":" + addMessage());
                    }
                    this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                    this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                            + " value=" + addMessage() + ", actual=" + actual);
                    printMessage("**** verifying Text Value= " + actual + " for " + this.controlIdentifier + ":"
                            + addMessage());
                    if (actual != null && !actual.isEmpty()) {
                        if (value != null && value.contains("@")) {
                            this.addTestExtract(value, actual);
                        } else {
                            this.assertText(value, actual);
                        }
                        return control;
                    }
                } catch (Exception e) {
                }
            } else if (method.equalsIgnoreCase("sendKeys")) {
                this.printCommand(this.tagdesc + " for control with identifier=" + this.controlIdentifier
                        + " value=" + addMessage());
                this.setImpilicitTimeInMiliSec(new Integer(timeout));
                while (!control.isDisplayed()) {
                    this.setImpilicitTimeInMiliSec(new Integer(timeout));
                }
                Thread.sleep(100);
                control.sendKeys(sendkeyValue);
                this.timeTaken = this.timeTaken + (System.currentTimeMillis() - executionTime);
                printMessage("**** Entered Value= " + addMessage() + " for Control=" + this.controlIdentifier
                        + ":" + addMessage());
                return control;
            }

        }
    } catch (NumberFormatException e) {

        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        // TODO Auto-generated catch block
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);
    } catch (InterruptedException e) {

        // TODO Auto-generated catch block
        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        this.printCommand(
                " FAILED  with Exception for Command=" + this.tagdesc + " for control with identifier="
                        + this.controlIdentifier + " file=" + addMessage() + "\n Message=" + e.getMessage());
        this.printCommand(WmLog.getStackTrace(e));
        String v_msg = ">>Dataset:" + this.threadIndex + " FAILED TO EXECUTE CONTROL IN " + addMessage() + " "
                + (e.getMessage() != null && e.getMessage().length() > 100 ? e.getMessage().substring(0, 100)
                        : e.getMessage());
        e.printStackTrace();
        throw new TestMaxException(v_msg);
        //handleTimeOut(v_msg);
    }

    //if you are here then quit
    //driver.quit();

    return null;
}