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); […]