Selenium Wait Confusion...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Selenium Wait Confusion...

mawa316 .
Hi all,

I've always been a little confused about waits using Selenium and I'm hoping someone can shed some light on something.

What is the difference between the following two waits...

wait.Until(d => driver.FindElementByXPath("//div[contains(text(), 'Blah-Blah')]").Displayed);

wait
.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), 'Blah-Blah')]")));


I've found in some of my tests that when I have one in place and if fails, if I use the other method it works.

Any help in differentiating the two would be greatly appreciated!

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c927c12f-463a-4508-bfb4-ea01bb957d73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Selenium Wait Confusion...

Jonathan Herbaut
I'm not sure about the answer but it seems like that with :
  • The first one : You expect that your element is always in your DOM but not visible
  • The second one : You expect that your element will be visible (but not necessary in your dom during the wait request)

The first one will send you a ElementNotFoundException when you ask for the Displayed attribute.

With the second one, you never make a direct search of your element, that's why the exception will not be fired and this solution is clearly better if this element must be seen before the wait timer.


Le mercredi 25 avril 2018 20:18:28 UTC+2, mawa316 a écrit :
Hi all,

I've always been a little confused about waits using Selenium and I'm hoping someone can shed some light on something.

What is the difference between the following two waits...

wait.Until(d => driver.FindElementByXPath("//div[contains(text(), 'Blah-Blah')]").Displayed);

wait
.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath("//div[contains(text(), 'Blah-Blah')]")));


I've found in some of my tests that when I have one in place and if fails, if I use the other method it works.

Any help in differentiating the two would be greatly appreciated!

Thanks!

--
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/c87fa8bc-621f-43e1-83d4-eac9e282ae69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.