Watin search for text

I have a span element in my page:

<span class="selected-facets">
<ul>
<li>
<a href="?"> </a>
foo
</li>
</ul>
</span>

How can i write a test that makes sure that the

  • element in the span, contains the text 'foo'.

    Thanks in advance.

    Answers


    Maybe this can help:

      browser.Span(Find.ByClass("selected-facets")).InnerHtml.Contains("Foo");
    

    Mabye you should look here: Parsing-HTML-Tags-in-C

    It seems relativly simple:

    protected void Prossess(string html)
    {
        HtmlTag tag;
        HtmlParser parse = new HtmlParser(html);
        while (parse.ParseNext("span", out tag))
        {
          string value;
          if (tag.Attributes.TryGetValue("class", out value))
          {
            // now should be able to compair the value
          }
        }
    }
    

    Or mabye this will be better for you: htmltidy


    Need Your Help

    Reading EML files from Windows SMTP service. Any reason not to use StreamReader?

    .net smtp stream streamreader eml

    I'm going to be reading and parsing the EML files dropped by the Microsoft SMTP service. I am a newbie to using the various stream classes. The implementation I have seen that parses these files ...

  • About UNIX Resources Network

    Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.