Lazy wait for HTML elements

2 posts, 0 answers
  1. Harinee
    Harinee avatar
    6 posts
    Member since:
    Mar 2015

    Posted 19 Mar 2015 Link to this post


    I have code like this:

    newElement = Find.ById<HtmlDiv>("someId");  
    //the find is already executed here. But it takes some time before newElement is present on the page. So the find strategy will return null.

     //since element was not already present, newElement= null. So wait for exists doesn't really do anything

    Is there a way to have a lazy find strategy? So, only when I wait for the element to exist, does it actually try to find it?
  2. Boyan Boev
    Boyan Boev avatar
    1072 posts

    Posted 23 Mar 2015 Link to this post

    Hi Harinee,

    In this case you should for the entire find expression like this:

    HtmlFindExpression expr = new HtmlFindExpression("id=someID");
    ActiveBrowser.WaitForElement(expr, 30000, false);
    Element el = ActiveBrowser.Find.ByExpression(expr);

    Let me know if this helps.

    Boyan Boev
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top