asp.net mvc - Selenium C# Dynamic Meta Tags -


im using selenium c# in order serve rendered javascript applications google spiders , users javascript disabled. using asp.net mvc serve pages controller. need able generate dynamic meta tags before content served caller. example, following pseudo code:

var pagesource = driver.pagesource; // page content           var meta = driver.findelement(by.tagname("meta.description")).getattribute("content"); meta.content = "my new meta tag value here";  return driver.pagesource; // return page source edited meta tags client 

i know how page source caller, doing this, cant seem find right selector edit meta tags before push content requester. how accomplish this?

selenium doesn't have feature this. technically, can change meta tags javascript, can use selenium's ijavascriptexecutor in c#.

if page using jquery, here's 1 way it:

// new content swap in string newcontent = "my new meta tag value here";  // jquery function swapping string changemetasscript = "$('meta[name=author]').attr('content', arguments[0]);"  // execute javascript executer ijavascriptexecutor js = driver ijavascriptexecutor; js.executescript(changemetasscript, newcontent); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -