When runing on headless browser it fails at 'switch to window'

When I run without headless, full test runs without any fail. But when I run on headless browser it stays stuck at 97%. I suspected that it fails at ‘switch to window’ action (as headless may not have any window). Then I disabled those lines (line-10,11,12 in my case) and then test ran without any fail on headless browser. Can anyone help me out here please? Is there any way I can know programmatically whether I’m running on headless or not, so that I could make those three lines conditional. BTW, in this test line#9 opens a PDF file on a browser tab.

Hi @shibleemehdi,
Can you share the error message you are getting?

It remains stuck in that percentage when I run headless. If I disable line#10,11,12 then it does not stuck.

Please send your logs to support@testproject.io