In Playwright I created a script to verify the title using toHaveAttribute assertion for this element:
<title style="" xpath="1">Unient | Your Versatile Partner for Better Offshoring</title>
Here is my code:
import { test, expect } from '@playwright/test';
test('Landing page', async ({ page }) => {
await page.goto('https://www.unient.biz/');
await page.getByRole('button', { name: 'Accept All' }).click();
const Title = page.locator("/html/head/title[@xpath='1']");
await expect(Title).toHaveAttribute("title","Unient | Your Versatile Partner for Better Offshoring");
});
But there is an error and I am not really sure how to fix this:
expect.toHaveAttribute: Unsupported token "@xpath" while parsing selector "/html/head/title[@xpath='1']"
=========================== logs ===========================
expect.toHaveAttribute with timeout 5000ms
============================================================
5 | await page.getByRole('button', { name: 'Accept All' }).click();
6 | const Title = page.locator("/html/head/title[@xpath='1']");
> 7 | await expect(Title).toHaveAttribute("xpath","Unient | Your Versatile Partner for Better Offshoring");
| ^
8 | });