This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
The command to get page source is not yet defined in the specification. The DOM Parsing specification mentions an XMLSerializer interface which barancev says FirefoxDriver is already using: http://domparsing.spec.whatwg.org/#xmlserializer The algorithm they use for XML serialization is here: http://domparsing.spec.whatwg.org/#concept-serialize-xml It should be made clear in a note or something that the stringified DOM we return doesn't necessarily correctly reflect the active DOM as it would've been seen if inspecting the DOM through a debugger. With more tactful prose.
Created attachment 1491 [details] Example After having examined this closer I think what we want is to call outerHTML on the documentElement instead, which “[…] represents the markup of the Element and its contents”: http://domparsing.spec.whatwg.org/#outerhtml This seems to be closer to the intended behaviour of getting the current DOM and will work on both HTML and XHTML type documents. So the spec should simply refer to the DOM Parsing spec's definition of outerHTML without making any special guarantees or promises. We should however add a note saying something along the lines of this: “Note: The details of the outerHTML serialization may be subject to user agent details. For example the sequence order of attributes on DOM nodes is unspecified.” There are also the following provisions in the spec about error handling: * Throws InvalidStateError if element in an XML document cannot be serialized to XML * Throws SyntaxError if the given string is not well-formed * Throws NoModificationAllowedError if the parent of the element is a document node The two first are theoretical in our case as there's a limited number of XHTML documents out there that are both ill-formed /and/ which modify the DOM to become invalid at runtime. The third is irrelevant in our case as we will always be calling this at the document.documentElement. We could raise an "invalid element state" in this case.
it was decided not to add pageSource to the spefication so closing. To get the same result the local end can do > driver.executeScript("return document.querySelector(':root').outerHTML")