playwriter 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/mcp.test.ts CHANGED
@@ -610,8 +610,8 @@ describe('MCP Server Tests', () => {
610
610
  expect(results).toMatchInlineSnapshot(`
611
611
  [
612
612
  {
613
- "title": "",
614
- "url": "about:blank",
613
+ "title": "🎄 Twelve Days of Shell 🎄",
614
+ "url": "https://12days.cmdchallenge.com/",
615
615
  },
616
616
  {
617
617
  "title": "Example Domain",
@@ -696,8 +696,8 @@ describe('MCP Server Tests', () => {
696
696
  expect(results).toMatchInlineSnapshot(`
697
697
  [
698
698
  {
699
- "title": "",
700
- "url": "about:blank",
699
+ "title": "🎄 Twelve Days of Shell 🎄",
700
+ "url": "https://12days.cmdchallenge.com/",
701
701
  },
702
702
  {
703
703
  "title": "Example Domain",
@@ -762,18 +762,18 @@ describe('MCP Server Tests', () => {
762
762
  const pages = await browserContext.pages()
763
763
  expect(pages.length).toBeGreaterThan(0)
764
764
  const page = pages[0]
765
-
765
+
766
766
  await page.goto('https://example.com/disconnect-test')
767
767
  await page.waitForLoadState('networkidle')
768
768
  await page.bringToFront()
769
-
769
+
770
770
  // Enable extension on this page
771
771
  const initialEnable = await serviceWorker.evaluate(async () => {
772
772
  return await globalThis.toggleExtensionForActiveTab()
773
773
  })
774
774
  console.log('Initial enable result:', initialEnable)
775
775
  expect(initialEnable.isConnected).toBe(true)
776
-
776
+
777
777
  // Wait for extension to fully connect
778
778
  await new Promise(resolve => setTimeout(resolve, 500))
779
779
 
@@ -790,7 +790,7 @@ describe('MCP Server Tests', () => {
790
790
  `,
791
791
  },
792
792
  })
793
-
793
+
794
794
  const beforeOutput = (beforeDisconnect as any).content[0].text
795
795
  expect(beforeOutput).toContain('foundTestPage')
796
796
  console.log('Before disconnect:', beforeOutput)
@@ -800,7 +800,7 @@ describe('MCP Server Tests', () => {
800
800
  await serviceWorker.evaluate(async () => {
801
801
  await globalThis.disconnectEverything()
802
802
  })
803
-
803
+
804
804
  // Wait for disconnect to complete
805
805
  await new Promise(resolve => setTimeout(resolve, 500))
806
806
 
@@ -815,7 +815,7 @@ describe('MCP Server Tests', () => {
815
815
  `,
816
816
  },
817
817
  })
818
-
818
+
819
819
  const afterDisconnectOutput = (afterDisconnect as any).content[0].text
820
820
  console.log('After disconnect:', afterDisconnectOutput)
821
821
  expect(afterDisconnectOutput).toContain('Pages after disconnect: 0')
@@ -829,10 +829,10 @@ describe('MCP Server Tests', () => {
829
829
  console.log('toggleExtensionForActiveTab result:', result)
830
830
  return result
831
831
  })
832
-
832
+
833
833
  console.log('Reconnect result:', reconnectResult)
834
834
  expect(reconnectResult.isConnected).toBe(true)
835
-
835
+
836
836
  // Wait for extension to fully reconnect and relay server to be ready
837
837
  console.log('Waiting for reconnection to stabilize...')
838
838
  await new Promise(resolve => setTimeout(resolve, 1000))
@@ -863,25 +863,25 @@ describe('MCP Server Tests', () => {
863
863
  console.log('Checking pages after reconnect...');
864
864
  const pages = context.pages();
865
865
  console.log('Pages after reconnect:', pages.length);
866
-
866
+
867
867
  if (pages.length === 0) {
868
868
  console.log('No pages found!');
869
869
  return { pagesCount: 0, foundTestPage: false };
870
870
  }
871
-
871
+
872
872
  const testPage = pages.find(p => p.url().includes('disconnect-test'));
873
873
  console.log('Found test page after reconnect:', !!testPage);
874
-
874
+
875
875
  if (testPage) {
876
876
  console.log('Test page URL:', testPage.url());
877
877
  return { pagesCount: pages.length, foundTestPage: true, url: testPage.url() };
878
878
  }
879
-
879
+
880
880
  return { pagesCount: pages.length, foundTestPage: false };
881
881
  `,
882
882
  },
883
883
  })
884
-
884
+
885
885
  const afterReconnectOutput = (afterReconnect as any).content[0].text
886
886
  console.log('After reconnect:', afterReconnectOutput)
887
887
  expect(afterReconnectOutput).toContain('foundTestPage')
@@ -900,11 +900,11 @@ describe('MCP Server Tests', () => {
900
900
  // Clear any existing logs from previous tests
901
901
  clearAllLogs();
902
902
  console.log('Cleared all existing logs');
903
-
903
+
904
904
  // Verify connection is working
905
905
  const pages = context.pages();
906
906
  console.log('Current pages count:', pages.length);
907
-
907
+
908
908
  return { success: true, pagesCount: pages.length };
909
909
  `,
910
910
  },
@@ -996,7 +996,7 @@ describe('MCP Server Tests', () => {
996
996
  `,
997
997
  },
998
998
  })
999
-
999
+
1000
1000
  const beforeReloadOutput = (beforeReloadResult as any).content[0].text
1001
1001
  expect(beforeReloadOutput).toContain('[log] Before reload 99999')
1002
1002
 
@@ -1025,7 +1025,7 @@ describe('MCP Server Tests', () => {
1025
1025
  `,
1026
1026
  },
1027
1027
  })
1028
-
1028
+
1029
1029
  const afterReloadOutput = (afterReloadResult as any).content[0].text
1030
1030
  expect(afterReloadOutput).toContain('[log] After reload 88888')
1031
1031
  expect(afterReloadOutput).not.toContain('[log] Before reload 99999')
@@ -1357,6 +1357,60 @@ describe('MCP Server Tests', () => {
1357
1357
  await page.close()
1358
1358
  }, 60000)
1359
1359
 
1360
+ it('should work with stagehand', async () => {
1361
+ if (!browserContext) throw new Error('Browser not initialized')
1362
+ const serviceWorker = await getExtensionServiceWorker(browserContext)
1363
+
1364
+ await serviceWorker.evaluate(async () => {
1365
+ await globalThis.disconnectEverything()
1366
+ })
1367
+ await new Promise(r => setTimeout(r, 500))
1368
+
1369
+ const targetUrl = 'https://example.com/'
1370
+
1371
+ const enableResult = await serviceWorker.evaluate(async (url) => {
1372
+ const tab = await chrome.tabs.create({ url, active: true })
1373
+ await new Promise(r => setTimeout(r, 1000))
1374
+ return await globalThis.toggleExtensionForActiveTab()
1375
+ }, targetUrl)
1376
+
1377
+ console.log('Extension enabled:', enableResult)
1378
+ expect(enableResult.isConnected).toBe(true)
1379
+
1380
+ await new Promise(r => setTimeout(r, 1000))
1381
+
1382
+ const { Stagehand } = await import('@browserbasehq/stagehand')
1383
+
1384
+ const stagehand = new Stagehand({
1385
+ env: 'LOCAL',
1386
+ verbose: 1,
1387
+ disablePino: true,
1388
+ localBrowserLaunchOptions: {
1389
+ cdpUrl: getCdpUrl(),
1390
+ },
1391
+ })
1392
+
1393
+ console.log('Initializing Stagehand...')
1394
+ await stagehand.init()
1395
+ console.log('Stagehand initialized')
1396
+
1397
+ const context = stagehand.context
1398
+ console.log('Stagehand context:', context)
1399
+ expect(context).toBeDefined()
1400
+
1401
+ const pages = context.pages()
1402
+ console.log('Stagehand pages:', pages.length, pages.map(p => p.url()))
1403
+
1404
+ const stagehandPage = pages.find(p => p.url().includes('example.com'))
1405
+ expect(stagehandPage).toBeDefined()
1406
+
1407
+ const url = stagehandPage!.url()
1408
+ console.log('Stagehand page URL:', url)
1409
+ expect(url).toContain('example.com')
1410
+
1411
+ await stagehand.close()
1412
+ }, 60000)
1413
+
1360
1414
  })
1361
1415
 
1362
1416
 
@@ -28,10 +28,10 @@ Return value:
28
28
  - generic [ref=e21]:
29
29
  - generic: ⌘
30
30
  - generic: K
31
- - link "100.8k" [ref=e22] [cursor=pointer]:
31
+ - link "100.5k" [ref=e22] [cursor=pointer]:
32
32
  - /url: https://github.com/shadcn-ui/ui
33
33
  - img
34
- - generic [ref=e23]: 100.8k
34
+ - generic [ref=e23]: 100.5k
35
35
  - button "Toggle theme" [ref=e24]:
36
36
  - img
37
37
  - generic [ref=e25]: Toggle theme