RE: Creating an org.apache.tapestry5.dom.Document from client-side page source

Davide Vecchi <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <[email protected]>
I'm not sure what exactly is so surprising, anyway if you mean why I want to test in that way, it's because the test must fail if certain texts are present anywhere in the page except for a certain div where their possible presence must be ignored. So I thought removing that div from the DOM and inspecting the rest was the easiest way (and apparently I was wrong).

If you were talking about something else just let me know.


-----Original Message-----
From: Lance Java [mailto:[email protected]] 
Sent: Thursday, April 6, 2017 17:32
To: Tapestry users <[email protected]>
Subject: Re: Creating an org.apache.tapestry5.dom.Document from client-side page source

Why on earth would you do that?

On 6 Apr 2017 16:20, "Davide Vecchi" <[email protected]> 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.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.