This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test, expect, Page } from '@playwright/test'; | |
import { createMachine } from 'xstate'; | |
import { createModel } from '@xstate/test'; | |
let page: Page; | |
test.describe('Playwright document search', () => { | |
const documentationSearchMachine = createMachine({ | |
id: 'documentSearch', | |
initial: 'idle', | |
states: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {test, expect} from '@playwright/test'; | |
test('validate a complex pdf II, all pages', async ({page}) => { | |
const numberOfPages = 2; | |
for (let i = 1; i < numberOfPages + 1; i += 1) { | |
let pdfResource = | |
'https://oedtrngbj.wpengine.com/wp-content/uploads/Powerwall_2_AC_Datasheet_EN_NA.pdf'; | |
let iframe = `<iframe src="${pdfResource}#zoom=60&page=${i}" style="width: 100%;height:100%;border: none;"></iframe>`; | |
await page.setContent(iframe); | |
await page.waitForTimeout(5000); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// package.json | |
{ | |
"name": "fancy_vscode_launch_profiles", | |
"version": "1.0.0", | |
"scripts": { | |
"vscode-debug": "playwright test --config ./playwright.config.ts --workers=1" | |
}, | |
"devDependencies": { | |
"@playwright/test": "^1.22.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PDFParser from 'pdf2json'; | |
import { test, expect } from '@playwright/test'; | |
test.describe('assert PDF contents using Playwright', () => { | |
let pdfContents: any | |
test.beforeAll(async () => { | |
pdfContents = await getPDFContents('./pdf_sample.pdf') | |
}) | |
test('pdf file should have 6 pages', async () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { test, expect } from '@playwright/test'; | |
import * as fs from 'fs/promises' | |
test.describe('use Playwright to easliy download a file from remote server', () => { | |
test('able to download a remote file to disk', async ({ page }, testInfo) => { | |
const baseUrl = 'https://www.tesla.com/' | |
const resource = 'ns_videos/2021-tesla-impact-report.pdf' | |
const getResp = await page.context().request.get(`${baseUrl}${resource}`) | |
expect(getResp.ok()).toBe(true) |