Search code examples
c#browserwatin

How to find id's which ends with Watin


How could i found elements by id in a html document using Watin. For example:

 browser.Link(Find.ById(string+"abc"));

Is is possible ?

Later edit:

I found this and seems to work

browser.Element(wat.Find.BySelector("a:contains('pdf')")).ClickNoWait();

now ... how can i add to list every element which contains 'pdf' ?


Solution

  • I think something like that will work but I haven't tested it. It will probably be quite slow, but you can change the ElementCollection to something else. The if clause could be improved too.

    ElementCollection elc = ie.Elements;
    System.Collections.Generic.List<Element> pdfList = new System.Collections.Generic.List<Element>();
    for (int i = 0; i < elc.Count; i++)
    {
        if(elc[i].Text.Contains("pdf"))
        {
            pdfList.Add(elc[i]);
        }
    }