
Question:
I know this is sort of counter to the purpose of headless automation, but...
I've got an automation test running using Selenium and Chromedriver in headless mode. I'd prefer to keep it running headless, but occasionally, it runs into an error that really needs to be looked at and interacted with. Is it possible to render and interact with a headless session? Maybe by duplicating the headless browser in a non-headless one? I can connect through remote-debugging, but the Dev Tools doesn't seem to do allow me to view the rendered page or interact with anything.
I am able to take screenshots, which sort of helps. But I'm really looking for the ability to interact--there's some drag-and-drop elements that aren't working well with Selenium that are causing issues occasionally.
Answer1:What you are asking for is currently not possible. Further, such a "feature" would have nothing to do with Selenium, but the vendor of the browser. You can search their bug tracker to see if such a feature has already been requested.
The only currently available option is to run full GUI browser during debug / development of your tests.
Answer2:<strong>No</strong>, it is not possible to open/display/render a headless Selenium session.
Following are the steps you can take as per your situation/requirement :
<ul><li><em>Chromedriver in headless mode occasionally it runs into an error</em> : Put the error prone code block in a <a href="http://www.pythonforbeginners.com/error-handling/python-try-and-except" rel="nofollow">try-except
</a> block and debug the root cause. You can take a screenshot as well.
<em>Can I connect through remote-debugging</em> : No you won't be able to connect to any existing session. A detailed discussion <a href="https://stackoverflow.com/questions/47861813/how-can-i-reconnect-to-the-browser-opened-by-webdriver-with-selenium/47862867#47862867" rel="nofollow">here</a>.
</li> <li><em>Drag-and-Drop elements that aren't working well</em> : Get the page source and examine the elements and decide a proper <a href="https://stackoverflow.com/questions/48369043/official-locator-strategies-for-the-webdriver/48376890#48376890" rel="nofollow"><em>Locator Strategy</em></a>
</li> </ul>