question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

com.gargoylesoftware.htmlunit.html.DomNode.asText() returns nested elements with linebreaks

See original GitHub issue

In the case of nested elements, the text of span element is output with linebreaks:

<span>
    <select name="day" size="1">...</select>
    <select name="month" size="1">...</select>
    <select name="year" size="1">...</select>    
</span>

output: 1 JAN 2021

Therefore, real line breaks, like < /br> cannot be distinguished in output text from blocks. This worked fine in the earlier versions like 2.18 It seems that the status is set incorrectly after a block, see: com.gargoylesoftware.htmlunit.html.HtmlSerializer.HtmlSerializerTextBuilder.append(String, Mode)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
rbricommented, Feb 26, 2021

Hi @dennisduysak ,

this is work in progress, i have not done much on this. The plan is

  • to introduce the new method and make the old deprecated (done)
  • switch from system dependent line separator to \n (done)
  • make unit tests for at least all the cases we have unit test for the old method
  • make sure to remove all the special cases we have implemented in the old hierarchy - have test for all the cases and adapt the impl to something meaningful (at this step your case might be fixed)
  • cleanup, add more tests and release

But please keep in mind i do all this in my spare time, having a real >40h per week job - means any help is welcome.

0reactions
dennisduysakcommented, May 7, 2021

Hi @rbri , I saw that the changes for the select tags are already commited. Thanks a lot for this! However, the tables are still incorrectly formatted (see unit tests of HtmlTableTest.java in coment before). Is it possible to format them in the same way like the select tags?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changes - HtmlUnit - SourceForge
DomNode #asText() is now deprecated. rbri. Update, HtmlSerializerVisibleText moved into separate package 'com.gargoylesoftware.htmlunit.html.serializer'.
Read more >
DomNode (HtmlUnit 2.67.0 API) - SourceForge
Returns a string representation of the XML document from this element and all it's children (recursively). protected void, basicRemove().
Read more >
HtmlElement (HtmlUnit 2.67.0 API)
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode ... Appends a child element to this HTML element with the specified tag name if this ...
Read more >
HtmlMark (HtmlUnit 2.67.0 API)
Nested classes/interfaces inherited from class com.gargoylesoftware.htmlunit.html ... Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode.
Read more >
DomElement (HtmlUnit 2.67.0 API)
Fields inherited from class com.gargoylesoftware.htmlunit.html.DomNode ... Returns the first child element node of this element. String · getId().
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found