links-talent-playwright-tests/tests/location-not-clickable.spec.ts

32 lines
1.2 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('#1 Location field should be clickable in job listings — currently not', async ({ page }) => {
// Step 1: Go to the job listings page
await page.goto('https://careers-page.com/linkstalent?page=1&mode=preview', { waitUntil: 'domcontentloaded' });
// Step 2: Wait for job listings to load
await page.waitForSelector('.job-element-in-list', { timeout: 10000 });
// Step 3: Get the first location element
const location = page.locator('.location').first();
// Step 4: Check that it is visible
await expect(location).toBeVisible();
// Step 5: Check if it's a <p> tag (non-interactive)
const tagName = await location.evaluate(node => node.tagName.toLowerCase());
expect(tagName).toBe('p');
// Step 6: Try clicking and check that the URL does not change
const initialURL = page.url();
await location.click();
await page.waitForTimeout(10000); // Wait for any potential action
// Step 7: Confirm URL hasn't changed
expect(page.url()).toBe(initialURL);
// Step 8: (Optional) Check it has no onclick or href attribute
const hasClickHandler = await location.evaluate(node => !!node.getAttribute('onclick'));
expect(hasClickHandler).toBeFalsy();
});