Webdriver takes advantage of a browser's built-in support to map DOM elements to WebElement objects using id/xpath, among other methods.
The JavascriptExecutor.executeScript
runs an external script within the context of the currently active browser window (similar to extensions like grease monkey), and if the script returns a DOM element, it is converted into a WebElement object.
It can be said that WebDriver's simulated clicks on a browser mirror actual user interactions more closely compared to those triggered by Javascript.
In practice, not all events can be automated seamlessly across all web browsers, including different versions of the same browser (e.g., various versions of IE, FF, etc.). Nevertheless, WebDriver remains one of the best tools available for this purpose.
Around four years ago, we encountered issues with a specific version of IE where right clicks or mouse hovering on generated menu links was not possible through WebDriver, so we had to use JavaScript to simulate these actions in a browser-independent manner. This highlights the value of executing external JavaScript.
There are also automated web testing frameworks that rely solely on JavaScript instead of leveraging a browser's native capabilities. For example: http://en.wikipedia.org/wiki/Sahi_%28software%29
References: