Retrieving Canonical tag on page with selenium :-
HTML Source :-
<link rel="canonical" href="base url" />
int result =0;
String url = selenium.getLocation();
if (selenium.isElementPresent("//link[@rel='canonical' and @href='" + (url) + "']"))
{
//System.out.println(url+"Canonical tag present : " + selenium.getText("//link[@rel='canonical']"));
System.out.println("Canonical tag present : " + url);
selenium.open(url);
}
else
{
System.out.println("Canonical tag not present : " +url);
result++;
}
No comments:
Post a Comment