Tutorial :Using WatiN, how can I access the head part of the page, specifically the meta tags?



Question:

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.


Solution:1

browser      .Element(Find.ByName(nameAttribute))      .GetAttributeValue("content");  


Solution:2

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>();  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »