3

I am using TestStack's Selenium wrapper Seleno for UI testing. I seem to have stumbled upon some weird behavior that I am unable to determine the source of.

Say that I try to find an element that may or may not exist in the DOM:

public void FindStuffByCss(string selector)
{
    Find.OptionalElement(By.CssSelector(selector), TimeSpan.FromMilliseconds(200));
}

I would expect this function to time out after 200 milliseconds if it doesn't find any elements in the DOM, but it actually takes 10 seconds! At first, I thought this was because of the cssSelector I used, but it doesn't seem like that's the case.. Because the following times out after 500 milliseconds:

public void FindStuffByJquery(string selector)
{
    Find.OptionalElement(By.jQuery(selector), TimeSpan.FromMilliseconds(200));
}

Unless JQuery is 20 times faster than whatever Selenium/Seleno uses to perform its By.CssSelector query, this is a little odd. To me it looks like there is a default minimum timeout that you cannot override.

Has anyone noticed similar behaviour? I would really like to know why, and if there is a way to override it.

  • Do you have an `implicitWait()` defined? – JeffC Nov 06 '15 at 04:36
  • Yes, Seleno use a `implicitwait` of 10 seconds by default. It makes sense that it is this timeout that cause the 10 second delay with the `By.CssSelector` method. But that does not explain how the `By.jQuery` only takes 500 milliseconds. Regardless, shouldn't the timeout passed as an argument override the `implicitWait` ? – Kristian Johannessen Nov 08 '15 at 20:36

0 Answers0