playwright-fluent
                                
                                
                                
                                    playwright-fluent copied to clipboard
                            
                            
                            
                        Reusing a browser instance rather than starting browser for each tests
Is your feature request related to a problem? Please describe. Starting a browser for each test takes time. We could make a test campaigns faster by reusing single browser instance.
Describe the solution you'd like I would like to use one and only one browser instance and to create a context for each test. However this could have pitfalls for those who try to use parallelism. We should have the choice between using a single instance or not.
BR
Franck
@franckLdx You can achieve such behaviour by creating new context in existing browser:
public async startNewIncognitoTab(playwrightFluent: PlaywrightFluent, options?: BrowserContextOptions): Promise<PlaywrightFluent> { const browser = await playwrightFluent.currentBrowser(); const context = await browser.newContext(options); const page = await context.newPage(); return new PlaywrightFluent(browser, page); }
Just close context after each test instead of browser, and then close browser once after all tests. Also new context will provide you with isolation on session level so your tests will not affect each other in parallel run.
Hi @osolomin90 , your solution is awesome ! Did not know it was possible to use my lib in such a way :)