Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
how to make element wait for click

Solved 1 Answers 70 Views Selenium
0 1
I have an element which I am required to wait for click. How do I achive this?

1 Answer

0
Best answer
0

Try this.

 

    /**
     * Function to explicitly wait for an element to be clickable
     * 
     * @param driver
     *            -WebDriver currently in use by script
     * @param by
     *            -By identifying the element to be interacted with
     * @param duration
     *            -Int identifying the wait time in seconds
     */
    protected static void waitForClickable(WebDriver driver, By by, int duration) {
        for (int x = 0; x <= 5; x++) {
            try {
                new WebDriverWait(driver, duration).until(ExpectedConditions.elementToBeClickable(by));
                break;
            } catch (StaleElementReferenceException e) {
                e.printStackTrace();
            }
        }
    }
answered by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...