[Python] Lost url while using playwright to open new page in python

Discussão em 'Python' iniciado por Stack, Fevereiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have two pages, page0 and page1. I clicked a button in page1, and it popup a blank page to load for 3-5 minutes. After that, it will popup a new page, and close all the pages except page0. However, playwright lost the final page url. it only has the first page's url.

    Here's my code

    async with self.context.expect_event('page', timeout = 60000) as page2_info:
    await page1.locator('#fraInterface").content_frame.get_by_role("button", name = "Finish Input").click()


    In this case, I should find two urls with this code:

    self.context.pages


    If anyone can help me to solve this problem, I'll be really grateful!

    I tried to use two async to find the url, but it did not work. I also tried to use different method, such as change context.expect_event('page') to page1.expect_popup(). Both can not work in this situation.

    Continue reading...

Compartilhe esta Página