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

HtmlSpan textcontent issue

1 Answer 53 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Santosh
Top achievements
Rank 1
Santosh asked on 09 May 2012, 12:53 PM
Hi,
I am trying to check a condition on the failed webpage using Htmlspan label text. The application requires moving from one webpage to another webpage and perform certain actions on the webpage and the loop continues for several webpages. When i record the failed webpage i get the below lines of code which i am trying to use this in my if else condition. The issue which i am facing is that it works for the first error webpage and moves to the second webpage. When the second webpage fails i am getting an error. The condition is not able to get the failed template HtmlSpan label text and moving to the else condition. (FYI. All the failed webpages pick the text content from the same HtmlSpan i.e same error page loads everytime when ever a page fails). 
It would be very helpful if you could suggest me a proper approach to achieve this.

Regards,
Santosh
 



Pages.Online7.FrameNavigationPanel.LblErrorTitleSpan.AssertContent().TextContent(ArtOfTest.Common.StringCompareType.Contains, "Sorry there was an error displaying your report."); 
                       or 
Pages.Online7.FrameNavigationPanel.LblErrorTitleSpan.BaseElement.Wait.ForCondition((a_0, a_1) => ArtOfTest.Common.CompareUtils.StringCompare(a_0.TextContent, "Sorry there was an error displaying your report.", ArtOfTest.Common.StringCompareType.Contains), false, null, 10000); 
    
if (Pages.Online7.FrameNavigationPanel.LblErrorTitleSpan.IsEnabled) 
                     or 
if (Pages.Online7.FrameNavigationPanel.LblErrorTitleSpan.IsVisible()) 
Code to move to next webpage
Pages.Online4.ImgRightArrow.Click(false);
  
else
Some Code to perform actions on the rendered webpage
    
}

1 Answer, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 11 May 2012, 11:18 PM
Hello Santosh,

To clarify, when the condition is not met in the IF statement, the test throws an error instead of executing the ELSE portion. Is that correct?

If so, my suspicion is that the LblErrorTitleSpan element has Find Settings based on text content. So when its text differs, the element cannot be found to perform the verification on and it causes an error.

If this is the case, you'll need to change the verification to a Wait For Exists. See here for an example of this approach with standard, non-coded steps. See here for how to wait for an element to exist in code.

If your use case differs, please provide more information.

Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Tags
General Discussions
Asked by
Santosh
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Share this question
or