Robot Framework - Selenium2library - Check the Favicon of the page Robot Framework - Selenium2library - Check the Favicon of the page selenium selenium

Robot Framework - Selenium2library - Check the Favicon of the page


According to the currently applied standards, the correct way to set the favicon is through a link tag, having rel="icon" attribute, though some sites still use rel="shortcut icon" (more details in the wikipedia link above). This xpath covers both:

${loc}=    xpath=//link[@rel="link" or @rel="shortcut icon"]

To get its value, use the normal robotframework approach:

${favicon}=    Get Element Attribute     ${loc}@href


Figured it out.I basically grab the href of the link tag in question, and then compare them using the "should be equal as strings" keyword. I would have solved it sooner, but the icon link tag was not the first link tag. Below is the lines I used:

${Favicon1} =   Get Element Attribute    //link[2]@hrefShould Be Equal As Strings    ${Favicon1}    http://localhost:8080/bin/icons/1.ico

Many thanks to Bryan Oakley for nudging me in the right direction.