Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the trade-off for disabling CSS in HTMLUnit?

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?

like image 305
David Michael Gang Avatar asked May 02 '13 15:05

David Michael Gang


1 Answers

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.

like image 109
North Avatar answered Nov 02 '22 11:11

North