Behind the scenes working of Selenium [closed]

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 10 years ago .
  1. I have read that webdriver interacts directly with the automation engine of the browser instead of executing Javascript like Selenium RC. Does that mean that WebDriver does not execute Javascript interally AT ALL?
    Does that mean that there is more than one way to interact with the DOM? I was believing that Javascript is the only way to access/parse the DOM on a browser.
  2. Selenium RC used proxy to eliminate the problem of same origin policy. How is WebDriver addressing the problem of same origin policy?
  3. WebDriver uses JSON wire protocol. But where in the components of WebDriver is JSON Wire protocol used? Is it used in the drivers of different browsers? Or is it used in the Language Bindings API?
  4. When my code is: WebDriver driver = new ChromeDriver(); driver.get("http://www.google.com"); WebElement searchField = driver.findElement(By.name("q")); searchField.sendKeys("selenium"); How is the DOM accessed by WebDriver when the above code is executed?

It would really help if someone can explain these to me in details. I want to make a community wiki regarding internal working of WebDriver to hopefully help anyone searching for this topic. Thanks in advance!

Abhijeet Vaikar asked Apr 15, 2014 at 5:02 Abhijeet Vaikar Abhijeet Vaikar 1,608 6 6 gold badges 28 28 silver badges 51 51 bronze badges What do you mean by point 3, "how is the DOM accessed?" Commented Apr 15, 2014 at 8:25

For example, when I execute document.getElementById() returns a javascript object which represents an element on the DOM. Does it work similarly with all webdriver binding apis? Does webelement contain reference to an element on the DOM?

Commented Apr 15, 2014 at 8:58

Folks voting for closing this question - I would like to know why the question is getting voted for close?? Any valid reasons?

Commented Apr 16, 2014 at 8:18

1 Answer 1

All implementations of WebDriver that communicate with the browser, or a RemoteWebDriver server use a common wire protocol. This wire protocol defines a RESTful web service using JSON over HTTP.

So each WebDriver command is mapped to an HTTP method via the WebDriver service, and then passed on to the HTTP Command Processor to communicate with the browser. The Command responses are returned as HTTP/1.1 response messages via the WebDriver service.

Different drivers, such as the Firefox Driver and the IE Driver, have different implementations to accomplish the above.

The Selenium WebDriver architecture document linked below goes into further details on how these are implemented and how WebDrvier commands flow through to the browser and back. Read section 16.6 for details on the Firefox Driver.

The Architecture of Open Source Applications - Selenium WebDriver
by Simon Stewart (creator of WebDriver, and core contributor to the Selenium project)

Also, details on the The WebDriver Wire Protocol will be helpful in understanding how the HTTP methods are mapped.