I have a question.
What makes FirefoxDriver be able to locate WebElements and click on them in a java code but when running the same code with HtmlUnitDriver the same WebElements are not located. Also when running the same code on HtmlUnit(applying HtmlUnit principles) WebElements are not found, in fact the code return NullPointerException. Is there a particular reason?
Without seeing your code, I might hazard a guess that it might be because you need to enable javascript.
JavaScript is disabled by default in the HtmlUnitDriver.
If you look at the source constructor at(LICENSE Apache 2.0)
https://github.com/SeleniumHQ/htmlunit-driver/blob/master/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java#L166
And the other constructors at https://github.com/SeleniumHQ/htmlunit-driver/blob/master/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitDriver.java#L143-L158
You see that they provide a default false if the variable isn't provided.
So to enable javascript in the HtmlUnitDriver you'll need to provide true when initializing it, that you want JavaScript components active in it.