playwright-java icon indicating copy to clipboard operation
playwright-java copied to clipboard

BrowserContext.pages() does not return the exact count of pages when new pages are launched by application under test (browser with extension))

Open Mani-151 opened this issue 9 months ago • 4 comments

Version

1.43.0

Steps to reproduce

  1. launchPersistentContext to open browser with extension
  2. Do a specific action which launches a new tab.
  3. Get the count of pages using browserContext.pages().
  4. I have used page = browserContext.waitForPage(() -> {}); still seeing an issue

Expected behavior

browserContext.pages() should return the count of the pages which currently open

Actual behavior

browserContext.pages() does not return the count of new tabs which are opened by application under test

Additional context

No response

Environment

Macbook, Chromium , Java 11

Mani-151 avatar May 02 '24 20:05 Mani-151

@yury-s : Could you please help me here

Mani-151 avatar May 04 '24 19:05 Mani-151

Please provide a complete example which we could use to reproduce the issue locally.

yury-s avatar May 07 '24 15:05 yury-s

I am sharing the below code, Could please check if the below code snippet can give you a better idea of the scenario which i am trying. the application URL has restricted access, hence could not share the URL.

String extensionDirPath = PathToExtension List<String> args = new ArrayList<>(Arrays.asList( "--disable-extensions-except=" + extensionDirPath, "--load-extension=" + extensionDirPath, "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream" )); BrowserType browserType = playwright.chromium(); context = browserType.launchPersistentContext(tempUserDataDir, new BrowserType.LaunchPersistentContextOptions() .setHeadless(false) .setArgs(args) Page page = context.newPage(); Page.navigate("application URL"); page.click("Xpath to button"); //This page opens up new tab

context.pages() --> Returns 1 , but expecting 2 as new tab is opened by click action which. If we wait for 5-10 seconds , we are seeing the value as 2.

I tried using below

page=context().waitForPage(() -> { page.locator('element locator').isVisible(); });

Mani-151 avatar May 08 '24 18:05 Mani-151

It has something to do with the extension. I cannot reproduce it with regular web pages. We need complete reproduction example.

yury-s avatar May 08 '24 19:05 yury-s

Closing as part of the triage process since it seemed stale. Please create a new issue with a detailed reproducible or feature request if you still face issues.

mxschmitt avatar May 20 '24 14:05 mxschmitt