chrome-devtools-java-client icon indicating copy to clipboard operation
chrome-devtools-java-client copied to clipboard

How to avoid hang on extracting HTML content from non HTML page (solved)

Open andrewliles opened this issue 6 years ago • 0 comments

I was having a problem with this command when browsing to content that happened to be XML - the evaluation function hung indefinitely.

devToolsService.getRuntime().evaluate("document.documentElement.outerHTML")

Here is a work around:

Object contentType = devToolsService.getRuntime().evaluate("document.contentType");
if((contentType != null) && "text/html".equalsIgnoreCase(contentType.toString())) {
   devToolsService.getRuntime().evaluate("document.documentElement.outerHTML")
}

andrewliles avatar Apr 29 '19 09:04 andrewliles