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

`element fits gauge` fails, if element is only allowed as children of a specific element #98

Closed
DaniRey opened this issue Jul 19, 2019 · 0 comments

Comments

@DaniRey
Copy link
Member

commented Jul 19, 2019

Some elements, like tr or td are not allowed as direct children of body. They require table as their parent.

Imagine the document is

<html><head></head><body>
<table>
 <tr><td><img src="a.jpg"></img></td></tr>
 <tr><td><img src="b.jpg"></img></td></tr>
</body></html>

Then

val row = findAll(CssSelectorQuery("table>tr"))
for(row <- rows)
 row fits <tr><td><img src="@contains .jpg"></img></td></tr>
}

Will fail, because the outerHtml of every <tr> is parsed with Jsoup, which will remove <tr> if it is not within a <table>

@DaniRey DaniRey self-assigned this Jul 19, 2019
@DaniRey DaniRey added the bug label Jul 19, 2019
@DaniRey DaniRey added this to the 3.0.1 milestone Jul 19, 2019
DaniRey added a commit that referenced this issue Jul 22, 2019
 - Jsoup.parseBodyFragment will remove elements, if they miss a required parent
 - when parsing fragments, such parents are often missing, for example <tr> requires <tbody>, which requires <table>
 - the FragmentParser object provides the parseFragment method, which automatically provides the correct context, based on the first element in the fragment
 - some elements require explicit wrapping, before parsing (i.e. <rp> and <rt>)
 - fixes #98
DaniRey added a commit that referenced this issue Jul 23, 2019
- add images for test content
DaniRey added a commit that referenced this issue Jul 23, 2019
- add images for test content
DaniRey added a commit that referenced this issue Jul 23, 2019
- remove trailing comma
@DaniRey DaniRey closed this in bdae3f1 Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.