Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Mani-151 opened this issue May 2, 2024 · 5 comments

Comments

@Mani-151
Copy link

Mani-151 commented May 2, 2024

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
Copy link
Author

Mani-151 commented May 4, 2024

@yury-s : Could you please help me here

@yury-s
Copy link
Member

yury-s commented May 7, 2024

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

@Mani-151
Copy link
Author

Mani-151 commented May 8, 2024

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 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();
});

@yury-s
Copy link
Member

yury-s commented May 8, 2024

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

@mxschmitt
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants