forked from commaai/new-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add playwright script to take screenshots (commaai#37)
- Loading branch information
1 parent
f1f68c9
commit 399d21e
Showing
3 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable */ | ||
const { webkit, devices } = require('playwright'); | ||
|
||
const base_url = process.argv[2]; | ||
const endpoints = { | ||
Login: 'login', | ||
RouteList: '1d3dc3e03047b0c7', | ||
RouteActivity: '1d3dc3e03047b0c7/000000dd--455f14369d', | ||
}; | ||
|
||
async function takeScreenshots(deviceType, context) { | ||
let page = await context.newPage() | ||
await page.goto(`${base_url}`) | ||
await page.click(`button:has-text('Try the demo')`) | ||
for (const endpoint in endpoints) { | ||
await page.goto(`${base_url}/${endpoints[endpoint]}`) | ||
await page.waitForTimeout(2000) | ||
await page.screenshot({path: `screenshots/${endpoint}-${deviceType}.png`}) | ||
} | ||
await page.close() | ||
} | ||
|
||
(async () => { | ||
const mobile_browser = await webkit.launch() | ||
const iphone_13 = devices['iPhone 13'] | ||
const mobile_context = await mobile_browser.newContext(iphone_13) | ||
await takeScreenshots('mobile', mobile_context) | ||
await mobile_browser.close() | ||
|
||
const desktop_browser = await webkit.launch() | ||
const desktop_context = await desktop_browser.newContext({viewport: { width: 1920, height: 1080 }}) | ||
await takeScreenshots('desktop', desktop_context) | ||
await desktop_browser.close() | ||
})() |