Being a selenium test developer, I always used WebDriver with knowledge that was limited to usage of the tool in developing test scripts. But I am curious to know how WebDriver interacts with a page on a browser internally.
My questions are:
Selenium RC used proxy to eliminate the problem of same origin policy. How is WebDriver addressing the problem of same origin policy?
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?
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With