7

I experienced slowness in HTMLUnit 2.12, and therefore disabled CSS as explained in HTMLUnit : super slow execution?.

I want to understand what the trade-off is. Does it mean that I cannot use XPath selectors? Are there other tradeoffs?

Community
  • 1
  • 1
David Michael Gang
  • 7,107
  • 8
  • 53
  • 98
  • 1
    I don't think disabling CSS has anything to do with XPath expressions. I actually _think_ (not tested) you should be able to use CSS selectors, too, because they work on the current DOM structure and they don't do anything with actual CSS. Anyway, did you test anything of this? Did you resolve the question? Did you try contacting HTMLUnit developers? – Petr Janeček Jul 24 '13 at 09:37

1 Answers1

3

XPath selectors only take into account the html/xml document. CSS does not affect your queries. If it would then it would have non-deterministic results based on whatever CSS rule was applied.

As far as CSS selectors and XPath selectors go, you can safely use those without loading any CSS beforehand. Loading them will have no effect on the result you will receive.

For the CSS to have any influence on your usage of HTMLUnit is for your code or the JavaScript code loaded to depend on the computed style of the elements.

North
  • 90
  • 4