Architecture
The WebDriver architecture does not
follow the same approach as Selenium RC, which
was written purely in JavaScript for all
the browser automation. The JavaScript, in Selenium
RC, would then emulate user actions.
This JavaScript would automate the browser from
within the browser. WebDriver on the
other hand tries to control the browser from outside
the browser. It uses accessibility API
to drive the browser. The accessibility API is used by
a number of applications for accessing
and controlling applications when they are used by
disabled users and is common to web
browsers.
WebDriver uses the most appropriate way
to access the accessibility API. If we look at
Firefox, it uses JavaScript to access
the API. If we look at Internet Explorer, it uses C++. This
approach means we can control browsers
in the best possible way but has the downside
that new browsers entering the market
will not be supported straight away like we can with
Selenium RC.
Where that approach doesn't work we will
then inject JavaScript into the page. Examples of
this are found in the new HTML5.
WebDriver API
|
WebDriver SPI
|
JSON Wire Protocol
|
Selenium Server
|
The system is made up of four different sections.
WebDriver API
The WebDriver API is the part of the
system that you interact with all the time. Things
have changed from the 140 line long API
that the Selenium RC API had. This is now more
manageable and can actually fit on a
normal screen. You will see this when you start using
WebDriver in the next chapter. This is
made up of the WebDriver and the WebElement objects.
driver.findElement(By.name("q"))
and
element.sendKeys("I love
cheese");
WebDriver SPI
When code enters the Stateless
Programming Interface or SPI, it is then called to a
mechanism that breaks down what the
element is, by using a unique ID, and then calling a
command that is relevant. All of the API
calls above then call down.
Using the example in the previous
section would be like the following code, once it was
in the SPI:
findElement(using="name",
value="q")
sendKeys(element="webdriverID",
value="I love cheese")
From there we call the JSON Wire
protocol. We still use HTTP as the main transport
mechanism. We communicate to the
browsers and have a simple client server transport
architecture the WebDriver developers
created the JSON Wire Protocol.
JSON Wire protocol
The WebDriver developers created a
transport mechanism called the JSON Wire Protocol.
This protocol is able to transport all
the necessary elements to the code that controls it. It
uses a REST like API as the way to
communicate.
Selenium server
The Selenium server, or browser,
depending on what is processing, uses the JSON Wire
commands to break down the JSON object
and then does what it needs to. This part of the
code is dependent on which browser it is
running on.As mentioned earlier, it could be done in the
browser via C++; if it's in IE or if not available we
inject Selenium.
Nice Article about selenium architecture.it was so informative..Thanks for sharing..Keep update best selenium training in chennai best selenium training institute in chennai
ReplyDelete