playwright-java
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))
Version
1.43.0
Steps to reproduce
- launchPersistentContext to open browser with extension
- Do a specific action which launches a new tab.
- Get the count of pages using browserContext.pages().
- 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
@yury-s : Could you please help me here
Please provide a complete example which we could use to reproduce the issue locally.
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(); });
It has something to do with the extension. I cannot reproduce it with regular web pages. We need complete reproduction example.
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.