Selenium WebDriver
Gianluca Carbone
Selenium WebDriver 1
Contents
• What is Selenium?
• History
• WebDriver
• High-Level Architectures
• Architectural themes
• Non – Functional quality
• Layers & Javascript
• Design issues
• Firefox driver
• IE driver
• Who use Selenium
• Future problems
• Demonstration of a driverSelenium WebDriver 2
What is Selenium?
Selenium is a set of tools for cross-platform automated testing of web applications.
• Open Source Web Application Testing System
• Automated UI Testing
• Functional type of tests
• Multiple browsers, multiple languages
Selenium WebDriver 3
Selenium
• History
Selenium WebDriver 4
Selenium(1)- OverviewSelenium Core: JavaScript Framework
- IDE
Firefox Plugin
- Remote Control
Javascript code of Selenium Core
Server: Proxy to launch browsers
Client libraries
- Grid
Distributed remote tests
Selenium WebDriver 5
WebDriver
A platform and language-neutral interface that allows programs or scripts to introspect into, and control the behavior of a web browser.(W3C)
• Clean & Object Oriented API
• Java bindings
• Attempted to bind natively to the browser
• HtmlWebDriver
• Overcomes the limitation of Selenium RC “Same Origin Policy”
Selenium WebDriver 6
Selenium 1.0 Architecture
• High level architecture
Selenium WebDriver 7
Selenium “2.0” Architecture
• High level architecture
Selenium WebDriver 8
Architectural themes
• Keep the costs down
• Emulate the user
• Prove the drivers work…
• …but you should not need to understand how everything
works
• Lower the bus factor
• Have sympathy for Javascript implementation
• Every method call is an RPC call
• We are an Open Source project
Selenium WebDriver 9
Non-functional quality
- Scalability
- Portability
- Compatibility
- Integrability/Reusability
- Customizability
- Usability
- Testability
- Ease of support
- Resilience/Maintainability
Selenium WebDriver 10
Layers and Javascript
• A browser automation tool is essentially built of three moving
parts:
1. A way of interrogating the DOM (Document Object Model)
2. A mechanism for executing Javascript
3. Some means of emulating user input
Language : Javascript
Selenium makes use of a layered set of libraries
Selenium WebDriver 11
Layers and Javascript (2)
• Adapter layers: in order to meet the API
contracts of both WebDriver and Core.
• Atoms: that provides functions for simple
tasks or complex actions.
• Google’s Clousure Library: which supplies
primitives and a modularization mechanism
allowing source file to be kept focused and
small as possibileSelenium WebDriver 12
Issue
• Operating Systems, Drivers and Programming
Languages supported:
Operating Systems :
Bindings: C#, Java, Ruby, Python, (Php and Perl
made by third part).
WebDriver API:
Selenium WebDriver 13
Issue(2)
• Simplified Architecture -> Selenium Server NOT
needed.
- using only the WebDriver API
- browser and tests will all run on the same machine
• Otherwise you need it : - Selenium Grid;
- Connect to a remote machine with a particular browser
- Not using the Java bindings and would like to use HtmlUnitDriver
Selenium WebDriver 14
Issue(3)
• Dealing with Combinatorial Explosion� Reducing the number of language
� Reducing the number of supported browsers
� Make all the browsers look identical to the language bindings with a uniform interface.
• Have sympathy for a JavaScript Implementation� Problem in the future, already with HTML 5
� Do not worry!
• Flaws in the WebDriver Design� RenderedWebElement Interface
� Documentation
� Binding tightly to a browser
� HTTP status code!
Selenium WebDriver 15
Issue (4) - Architectural Style &
Design Pattern• Architectural Style
� Layered
� Plugin
Born as a plugin for firefox and always new features can be added to it
• Design Patterns � Components – InteroperabilityEnable communication between different platform (Web driver and Selenium Core)
� Composition Reuse of an existing applications – Selenium Core
Build system out of the composition of existing ones
Selenium WebDriver 16
ISSUE (5)
Firefox Driver• Transport mechanism
� RPC
� HTTP
• Single or multiple end points� “REST-ish”
� SOAP (single end-point)
� REST (multiple end-points)
• Encoding data based on content type negotiation� HTML
� XML
� JSON
Selenium WebDriver 17
Firefox Driver
Overview of the Firefox Driver Architecture
• HTTP server
� XPCOM by Selenium
� HTTPD by Mozilla
• Error handling(two level)
1. invalid request
2. failed commands
Selenium WebDriver 18
ISSUE (6)
Internet Explorer Driver• Language to use for programming on Windows
� C# 4
� C++
• In order to get the Java classes communicating with the C++
� JNI (Java Native Interface)
� JNA (Java Native Architecture)
• Thread Boundary
� No
� Yes
Java is multi-thread and IE COMs have single thread. It is solved taking the IE instance in a separate thread and using the PostThreadMessage Win32 API to communicate across the thread boundary.
Selenium WebDriver 19
IE Driver
IE Driver Architecture
Selenium WebDriver 20
Who uses Selenium
Selenium WebDriver 21
Future problems
Selenium WebDriver 22
Demonstration of a driver
I hope to be on time!
Small Demo.
Driver:
Selenium WebDriver 23
Reference
• The Architecture of Open
Source Application – Selenium
WebDriver – Simon Stewart
• Official Web site of Selenium
http://docs.seleniumhq.org/
Selenium WebDriver 24