Selenium
Selenium
Selenium
using Selenium
Outline
Uniqueness of web app testing
Heterogonous system
Dynamic pages
Load
Security
Selenium WebDriver
Course project 4
Web application architecture
Heterogeneous system
Front end
Browser: IE, Firefox, Chrome, Safari…
Server side
Application Server
Database Server
File System
……
Heterogeneous system
Front end
HTML, JavaScript, Adobe Flash……
HTML
JavaScript
Uniqueness 1: Heterogeneous system
Server side
Can be written in PHP, Java, C#...
Communicate with Database server in SQL
PHP
SQL
HTML
SQL
Heterogeneous system
Should test all involved parts
Everything can go wrong…
Bad things
The front end is not trustable
Crafted malicious requests
Good things of testing from the front end
Automated web app testing
Compare to commend-line program testing…
Sensitive to input values (the same)
GUI testing: event driven (the difference)
“Button A” then “Button B” OK
“Button B” then “Button A” FAIL
The robot should be able to
Provide input values
Simulate user actions
Selenium
A tool set automates web app testing across platforms
Can simulate user interactions in browser
Two components
Selenium IDE
Selenium WebDriver (aka. Selenium 2)
Selenium IDE
Firefox extension
Demo
Front end limits the length of the input values
Front end limits the content of the input values
Front end limits the combination of the input values
Uniqueness 2: Dynamic pages
Client page is dynamic
It can change itself in the runtime
HTML can be modified by JavaScript
JavaScript can modify itself
Demo
Query String: UPDATE users SET password = “pass” WHERE username =“me”
Query String: UPDATE users SET password = “pass” WHERE username =“” OR 1=1 --”
Uniqueness 4: Security
Cross Site Scripting (XSS)
The untrusted input is used to construct dynamic
HTML pages.
The malicious JS injected executes in victim’s
browser
The malicious JS can steal sensitive info
Demo
Selenium WebDriver
Course project 4
Limitation of Selenium IDE
No multiple browsers support
It runs only in Mozilla Firefox.
No manual scripts
E.g. conditions and Loops for Data Driven Testing
It’s efficient
WebDriver leverages each browser’s native support
for automation.
What Selenium can do
A solution for the automated testing
Simulate user actions
Functional testing
Create regression tests to verify functionality and
user acceptance.
Browser compatibility testing
The same script can run on any Selenium platform
Load testing
Stress testing
How to use Selenium WebDriver
(1) Go to a page
By name
HTML: <input name="cheese" type="text"/>
WebDriver: driver.findElement( By.name("cheese") );
By Xpath
HTML
<html>
<input type="text" name="example" />
<input type="text" name="other" />
</html>
WebDriver: driver.findElements( By.xpath("//input") );
There are plug-ins for firefox/chrome to automatically display the Xpath
Time issue
There are delays between submitting a request
and receiving the response
We can wait until the response page is loaded
Course project 4
Course Project 4
Test a functionality without the source
The subject web application
“Add New Class” in “SchoolMate”
Course Project 4
Part 1: overview
Design test cases against the requirement
The tests should consider
all possible cases
equivalence class partitioning
Implement Selenium WebDriver Script for “Add
new class”
Test cases
generated
Convert
Q&A