how do i wait for element to be visible

Solved 1 Answers 93 Views Selenium
0 1
I have an application where I have to wait until element is visible. How do I achive this?

1 Answer

Best answer
     * Function to explicitly wait for an element to become visible for a
     * designated duration
     * @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 waitForVisible(WebDriver driver, By by, int duration, String selector) {
        for (int x = 0; x <= 5; x++) {
            try {
                new WebDriverWait(driver, duration).until(ExpectedConditions.visibilityOfElementLocated(by));
            } catch (StaleElementReferenceException e) {
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.

We have resolved 1.2k+ Software Testing queries!

Top Contributors