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

Avoid the Timeout Exception if iframe element not found

1 Answer 70 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Satya
Top achievements
Rank 1
Satya asked on 17 Sep 2012, 11:24 AM
Hi,

The default behavior of Test Studio and the Telerik Testing Framework is to time out after a certain interval if the element is not found. 

I would like to avoid the Timeout Exception and perform a different set of steps depending on whether the element is found. My application does not use silverlight.
I have checked the Telerik help document , Change Silverlight Find Strategy, but i think  it is applicable for only Silverlight applications.

Below is the code snippet which i want to perform if the 'MS2007AboveRadio' check box on the iframe is found. To avoid Timedout Exception if the element is not found, i have placed it in the try catch block. Tried the if else condition aswelll, but it gets timedout.

try
{
    Pages.application.FrameFrame1.MS2007AboveRadio.Check(true, true);
    Pages.application.FrameFrame1.CphMainBtnProceedImage.Click(true);
}
catch
{
}

Please suggest me better way to do it. Do we have something like Find Strategy for a c#.net application.

Regards,
Satyajeet

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 19 Sep 2012, 01:15 PM
Hi Satyajeet,

I am sorry, but this is our current implementation. When referencing an element from the Repository via the Pages class, if the element is found it will return the element, if it's not it will throw an exception.
 
There is an existing feature request to implement a functionality similar to the Silverlight Find Strategy for Html. You can vote for the PITS Issue here: Public URL.

In the meantime, please read this article on how to overcome the problem. 

There is also a way to do this in code. You can search for the element first and then check whether the element is found. Here's a sample code:
ActiveBrowser.NavigateTo("http://yahoo.com/");
  
HtmlButton button = ActiveBrowser.Find.ByContent<HtmlButton>("Search");
if (button != null)
{
    Log.WriteLine("'Search' button exists!");
}
else
{
    Log.WriteLine("'Search' button doesn't exist!");
}

Please give it a try and let me know if you need further assistance on this.
 
All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Satya
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or