How to pass the by parameter in explicit wait as here we are not using By.id for find element please give solution that we can directly pass element

How to pass the by parameter in explicit wait as here we are not using By.id for find element please give solution that we can directly pass element

Default Asked on July 22, 2017 in Selenium WebDriver.
Add Comment
  • 1 Answer(s)

    I don’t quite understand your question so I’ll give you two methods wrote in C# to wait for element and to wait for by. I use the first one as I work only with elements and it works wonders, doesn’t matter what kind of elements it is (even text) you can click on it so it will wait for it. Hope it helps.

    public static void WaitForElement(IWebElement element) {
    var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(75));
    wait.Until(ExpectedConditions.ElementToBeClickable(element));
    }

    public static void WaitForBy(By by) {
    var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
    wait.Until(ExpectedConditions.ElementExists(by));
    }

    Default Answered on November 25, 2017.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.