Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor.getTextContent not trimming the stlying tag #265

Closed
sowjanyaboddeti opened this issue Nov 3, 2020 · 4 comments
Closed

Anchor.getTextContent not trimming the stlying tag #265

sowjanyaboddeti opened this issue Nov 3, 2020 · 4 comments
Assignees

Comments

@sowjanyaboddeti
Copy link

`

 

<style>   h6.additional-class-50612681{   line-height: 24px;   font-size: 22px;   letter-spacing: -1px;   }   </style>

 
  NEXT Biometrics receives initial purchase order of 5000 FAP20 sensors from new partner.
 


   
 
`

While getting anchor text from the above href link, getting the styling tag included. Is this expected for some URLs (like outliers for the general logic)

@rbri
Copy link
Member

rbri commented Nov 3, 2020

It will be a great help if you can prepare a pull request with a failing test case similar to com.gargoylesoftware.htmlunit.html.HtmlAnchor2Test.asText_getTextContent()

@sowjanyaboddeti
Copy link
Author

Created it #267

Submitted a PR in a public repo for the first -time. Please let me know if it doesn't look good.

@rbri
Copy link
Member

rbri commented Nov 4, 2020

Great, thanks.
Was simpler to understand your point based on the PR.
Have added a modified test com.gargoylesoftware.htmlunit.html.HtmlStyleTest.asText_getTextContent_insideDiv().

I think this is not a bug - the implementation works as expected (from my understanding) because getTextContent is a method inherited from org.w3c.dom.Node (see https://www.w3.org/TR/dom41/#dom-node-textcontent).

I guess for your case you have to use com.gargoylesoftware.htmlunit.html.DomNode.asText().

@rbri rbri self-assigned this Nov 4, 2020
@sowjanyaboddeti
Copy link
Author

asText() method works as expected. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants