System.Web.HttpUtility.UrlDecode

Verifying the canonical tag on a web page using Selenium GetLocation 

Here is an example to verify the canonical tag on a web page using Selenium GetLocation. The selenium script is written in C#

public int CheckCanonicalTag()
{
int resultcount = 0;
string URL = selenium.GetLocation();
if (selenium.IsElementPresent("//link[@rel='canonical' and @href='" + System.Web.HttpUtility.UrlDecode(URL) + "']"))
{
Console.WriteLine( "Canonical tags is present on the page :" + URL);
}
else
{
Console.WriteLine( "Canonical tags is not present on the page :" + URL);
resultcount++;
}
return resultcount;
}

More…

By Pavandeep Puddupakkam on November 17, 2011 | Selenium RC, Visual Studio 2010 | 1 comment
Tags: , , ,