0% found this document useful (0 votes)
77 views

Test Automation and Advanced Selenium-Classbook-Lesson04

Uploaded by

Suriya Priya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Test Automation and Advanced Selenium-Classbook-Lesson04

Uploaded by

Suriya Priya
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Test Automation & Advanced Selenium Selenium 2.

0 – Web Driver

Test Automation & Advanced


Selenium
Lesson 4: Selenium 2.0 – WebDriver

Pag
e
04-1
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

Lesson Objectives

 Introduction To WebDriver
 Selenium WebDriver Architecture
 Selenium WebDriver Architecture - Components
 Web Driver Vs Selenium RC Vs Selenium IDE
 Benefits of Web Driver over Selenium IDE and RC
 Limitations of Web Driver

Pag
e
04-2
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Introduction To WebDriver

 Selenium WebDriver is one of the most important key component of


Selenium releases
 It is a web automation framework that allows you to execute your
tests against different browsers and not just in Firefox, unlike
Selenium IDE
 It is said to be more advanced and sophisticated replacement for
Selenium RC
 Selenium WebDriver is a well-designed Object Oriented API that
provides improved support for web application testing
 Selenium WebDriver was developed to better support dynamic web
pages where elements of a page may change without the page itself
being reloaded
 Selenium WebDriver supports many browsers including headless
HTMLUnit browser and it supports multiple programming languages
 It works on different operating systems as well

Pag
e
04-3
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Introduction To WebDriver (Cont.)

Multiple Browser Support Multiple Language Support Multiple OS Support

Mozilla Java
Firefox iOS

Opera Internet
JavaScript C-Sharp
Browser
Explorer
Windows Mac
Selenium Selenium
WebDriver Selenium
WebDriver
WebDriver

HTMLUnit
Safari
Driver PHP
Python

Google Android Linux


Chrome Ruby

Pag
e
04-4
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Selenium WebDriver Architecture

Over HTTP Server

Selenium Browser Driver


FirefoxDriver Browsers
Language
Bindings
JASON ChromeDriver Firefox Browser
Chrome Browser
Java Wire SafariDriver
OperaDriver Safari Browser
Ruby
C-Sharp
Protocol EdgeDriver Opera Browser
iOS Driver Edge Browser
Python
JavaScript
Selendriod
Over HTTP Server

Pag
e
04-5
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Selenium WebDriver Architecture - Components
 Language Bindings:
• These are like glue code/wrapper libraries written in corresponding languages
to communicate with the WebDriver API. Selenium Developers have
developed language bindings to allow Selenium to support multiple
languages. The language binding will send the commands across the common
driver API.
 JSON Wire Protocol:
• JSON stands for JavaScript Object Notation. It is used to transfer data
between a server and a client on the web. It transfers information between
HTTP server. Each browser driver having it's own HTTP server.
 Browser Drivers:
• Browser drivers will do the important job of driving the corresponding
browsers. Example: a Chrome browser driver knows how to drive Chrome
browser to perform low level activities such as interacting with UI elements,
navigating between pages etc. We mention the required driver in our code.
When we run our tests, the driver server listens on a port on our local
machine. It will interpret the commands received from the WebDriver API,
execute on the actual browser and return the results back to our code
through the API.

Pag
e
04-6
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Web Driver Vs Selenium RC Vs Selenium IDE

 WebDriver  Selenium RC  Selenium IDE


 Supports all browsers • Supports all browsers • Only works in Mozilla
like Firefox, IE, like Firefox, IE, browser
Chrome, Safari, Opera Chrome, Safari, Opera • Supports Record and
etc. etc. playback
 Doesn’t supports • Doesn’t supports • Doesn’t required to
Record and playback Record and playback start server before
 Doesn’t required to • Required to start executing the test
start server before server before script.
executing the test executing the test • Core engine is
script script. JavaScript based
 Interacts natively with • Core engine is • Very simple to
browser application JavaScript based use
 As compared to RC, it • It is easy and small
is bit complex and API
large API.

Pag
e
04-7
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – WebDriver


Benefits of Web Driver over Selenium IDE and RC

 Architecture is simpler than Selenium RC's


 Faster than Selenium RC
 Interacts with page elements in a more realistic way
 API is simpler than Selenium RC's
 Support the headless HtmlUnitDriver browser

1. Architecture: WebDriver's architecture is simpler than Selenium RC's. It


controls the browser from the OS level. All you need are your programming
language's IDE (which contains your Selenium commands) and a browser. You
first need to launch a separate application called Selenium Remote Control
(RC) Server before you can start testing. The Selenium RC Server acts as a
"middleman" between your Selenium commands and your browser. When you
begin testing, Selenium RC Server "injects" a Javascript program called
Selenium Core into the browser. Once injected, Selenium Core will start
receiving instructions relayed by the RC Server from your test program. When
the instructions are received, Selenium Core will execute them as Javascript
commands. The browser will obey the instructions of Selenium Core, and will
relay its response to the RC Server. The RC Server will receive the response of
the browser and then display the results to you. RC Server will fetch the next
instruction from your test script to repeat the whole cycle.

2. Speed: WebDriver is faster than Selenium RC since it speaks directly to the


browser uses the browser's own engine to control it. Selenium RC is slower
since it uses a Javascript program called Selenium Core. This Selenium Core
is the one that directly controls the browser, not you.

3. Real-life Interaction: WebDriver interacts with page elements in a more


realistic way. For example, if you have a disabled text box on a page you were
testing, WebDriver really cannot enter any value in it just as how a real person
cannot. Selenium Core, just like other JavaScript codes, can access disabled
elements. In the past, Selenium testers complain that Selenium Core was able
to enter values to a disabled text box in their tests.

Pag
e
04-8
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

4.1: Selenium 2.0 – Web Driver


Limitations of Web Driver

 Cannot Readily Support New Browsers


• Since, WebDriver operates on the OS level
• Different browsers communicate with the
OS in different ways.
• If a new browser comes out, it may have a different process of communicating
with the OS as compared to other browsers
 Has no built-in command that automatically generates a Test Results
File
• Have to rely on your IDE's output window, or design the report yourself using the
capabilities of your programming language and store it as text, html, etc.

Page 04-10
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

Summary

In this lesson, you have learnt


 WebDriver is a tool for testing web applications across different
browsers using different programming languages
 You are now able to make powerful tests because WebDriver
allows you to use a programming language of your choice in
designing your tests
 WebDriver is faster than Selenium RC because of its simpler
architecture
 WebDriver directly talks to the browser while Selenium RC needs
the help of the RC Server in order to do so
 WebDriver's API is more concise than Selenium RC's
 WebDriver can support HtmlUnit while Selenium RC cannot
 The only drawbacks of WebDriver are:
• It cannot readily support new browsers, but Selenium RC can
• It does not have a built-in command for automatic generation of test
results

Add the notes here.

Page 04-11
Test Automation & Advanced Selenium Selenium 2.0 – Web Driver

Review Question

Question 1
 Select which is NOT a feature of Web Driver
 Architecture is simpler
 Faster
 API is complex
 Supports all the browsers

Question 2: True/False
 WebDriver can Readily Support New Browsers.

Question 3: Fill in the Blanks


 WebDriver can support while Selenium RC cannot.

Page 04-12

You might also like