Wait for an IWebElement using WebDriverWait

149 views
Skip to first unread message

Kartik Shah

unread,
Sep 13, 2013, 4:06:11 PM9/13/13
to seleniu...@googlegroups.com
Hello All,

I have a requirement where i need to wait for an element which is already available in the form of variable IWebElement

Is there any way i can use WebDriverWait for IWebElement?

I am looking for something like mentioned below:

protected static void WaitForElement(IWebDriver driver, IWebElement PageText)
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60)));
            wait.Until(d=>PageText);
             //Currently this is not working
        }


Kartik Shah

Ashish Juyal

unread,
Sep 16, 2013, 2:02:43 AM9/16/13
to seleniu...@googlegroups.com
Hi ,
          Try for FluentWait.

Regards
Ashish Juyal

Kartik Shah

unread,
Sep 16, 2013, 2:33:36 AM9/16/13
to seleniu...@googlegroups.com
Thanks Ashish. But it seems FluentWait is available only with Java and not with .NET bindings. I need this in c#.

Any other pointers that i can try?

Thanks,
Kartik Shah

Kartik Shah


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/CAKw4aj%2Bc4Rw8tZejJ0jao9qz%3D_KujGPjeo%3DtzxYq7HqhLFBK2g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jim Evans

unread,
Sep 16, 2013, 5:57:29 AM9/16/13
to seleniu...@googlegroups.com
No, but there is a DefaultWait<T> in the .NET bindings that functions much the same as Java's FluentWait. That should give you the flexibility you need.

Kartik Shah

unread,
Sep 16, 2013, 6:21:47 AM9/16/13
to seleniu...@googlegroups.com
Thanks Jim. That did worked for me.

For someone who is looking something similar to implement, here is the code that i implemented based on Jim's suggesstion

DefaultWait<IWebElement> w = new DefaultWait<IWebElement>(WebElement);
                w.Timeout = TimeSpan.FromSeconds(30);
                w.IgnoreExceptionTypes(typeof(NoSuchElementException));

                return w.Until(ctx =>
                {
                    var elem = WebElement;
                    if (elem.Displayed)
                        return elem;
                    else
                        return null;
                });

Kartik Shah


On Mon, Sep 16, 2013 at 3:27 PM, Jim Evans <james.h....@gmail.com> wrote:
No, but there is a DefaultWait<T> in the .NET bindings that functions much the same as Java's FluentWait. That should give you the flexibility you need.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages