diff --git a/VINScanner/tests/e2e/test-MinElement.spec.ts b/VINScanner/tests/e2e/test-MinElement.spec.ts index 896de3e..fe0818e 100644 --- a/VINScanner/tests/e2e/test-MinElement.spec.ts +++ b/VINScanner/tests/e2e/test-MinElement.spec.ts @@ -22,7 +22,7 @@ test.describe.configure({ mode: 'serial' }); test.describe('Minimum Element Page Tests', () => { test.use({userAgent}); - + test.beforeEach(async ({ minElementPage }) => { await minElementPage.navigateTo(); }); @@ -45,8 +45,7 @@ test.describe('Minimum Element Page Tests', () => { test('should get all available resolutions', async ({ minElementPage }) => { const resolutions = await minElementPage.getAllResolutions(); if (resolutions !== null) { - // This fails because we're comparing objects incorrectly - // We need to compare each property of the objects instead + let isFound = availableResolutions.some(ai => resolutions.some(res => res.width === ai.width && res.height === ai.height) ); diff --git a/VINScanner/tests/pages/MinElementPage.ts b/VINScanner/tests/pages/MinElementPage.ts index ea2ff9e..66ee1d2 100644 --- a/VINScanner/tests/pages/MinElementPage.ts +++ b/VINScanner/tests/pages/MinElementPage.ts @@ -8,35 +8,16 @@ const URL = '/VINScanner/minimum-elements.html'; export class MinElementPage { private page: Page; private selResolution: Locator; - private options: Locator[]; constructor(page: Page) { this.page = page; } async initialize() { - this.selResolution = await this.page.locator('select.dce-sel-resolution'); - this.options = await this.selResolution.locator('option').all(); - } - - async grantCameraPermission() { - await this.page.addScriptTag({ - content: ` - navigator.mediaDevices.getUserMedia = async () => { - return { - getVideoTracks: () => [{ - applyConstraints: () => {}, - stop: () => {}, - }], - getAudioTracks: () => [], - }; - }; - `, - }); + this.selResolution = await this.page.locator('select.dce-sel-resolution'); } async navigateTo() { - // await this.grantCameraPermission(); await this.page.goto(URL); await this.initialize(); } diff --git a/VINScanner/tests/pages/VinScannerPage.ts b/VINScanner/tests/pages/VinScannerPage.ts index 1b19c9a..8ef2a97 100644 --- a/VINScanner/tests/pages/VinScannerPage.ts +++ b/VINScanner/tests/pages/VinScannerPage.ts @@ -8,7 +8,6 @@ export class VinScannerPage { private page: Page; private headerLabel: Locator; private settingsModal: Locator; - private scanModeContainer: Locator; private startButton: Locator; private scanBarcodeButton: Locator; private scanTextButton: Locator; @@ -20,7 +19,7 @@ export class VinScannerPage { this.headerLabel = this.page.locator(".scan-mode"); this.settingsModal = this.page.locator(".settings-modal-content"); this.startButton = this.page.locator(".start-btn"); - this.scanModeContainer = this.page.locator(".scan-mode-content"); + this.scanBarcodeButton = this.page.locator("#scan-barcode-btn"); this.scanTextButton = this.page.locator("#scan-text-btn"); this.scanBothButton = this.page.locator("#scan-both-btn"); @@ -72,8 +71,8 @@ export class VinScannerPage { } async getHeaderLabel(expectedText?: string) { - // await this.headerLabel.waitFor({ state: 'visible', timeout: 5000 }); await this.page.waitForTimeout(3000); + // If expectedText is provided, wait for it to appear if (expectedText) { await this.headerLabel.waitFor({ state: 'visible', timeout: 5000}); @@ -90,16 +89,10 @@ export class VinScannerPage { await this.settingsModal.waitFor({ state: "visible" }); } - async waitForPageLoad() { - await this.page.waitForFunction(() => { - return (typeof cameraEnhancer !== undefined); - }, { timeout: 10000 }); - await this.scanModeContainer.waitFor({ timeout: 10000 }); - } - async clickStartButton() { await this.startButton.click(); - // await this.waitForPageLoad(); + + // Ensuring the page is loaded after clicked on the Start button await this.page.waitForLoadState('networkidle', {timeout: 30000}); await this.page.waitForLoadState('domcontentloaded'); }