This is a migrated thread and some comments may be shown as answers.

Lazy wait for HTML elements

3 Answers 143 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Harinee
Top achievements
Rank 1
Harinee asked on 19 Mar 2015, 05:15 AM
Hi,

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.

newElement.Wait.ForExists(timeout);              
 //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?

3 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 23 Mar 2015, 03:13 PM
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);
ActiveBrowser.Actions.Click(el);

Let me know if this helps.

Regards,
Boyan Boev
Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
0
Bharadwaj
Top achievements
Rank 1
answered on 03 May 2018, 05:39 AM

Hi Boyan,

Thank for your response. By using your above post is there a way we can develop a generic Wait utility using all the Telerik Framework  functions? Please share your thoughts. 

Regards,

Bharadwaj.

0
Elena
Telerik team
answered on 07 May 2018, 09:28 AM
Hi Bharadwaj,

Thanks for reaching us out. 

You could use the above code shared by Boyan to create that generic wait utility - for example include the code in a method which expects the id to form the find expression as an argument. Then share the method across the project from a utility class.  

I hope this helps!

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
Harinee
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Bharadwaj
Top achievements
Rank 1
Elena
Telerik team
Share this question
or