Test Web applications using Selenium

Slides:



Advertisements
Similar presentations
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
Advertisements

Web Server Programming
Selenium HP Web Test Tool Training
Languages for Dynamic Web Documents
Server-Side vs. Client-Side Scripting Languages
Multiple Tiers in Action
Dynamic Web Pages Bert Wachsmuth. Review  Internet, IP addresses, ports, client-server, http, smtp  HTML, XHTML, XML  Style Sheets, external, internal,
Test Web applications using Selenium
Selenium – Testing Tool. What is Selenium? Selenium is a robust set of tools that supports rapid development of test automation for web-based applications.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
INTRODUCTION TO WEB DATABASE PROGRAMMING
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
JavaScript & jQuery the missing manual Chapter 11
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
Web Application Access to Databases. Logistics Test 2: May 1 st (24 hours) Extra office hours: Friday 2:30 – 4:00 pm Tuesday May 5 th – you can review.
Testing Web applications. Selenium What is Selenium? Selenium is a suite of tools to automate web application testing across many platforms Tests run.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Putting it all together Dynamic Data Base Access Norman White Stern School of Business.
Testing Web Applications. Plan The presentation covers: Selenium framework Spring MVC Test framework HttpUnit framework.
Selenium and Selenium on Rails. Agenda  Overview of Selenium Simple Selenium Tests Selenium IDE  Overview of Selenium on Rails  Problems with Selenium.
Web Automation Testing With Selenium By Rajesh Kanade.
Pubman and Selenium tests. What is Selenium Selenium is a suite of Web application test automation tools for any browser on any operating system –Firefox,
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Automated Smoke Testing on the JVM with Geb João SILVA (GS-AIS-EB) 1st Forum 29th of September, 2015 e-Business Section AUTOMATED SMOKE.
Crash Course in Web Hacking
Session 1 Chapter 1 - Introduction to Web Development ITI 133: HTML5 Desktop and Mobile Level I
Introduction Selenium IDE is a Firefox extension that allows you to record, edit, and debug tests for HTML Easy record and playback Intelligent field selection.
Web Security Lesson Summary ●Overview of Web and security vulnerabilities ●Cross Site Scripting ●Cross Site Request Forgery ●SQL Injection.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
WEB SECURITY WEEK 1 Computer Security Group University of Texas at Dallas.
Arklio Studija 2007 File: / / Page 1 Automated web application testing using Selenium
Web Security (cont.) 1. Referral issues r HTTP referer (originally referrer) – HTTP header that designates calling resource  Page on which a link is.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Web driver and its comparison Selenium RC. Selenium web driver: It's web automation testing out framework that assists to execute assessments throughout.
© University of Liverpool
Building Secure ColdFusion Applications
The Zen of UI Test Automation
Selenium and Selenium on Rails
Introduction to Dynamic Web Programming
Testing with Selenium IDE
WWW and HTTP King Fahd University of Petroleum & Minerals
Tutorial 10 Programming with JavaScript
Introduction and Principles
Selenium HP Web Test Tool Training
Relational database and SQL MySQL LAMP SQL queries
SQL Injection Attacks Many web servers have backing databases
Introduction Web Environments
Software Quality Assurance
PHP / MySQL Introduction
Web App vs Mobile App.
PHP: Security issues FdSc Module 109 Server side scripting and
HTML5 Level I Session I Chapter 1 - Introduction to Web Development
Lecture 2 - SQL Injection
Introduction of Week 11 Return assignment 9-1 Collect assignment 10-1
Selenium Web Test Tool Training Using Ruby Language
IntroductionToPHP Static vs. Dynamic websites
An Introduction to JavaScript
Cross-Site Scripting Issues and Defenses Ed Skoudis Predictive Systems
Lecture 34: Testing II April 24, 2017 Selenium testing script 7/7/2019
© University of Liverpool
Web Application Development Using PHP
Presentation transcript:

Test Web applications using Selenium

Outline Uniqueness of web app testing Selenium WebDriver Heterogonous system Dynamic pages Performance testing Security testing Selenium WebDriver

Web application architecture Heterogeneous system Front end Browser: IE, Firefox, Chrome, Safari… Server side Application Server Database Server File System ……

Heterogeneous system Front end Page in Browser Source behind HTML, JavaScript, Adobe Flash…… Page in Browser HTML JavaScript Source behind

Uniqueness 1: Heterogeneous system Server side Can be written in PHP, Java, C#... Communicate with Database server in SQL PHP Script PHP SQL HTML SQL

Heterogeneous System Need to test all sub-components Anything could go wrong… However, only front end is accessible for testing Can not directly test the Server code and SQL Have to drive the test execution Frontend HTML: Malformed HTML page? (demo) JavaScript: Runtime Errors? (demo) Server script PHP, Java…: Runtime Errors? (demo) SQL: Malformed SQL query string? (demo)

Test from the front end Pros Cons Hide the complexity of the backend Uniform interface Can use a robot to automate test execution Cons The front end is not trustable Crafted malicious requests

Selenium A tool set that 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 Easy record and replay Debug and set breakpoints Save tests in HTML, WebDriver and other formats.

Selenium IDE test cases Selenium saves all information in an HTML table format Each record consists of: Command – tells Selenium what to do (e.g. “open”, “type”, “click”, “verifyText”) Target – tells Selenium which HTML element a command refers to (e.g. textbox, header, table) Value – used for any command that might need a value of some kind (e.g. type something into a textbox)

How to record/replay with Selenium IDE Start recording in Selenium IDE Execute scenario on running web application Stop recording in Selenium IDE Verify / Add assertions Replay the test. Selenium IDE Demo……

Bad things of testing from the front end The front end is not trustable Front end code can be accessed by anybody Malicious users can infer the input parameters Crafted requests! 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 could be dynamic It can change itself at runtime HTML can be modified by JavaScript JavaScript can modify itself Demo Server script could be dynamic Client pages are constructed at runtime The same server script can produce completely different client pages SchoolMate

Uniqueness 3: Performance Performance is crucial to the success of a web app Recall the experience to register for a class in the first days of the semester… Performance testing evaluates system performance under normal and heavy usage Volume testing For expected concurrent number of users Stress testing To understand the upper limits of capacity Performance testing can be automated

Uniqueness 4: Security Web app usually deals with sensitive info, e.g. Credit card number SSN Billing / Shipping address Security is the biggest concern Security testing should simulate possible attacks

Uniqueness 4: Security SQL Injection The untrusted input is used to construct dynamic SQL queries. E.g, update my own password $str = "UPDATE users SET password = \” “ . $_POST['newPass’] . “\” WHERE username =\”“ . $_POST['username'] . “\””; mysql_query( $str ); PHP Script $_POST['newPass’] = pass, $_POST['username'] = me Query String: UPDATE users SET password = “pass” WHERE username =“me” Normal Case $_POST['newPass’] = pass, $_POST['username'] = “ OR 1=1 -- Query String: UPDATE users SET password = “pass” WHERE username =“” OR 1=1 --” Attack

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 Solution: Never trust user inputs Design test cases to simulate attacks

Outline Uniqueness of web app testing Selenium WebDriver Heterogonous system Dynamic pages Performance testing Security testing Selenium WebDriver

Selenium WebDriver (Selenium 2) Write a program to control the test execution of a web app More flexible and powerful than IDE Selenium-WebDriver supports multiple browsers in multiple platforms Google Chrome 12.0.712.0+ Internet Explorer 6+ Firefox 3.0+ Opera 11.5+ Android – 2.3+ for phones and tablets iOS 3+ for phones iOS 3.2+ for tablets

Selenium WebDriver WebDriver is designed to providing a simpler and uniform programming interface Same WebDriver script runs for different platforms Support multiple programming languages: Java, C#, Python, Ruby, PHP, Perl… It’s efficient WebDriver leverages each browser’s native support for automation.

How to use Selenium WebDriver (1) Go to a page (2) Locate an element (3) Do something with that element ...... (i) Locate an element (i+1) Do something with that element (i+2) Verify / Assert the result

Demo: Verify page title public static void main( String[] args ) { // Create a new instance of the Firefox driver WebDriver driver = new FirefoxDriver(); // (1) Go to a page driver.get("http://www.google.com"); // (2) Locate an element WebElement element = driver.findElement(By.name("q")); // (3-1) Enter something to search for element.sendKeys("Purdue Univeristy"); // (3-2) Now submit the form. WebDriver will find the form for us from the element element.submit(); // (3-3) Wait up to 10 seconds for a condition WebDriverWait waiting = new WebDriverWait(driver, 10); waiting.until( ExpectedConditions.presenceOfElementLocated( By.id("pnnext") ) ); // (4) Check the title of the page if( driver.getTitle().equals("purdue univeristy - Google Search") ) System.out.println("PASS"); else System.err.println("FAIL"); //Close the browser driver.quit(); }

How to locate an element By id HTML: <div id="coolestWidgetEvah">...</div> WebDriver: driver.findElement( By.id("coolestWidgetEvah") ); 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

Timing issue There are delays between submitting a request and receiving the response We can wait until the response page is loaded Robot doesn’t know! In WebDriver, sometimes it doesn’t work if Submit a request Verify the response immediately Solution: Simulate the wait. Wait until some HTML object appears

Summary: What Selenium can do A solution for the automated testing Simulate user actions Functional testing One could even program BVA in a test script Create regression tests to verify functionality and user acceptance. Browser compatibility testing The same script can run on any Selenium platform Volume testing Stress testing