← Back to Discord Forum

Is there a way to make browsers stay open after a test is finished?

sriram_36419posted in #help-playwright
Open in Discord

I have a use case where I need to spin up a browser, navigate to a section of the site and leave them on a page until they get killed by another process. Need this code in python.

Here's my code: `await page.goto("https://thoughtspot.okta.com/signin/verify/duo/web") await asyncio.sleep(10)

Switch to the iframe with the title "Duo Security"

iframe = page.frame_locator('iframe[title="Duo Security"]')

At this point, you're inside the iframe. You can locate and click your element within it.

element_within_iframe = iframe.locator('.row-label.push-label') await element_within_iframe.click()`

I want the browser to stay open after the last line of code.

This thread is trying to answer question "Is there a way to make browsers stay open after a test is finished using Python?"

4 replies

I don't use python for PW but try using time module.

import time ... time.sleep(300)


@abdomdata_41602 This will just pause the test for the given time. I want the test to end but the browser must not be closed.


@sriram_36419 Maybe try using page.pause(), it will stay open until you decide to end it. However, the test won't end until you do so.

If your plan is to wait till it executes your previous case then you should revise and fix that code as per has inbuilt mechanism for such operations! Use this as reference not a solution https://stackoverflow.com/questions/72462437/how-to-prevent-the-browser-from-closing-while-running-code-in-playwright-tests-i

Related Discord Threads

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.