Many a times I have seen various different people ask this same question in various different forms.. “How does WebDriver work”..
Here’s how I understand its working. Ofcourse I could never even remotely come close to the actual crystal clear explanation that Simon Stewart shared in this link. So please do spend sometime reading it to understanding things in a deeper fashion.
Here’s how it works on a high level.
You have a client binding based on your choice of language. The client binding basically gives you wrapper methods that help you interact with the web browser using selenium in an API like fashion.
You have a server component which basically adheres to the JSONWireProtocol and provides actual actions on the web browser, based on the JSONWireProtocol adherant calls.
The server component is implemented in different forms for different browsers:
- IE – IEDriverServer
- Chrome – ChromeDriver
- Firefox – A firefox plugin
- Safari – Safari Extension
- iOS – iOS driver which is basically a standalone java application which interacts internally with either the device/simulator.
- Android – Selendroid which is again a standalone java application which interacts internally with either the device/simulator.
This is how a typical flow happens.
When you basically do this :
WebDriver driver = new FirefoxDriver();
The constructor of FirefoxDriver internally does the following :
- Locates the firefox browser executable.
- Extracts the custom web driver firefox plugin which is embedded inside the codebase, puts it into a temp directory, creates an anonymous firefox profile into which it includes this plugin, and then feeds that to the firefox browser.
When you do something like this :
This call internally gets translated to New URL JSONWireProtocol command by the client bindings and then gets executed against the server component for the browser [ so in this case its against the firefox web driver plugin that is embedded into the firefox browser that was spawned ]. The server component translates the JSONWireProtocol command into an appropriate action on the browser [ in this case it loads the URL in the address bar of the browser and loads the URL ].
WebDriver is slowly moving towards an architectural approach wherein the browser manufacturers are expected to provide the server component against which the client bindings would be executed.
ChromeDriver is the result of that initiative. Microsoft is also working on building a similar server component for IE [ http://www.microsoft.com/en-in/download/details.aspx?id=44069 ]. This I believe would basically be a replacement for IEDriverServer binary that Jim Evans has created currently for IE.
For Firefox I believe there is an initiative called Marionette that is being worked upon [ https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette ]
Once that is completely rolled out, the approach across all the browsers would basically become the same.