none
Wait Until Element is Present RRS feed

  • Question

  • I want to replace the explicit waits (Wait(20);) on implicit waits
    I know that this is implemented in selenium webdriver, and I can write something like this:

    WebDriverWait wait = new WebDriverWait(driver, 30);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("id1")));

    but use selenium webdriver it does not suit me.
    who can help me in solving this problem (wait for a certain amount of time to find an element or elements if they are not immediately available)?


            private void CheckFindElement1()
            {
                try

                {
                    Wait(20);
                    var mlm = web_Browser.Document.GetElementById("id1");
                    mlm.InvokeMember("Click");
                }
                catch (Exception)
                {
                    Wait(1);
                    CheckFindElement1();
                }
            }
    Sunday, May 6, 2018 1:06 PM

All replies

  • It seems to me the deterministic way to do this is to add an onLoad handler to the element when you create it.  That way, you'd know exactly when it shows up.

    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Monday, May 7, 2018 5:44 AM
  • Hi Aleks Roth,

    Thank you for posting here.

    >>wait for a certain amount of time to find an element or elements if they are not immediately available

    For your question, try tp use Thread.Sleep() to wait a certain account of time.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 7, 2018 7:29 AM
    Moderator