-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Playwright in typescript supports accessing the browser name with its string name like :
const playwright = require('playwright');
(async () => {
for (const browserType of ['chromium', 'firefox', 'webkit']) {
const browser = await playwright[browserType].launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://whatsmyuseragent.org/');
await page.screenshot({ path: `example-${browserType}.png` });
await browser.close();
}
})();
Whereas in python, it will errors as the playwright object is not subscriptable
TypeError: 'Playwright' object is not subscriptable
Playwright should make the playwright subscriptable to be able to dynamically launch browser from string
TBD API:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
for browser_type in ["chromium", "firefox", "webkit"]:
browser = p[browser_type].launch()
page = browser.new_page()
page.goto("http://whatsmyuseragent.org/")
page.screenshot(path=f"example-{browser_type.name}.png")
browser.close()
pavelfeldman and mxschmitt