Selenium wait for page to load after click C#

///Selenium wait for page to load after click C#
Selenium wait for page to load after click C#2018-10-02T12:27:51+00:00

Front Page Forums Test Driven Development Selenium Selenium wait for page to load after click C#

Viewing 1 post (of 1 total)
  • Author
    Posts
  • ScientistZ
    Keymaster
    Post count: 44

    Selenium wait for page to load after click C#

    In order to do that Make sure you have below nugget packages installed.

    DotNetSeleniumExtras.WaitHelpers

    Selenium.Support is now deprecated so make sure you install above mentioned nugget package.

    Next thing is to create a function so that you can use it to get the element, this function will apply wait until the element that you are looking for is clickable.

    private static IWebElement WaitUntilElementIsVisisble(By elementLocator,IWebDriver driver, int timeout = 10)
    {
    try
    {
    var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));
    return wait.Until(ExpectedConditions.ElementToBeClickable(elementLocator));
    }
    catch (NoSuchElementException e)
    {
    //log exception
    throw;
    }
    }

    Usage:

    IWebElement passwordElement = WaitUntilElementIsVisisble(By.Name(“passwd”), iWebDriver);

    You can check the official documentation of Selenium here.
    Explore More solutions on stackoverflow

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

Skip to toolbar