Untitled
unknown
javascript
3 years ago
1.2 kB
15
Indexable
// @ts-check
const {expect, test} = require('@playwright/test');
//test url
const TEST_URL = 'https://24mx.ie/';
//regex expression for url with 24mx.domain/brands
const META_LINKS_BRANDS_LINK_RE = /https:\/\/24mx\..*\/brands/;
//meta links - customer service link
test('meta brands link', async ({ page }) => {
//go to test url
await page.goto(TEST_URL);
//check if link with class qa-header-customer-service is present
const link = page.locator('.qa-header-brands');
await expect(link).toBeVisible();
//get link text and url
const linkText = await link.innerText();
const linkUrl = await link.getAttribute('href');
//check if the opened link is the same as the one in the header
await link.click();
//log the link was clicked and expected url
console.log(`Clicking link '${linkText}' opening '${linkUrl}'`);
//check if the current url matches the regex expression
const currentUrl = page.url();
expect(currentUrl).toMatch(META_LINKS_BRANDS_LINK_RE);
//log the current url and the regex expression
console.log(`Current url '${currentUrl}' matches regex '${META_LINKS_BRANDS_LINK_RE}'`);
});Editor is loading...