← Back to Discord Forum

Why Playwright take extra time to finish even though the test has passed?

While the test has passed, Playwright still needs extra time to finish. I don't understand why. I previously posted my question on stackflow https://stackoverflow.com/questions/77285008/why-playwright-take-extra-time-to-finish-even-though-the-test-has-passed but no one responsed. Hope to get some help here! Thanks

This thread is trying to answer question "Why does Playwright take extra time to finish even though the test has passed?"

14 replies

Do you have trace we could look at? Otherwise we can only guess.

@skorp32 trace and report do not help in my case. It seems that they only show what happens during the test, not what happens after the test. Here my test only takes 1.6s to be passed, but PlayWright total time cost is 9.1s.


traces also show teardown steps

if teardown looks ok then most likely browser closing is slow

Where can I view the teardown steps?


after hooks

looks ok though

run test with debug flag

DEBUG=pw:browser* npx playwright test...

it will print in console how much time it takes to launch, close, etc

Running 1 test using 1 worker
[Microsoft] › baidu.spec.ts:3:6 › example
  pw:browser <launching> C:\Program Files                                       ...                                                                                    
  pw:browser [pid=12760][err] [12760:31008:1017/181140.355:ERROR:policy_logger.cc(154)] :components\enterprise\browser\controller\chrome_browser_cloud_management_controller.cc(163) Cloud management controller initialization aborted as CBCM is not enabled. +120ms
  pw:browser [pid=12760][err] [12760:31008:1017/181140.377:ERROR:assistance_home_client.cc(32)] File path C:\Users\yueji\AppData\Local\Temp\playwright_chromiumdev_profile-kUjLpa\Default +21ms                    
  pw:browser [pid=12760] <gracefully close start> +2s
  pw:browser [pid=12760] <process did exit: exitCode=0, signal=null> +6s
  pw:browser [pid=12760] starting temporary directories cleanup +0ms                                                                                                                                               
  pw:browser [pid=12760] exception while removing C:\Users\yueji\AppData\Local\Temp\playwright_chromiumdev_profile-kUjLpa: Error: EPERM: operation not permitted, unlink 'C:\Users\yueji\AppData\Local\Temp\playwright_chromiumdev_profile-kUjLpa\CrashpadMetrics-active.pma' +8ms
  pw:browser [pid=12760] finished temporary directories cleanup +0ms                                                                                                                                               
  pw:browser [pid=12760] <gracefully close end> +0ms

<process did exit: exitCode=0, signal=null> +6s

That would be strange, Since test 'visit google.com' spend +3 seconds to exit but test 'visit baidu.com' spend +6 seconds to exit. It also spend several seconds for some of my localhost projects to exit after each test.

you can try to file an issue on github with these logs and comparison between first url and second url

Thanks for your help @skorp32 !

Wonder if there is some kind of anti virus stuff going on too. Seeing "policy_logger", i remember when doing stuff in visual studio, anytime i build ran ran it took like 30+ seconds becaue the directory was getting scanned by my anti-virus... Added exception for my project bin folder the 30+ second decreased to less than 1...

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.