0

WatIn provides great functionality for programmatic access to the displayed parts of a Web page.

I want to access the head part of the page, spedifically the META tags. Watin allows me access to the TITLE, but AFAICT nothing else. There is an InternetExplorer property which allows access to ShDocVw.InternetExplorer. I suspect this might be the start of the path. Even if it is the right path, I don't know how to follow it.

RichardHowells
  • 7,826
  • 3
  • 24
  • 24

2 Answers2

1

This will give you a collection of meta tags in your page.

Syntax in WatiN 2.0 beta 1:

var metaTags = browser.ElementsWithTag("meta");

Syntax in WatiN 2.0 CTPs and earlier:

var metaTags  = browser.Elements.Filter(Find.By("tagName", "META"));

If you prever the following syntax, read my blog post about adding elements to WatiN:

var metaTags = browser.ElementsOfType<Meta>();
Jeroen van Menen
  • 2,418
  • 1
  • 15
  • 11
0
browser
    .Element(Find.ByName(nameAttribute))
    .GetAttributeValue("content");
eglasius
  • 35,831
  • 5
  • 65
  • 110
  • Thanks - this got me to ie.Element(Find.ByName("KEYWORDS")).GetAttributeValue("content"); I also found success with ie.Elements.Where(el => el.Id == "MetaKeywords") – RichardHowells Apr 01 '09 at 18:30
  • y, if you also have the id set to MetaKeywords (as your second way points reflects) you could just: ie.Element("MetaKeywords") :) – eglasius Apr 01 '09 at 18:39