Verifying elements in the HTML tag

Hello,

I am trying to find a way to validate values of the HTML tag. I have a list of expected values, such as what the og:title, og:url…etc should be, and want to construct a test to see if those known values are present in the markup.

Apologies if this has previously been answered on the Forum. I didn’t see an answer on a few search attempts.

Could you copy&paste your HTML source code here?

??? \-\-\- what do you have here?

Hi, Kazurayam,
Thank you for your reply.

Yes…
Here is a sample of the markup in that will go between the tag on the page that I am attempting to validate. (I changed the content values to something generic)

<meta property="og:title" content="OG Title"/>

<meta property="og:type" content="OG Type"/>

<meta property="og:url" content="OG URL" />

<meta property="og:image" content="OG Image" />

<meta property="og:description" content="OG Description"/>



<meta name="twitter:card" content="summary"/>

<meta name="twitter:site" content="@TWITTERHANDLE"/>
Page Title
<link rel="canonical" href="https://example.canonical.com" />

Supposing you create a Test Object named ‘Page_Discussion 16920/head_meta_property-ogtitle’ with the following selector xpath:

/html/head/meta[@property='og:title']

And you create a Test Case with the following snippet:

def ogtitle = WebUI.getAttribute(findTestObject(
    'Page_Discussion 16920/head_meta_property-ogtitle'), 'content')
WebUI.comment("og:title=${ogtitle}")

Then you will get a message in the Log:

og:title=OG Title

Kazurayam,

I wanted to thank you for your time and direction with this issue. You have outlined exactly what I needed to be able to validate this scenario.

Thank for this information, it helped me a lot