% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/browser.R
\name{browser_dom}
\alias{browser_dom}
\title{Execute JavaScript on an HTML page via a headless browser and dump the DOM}
\usage{
browser_dom(input, output = NULL, fragment = FALSE, browser = NULL)
}
\arguments{
\item{input}{Path or URL to the HTML page.}

\item{output}{An optional output file path. If not provided, the rendered
HTML is returned as a character string.}

\item{fragment}{Whether to return only the inner body content instead of the
full HTML document.}

\item{browser}{Path to the web browser. By default, the browser is found via
\code{xfun:::find_browser()}. If it cannot be found, you may set the global
option \code{options(xfun.browser = )} or environment variable \code{R_XFUN_BROWSER}
to the path of the browser, or simply pass the path to the \code{browser}
argument.}
}
\value{
If \code{output} is \code{NULL}, the rendered HTML as a character string;
otherwise the \code{output} path (invisibly).
}
\description{
Load an HTML page in a headless browser (Chromium/Chrome/Edge), execute all
JavaScript on it, and return (or save) the rendered DOM as HTML.
}
\examples{\dontshow{if (interactive()) \{}
f = tempfile(fileext = '.html')
writeLines(c(
  '<html><body><div id="out"></div>',
  '<script>document.getElementById("out").textContent = "hello";</script>',
  '</body></html>'
), f)
xfun::browser_dom(f)
\dontshow{\}}
}
