Finding text on a page

Oct 16, 2012 at 4:12 PM

Hello All,

Looking for a method or process to find sepcifc text on a page.  Watin has a containsText method that finds text on a page.  Does anything similiar exist for CUITe or Coded UI.  So far my search hasn't turned up anything. 

If no method exists can someone describe a process to scrape all of the text off of a web page and then verify whether the text exists on the page.

The only thing that I can think of is adding a search property like thisHtmlControl.PropertyNames.Text and then returning true if the search returns anything that matches.

Thanks

Jeff

 

 

Coordinator
Oct 17, 2012 at 1:58 AM

If you know which html element the text is in, you can get the InnerText property of that control and simply check the return value of the String.Contains method.

There is some sample code to get the html of a web page here:
http://cuite.codeplex.com/discussions/396767

Oct 25, 2012 at 3:18 PM

icnocop,

Thanks again for the reply.

I ended up Unwraping the CUITe control and using the HTMLDocument object to get the innertext for the page.  Then I used a contains method to determine if the string is located in the InnerText.  I posted a question on the Coded UI Test group and this was the solution that came back.

Along with your suggestion, I will add a get InnerText to some of my control code so I can get the text from specific elements on the page.

Here is the solution that I implemented.

            quoteSearch.SetFocus();
            CUITe_HtmlDocument myDoc = quoteSearch.Get<CUITe_HtmlDocument>();
            HtmlControls.HtmlDocument myDocument = (HtmlControls.HtmlDocument) myDoc.UnWrap();
            string innerHtml = myDocument.InnerText;
            bool myResult = innerHtml.Contains("DASHBOARD");

Thanks again for the help.

Jeff