Search code examples
javaseleniumselenium3

How Selenium 3 operate web elements


Selenium 2 injects JavaScript to do actions such as click.

How does Selenium 3 work?


Solution

  • It's Selenium RC that used Javascript engine :) And it cause a lot of issues besides of being a JS framework. For example, different browsers apply security limitations to Javascript, so many things became impossible and restricted.

    Therefore, with the release of Selenium 2 (Selenium WebDriver), it has been deprecated in favor of drivers that worked natively with the browser.

    Let's elaborate it a bit. So, Selenium RC:

    • Client libraries (different language implementation) communicate with Selenium RC server passing Selenese command (http request commands) for execution.
    • Selenium RC server passes Selenium command to the browser using Selenium Core JavaScript commands.
    • Those JS commands “injected” by the server in beginning of testings into the browser.
    • Browser, using its JS interpreter, executes the command.

    So, Selenium RC architecture looks like that:

    enter image description here

    Now, Selenium 2 deprecated all this RC-JS-Injecting magic. Instead, WebDriver communicated (with http requests based command) with browser drivers that communicated with the browser in a native way (using browser atoms). And, the Selenium project was the one responsible for providing the drivers for each browser! Remember this one, it will be important in the next paragraph ;)

    Selenium 2 architecture is as follows (note the native calls):

    enter image description here

    In Selenium 3, all the major browser vendors ship their own WebDriver implementations (Apple, Google, Microsoft, and Mozilla). And because the browser vendors know their browsers better than anyone, their WebDriver implementations can be tightly coupled to the browser, leading to a better testing experience for you. Also, all the trails of Selenium RC were deleted. Hooray!

    So Selenium 3 operate WebElements with native calls (as Selenium 2) executed by the driver, but, this time, browser drivers are developed by the browser vendors.