I can't seem to find anything about this in the official documents or anywhere, I would like to test if my website have all the right meta tags and OG data in the header.
Is this possible with CodeceptJs and Puppeteer?
I can't seem to find anything about this in the official documents or anywhere, I would like to test if my website have all the right meta tags and OG data in the header.
Is this possible with CodeceptJs and Puppeteer?
You can use seeElementInDOM method to find elements in DOM.
Or you can just grab page HTML source with grabSource and check meta tags as string containing in that source
Solved it by using a helper
class CustomHelper extends Helper {
async getPageOGTitle() {
const page = this.helpers['Puppeteer'].page;
const description = await page.$eval(
"head > meta[property='og:title']",
element => element.content
);
return description;
}
}
and then using it in my test
Scenario('Page Have OG title', async I => {
const OGTitle = await I.getPageOGTitle();
console.log(OGTitle);
});