diff --git a/generated.test.js b/generated.test.js new file mode 100644 index 0000000..be7269d --- /dev/null +++ b/generated.test.js @@ -0,0 +1,26 @@ +```javascript +import { test, expect } from '@playwright/test'; + +test('Confirm that clicking the \'Register\' link correctly navigates the user to the \'register.php\' page.', async ({ page }) => { + // Step 1: Navigate to the login page. + // This assumes the file is served from a web server where 'source code' is a top-level directory. + // The base URL should be configured in playwright.config.js (e.g., http://localhost:3000). + await page.goto('/source code/login.html'); + + // Step 2: Locate the "Register" link. + // Using getByRole is a best practice as it finds elements the way a user would. + const registerLink = page.getByRole('link', { name: 'Register' }); + + // Optional: Assert that the link has the correct href attribute before clicking. + await expect(registerLink).toHaveAttribute('href', 'register.php'); + + // Step 3: Click the link, triggering navigation. + // Playwright automatically waits for the page to navigate after a click. + await registerLink.click(); + + // Step 4: Verify the new page URL. + // Using a regular expression ensures the test passes regardless of the domain/port, + // as long as the path ends with 'register.php'. + await expect(page).toHaveURL(/register\.php$/); +}); +``` \ No newline at end of file