Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf ·...
Transcript of Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf ·...
![Page 1: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/1.jpg)
Selenium WebDriver
Gianluca Carbone
Selenium WebDriver 1
![Page 2: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/2.jpg)
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
![Page 3: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/3.jpg)
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
![Page 4: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/4.jpg)
Selenium
• History
Selenium WebDriver 4
![Page 5: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/5.jpg)
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
![Page 6: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/6.jpg)
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
![Page 7: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/7.jpg)
Selenium 1.0 Architecture
• High level architecture
Selenium WebDriver 7
![Page 8: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/8.jpg)
Selenium “2.0” Architecture
• High level architecture
Selenium WebDriver 8
![Page 9: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/9.jpg)
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
![Page 10: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/10.jpg)
Non-functional quality
- Scalability
- Portability
- Compatibility
- Integrability/Reusability
- Customizability
- Usability
- Testability
- Ease of support
- Resilience/Maintainability
Selenium WebDriver 10
![Page 11: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/11.jpg)
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
![Page 12: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/12.jpg)
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
![Page 13: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/13.jpg)
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
![Page 14: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/14.jpg)
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
![Page 15: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/15.jpg)
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
![Page 16: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/16.jpg)
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
![Page 17: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/17.jpg)
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
![Page 18: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/18.jpg)
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
![Page 19: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/19.jpg)
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
![Page 20: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/20.jpg)
IE Driver
IE Driver Architecture
Selenium WebDriver 20
![Page 21: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/21.jpg)
Who uses Selenium
Selenium WebDriver 21
![Page 22: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/22.jpg)
Future problems
Selenium WebDriver 22
![Page 23: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/23.jpg)
Demonstration of a driver
I hope to be on time!
Small Demo.
Driver:
Selenium WebDriver 23
![Page 24: Selenium WebDriver - Gianluca Carbonegianlucacarbone.it/my_content/SeleniumWebDriver_slide.pdf · • Simplified Architecture -> Selenium Server NOT needed.-using only the ... - Not](https://reader031.fdocuments.net/reader031/viewer/2022021802/5b85b44c7f8b9a162d8b5b9e/html5/thumbnails/24.jpg)
Reference
• The Architecture of Open
Source Application – Selenium
WebDriver – Simon Stewart
• Official Web site of Selenium
http://docs.seleniumhq.org/
Selenium WebDriver 24