Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
fix(browser-pool): make PlaywrightBrowser.browserType() return the browser type (#3981)
Martin Adámekd95cf20a677d
diff --git a/packages/browser-pool/src/playwright/playwright-plugin.ts b/packages/browser-pool/src/playwright/playwright-plugin.tsindex 26454f6ac..bcc24a061 100644--- a/packages/browser-pool/src/playwright/playwright-plugin.ts+++ b/packages/browser-pool/src/playwright/playwright-plugin.ts@@ -113,10 +113,12 @@ export class PlaywrightPlugin extends BrowserPlugin<});}- browser = new PlaywrightBrowserWithPersistentContext({+ const persistentBrowser = new PlaywrightBrowserWithPersistentContext({browserContext,version: this.#browserVersion,- }) as unknown as PlaywrightBrowser;+ });+ persistentBrowser.setBrowserType(this.library);+ browser = persistentBrowser as unknown as PlaywrightBrowser;}} catch (error) {await close();diff --git a/test/browser-pool/browser-plugins/plugins.test.ts b/test/browser-pool/browser-plugins/plugins.test.tsindex 855d59db9..0a843c27c 100644--- a/test/browser-pool/browser-plugins/plugins.test.ts+++ b/test/browser-pool/browser-plugins/plugins.test.ts@@ -626,6 +626,20 @@ describe('Plugins', () => {expect(version1).toEqual(browser.version());});+ test('should return browser type', async () => {+ const plugin = new PlaywrightPlugin(playwright[browserName]);++ const launchContext = plugin.createLaunchContext({ useIncognitoPages: false });+ browser = await plugin.launch(launchContext);+ expect(browser.browserType()).toBe(playwright[browserName]);++ await browser.close();++ const launchContext2 = plugin.createLaunchContext({ useIncognitoPages: true });+ browser = await plugin.launch(launchContext2);+ expect(browser.browserType()).toBe(playwright[browserName]);+ });+test('should return all contexts', async () => {const plugin = new PlaywrightPlugin(playwright[browserName]);