Tuesday, 3 September 2013

Selenium C# Dynamic Meta Tags

Selenium C# Dynamic Meta Tags

Im using Selenium for C# in order to serve fully rendered javascript
applications to google spiders and users with javascript disabled. I am
using ASP.NET MVC to serve the pages from my controller. I need to be able
to generate dynamic meta tags before the content is served to the caller.
For example, the following pseudo code:
var pageSource = driver.PageSource; // This is where i get my page content
var meta =
driver.findElement(By.tagname("meta.description")).getAttribute("content");
meta.content = "My New Meta Tag Value Here";
return driver.PageSource; // return the page source with edited meta tags
to the client
I know how to get the page source to the caller, i am already doing this,
but i cant seem to find the right selector to edit the meta tags before i
push the content back to the requester. How would I accomplish this?

No comments:

Post a Comment