Why on earth would you do that? On 6 Apr 2017 16:20, "Davide Vecchi" <d...@amc.dk> wrote:
Hi everybody I am writing a Selenium test to test a Tapestry 5.3.8 web app, and in that test I retrieved the whole client-side page source into a String. It's a regular HTML page generated by Tapestry. Nothing special about it, it starts with <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> .... and it ends with ...... </body></html> I need to create an org.apache.tapestry5.dom.Document instance from that page source, manipulate its DOM, turn the resulting Document back into a string, and make assertions about this string. My problem is only that I can't seem to be able to do the first step, that is create the Document instance from my String containing the page source. I tried MarkupWriter (its write() and writeRaw() methods): MarkupWriter writer = new MarkupWriterImpl(); writer.write(htmlText); // writer.writeRaw(htmlText); Document document = writer.getDocument(); but then document does not contain the DOM elements that were in htmlText (which is the String containing the page source), and document.getDocumentElement() returns null. I have tried other variations still with MarkupWriter, Document and all their methods that seemed related, but I got nothing. I'm sure I'm just missing something trivial. Does anyone know ? If possible I'd prefer a Tapestry solution, where the created object is an org.apache.tapestry5.dom.Document, but if it's necessary to get a org.w3c.dom.Document instead, or to use something else outside Tapestry, I would still go for it. Thanks in advance.