|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | + |
| 3 | +/* |
| 4 | +1. Test the read an image page should have the correct header. |
| 5 | +2. Test the read an image page should have the correct main heading. |
| 6 | +3. Test the read an image page should have the results field. |
| 7 | +4. Test the read an image page should have input selector to select an image file as input and parsed in the results field.. |
| 8 | +*/ |
| 9 | + |
| 10 | +const URL = '/hello-world/read-an-image.html'; |
| 11 | + |
| 12 | +test.beforeEach(async ({ page }) => { |
| 13 | + await page.goto(URL); |
| 14 | +}); |
| 15 | + |
| 16 | +test('should have correct title', async ({ page }) => { |
| 17 | + const title = await page.title(); |
| 18 | + expect(title).toBe("Dynamsoft Barcode Reader Sample - Hello World (Read an Image)"); |
| 19 | +}); |
| 20 | + |
| 21 | +test('should have main heading', async ({ page }) => { |
| 22 | + const h1 = await page.locator('h1'); |
| 23 | + expect(h1).not.toBeNull(); |
| 24 | + await expect(h1).toHaveText('Hello World (Read an Image)'); |
| 25 | +}); |
| 26 | + |
| 27 | +test('should have result containers', async ({ page }) => { |
| 28 | + const resultsContainer = await page.locator('#results'); |
| 29 | + expect(resultsContainer).not.toBeNull(); |
| 30 | +}); |
| 31 | + |
| 32 | +test('should be able to select an image file as an input and parsed the Barcodes in the results', async ({ page }) => { |
| 33 | + const fileSelector = await page.locator('input#input-file'); |
| 34 | + await expect(fileSelector).toBeVisible(); |
| 35 | + const fileChooserPromise = page.waitForEvent('filechooser'); |
| 36 | + await fileSelector.click(); |
| 37 | + const fileChooser = await fileChooserPromise; |
| 38 | + await expect(fileChooser.isMultiple()).toBe(true); |
| 39 | + await fileChooser.setFiles('./tests/image-src/ABC.png'); |
| 40 | + |
| 41 | + const results = await page.locator('#results'); |
| 42 | + await expect(results).toContainText("Dynamsoft-948743540084"); |
| 43 | + await expect(results).toContainText("Dynamsoft-162323263989"); |
| 44 | + await expect(results).toContainText("Dynamsoft-052408584613"); |
| 45 | + |
| 46 | +}); |
| 47 | + |
0 commit comments