Test Automation Using Selenium WebDriver With Java

Transcription

Test Automation Using SeleniumWebDriver with JavaNavneesh Garg Selenium WebDriver 2.0 Learn Automation on aWeb Based Application Real Life Experiences Step By Step Instructions Interview Questions Basedon SeleniumSelenium WebDriverStep By Step Guide

All rights reserved. No part of this publication may be reproduced, stored in aretrieval system or transmitted in any form or by any means, electronic, mechanical,photocopying, recording, scanning, or otherwise without either the prior writtenpermission of the author or authorization through payment of the appropriate per-copyfee to the Author. For permission please contact author at adactin.com/contact.html.Test Automation Using Selenium WebDriver with JavaBy Navneesh GargISBN - 978-0-9922935-1-2Publisher: AdactIn Group Pty Ltd.Copyright 2014 AdactIn Group Pty Ltd.This document also contains registered trademarks, trademarks and service marks that are owned bytheir respective companies or organizations. The publisher and the author disclaim any responsibilityfor specifying which marks are owned by which companies or organizations.LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THEAUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TOTHE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK ANDSPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION,WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BECREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICEAND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHERIS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICESOF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THEPUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO INTHIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSESTHE INFORMATION. THE ORGANIZATION OR WEBSITE MAY PROVIDE OR MAKEOWN RECOMMENDATIONS.2

ContentsAbout the Author . 9Preface. 111. Introduction to Automation. 151.1 What is Functional Automation?.151.2 Why do we Automate?.161.3 When should we Automate? Economics of Automation. 171.4Commercial and Open Source Automation Tools.182. Training Application Walkthrough. 202.1 Training Application Walkthrough .203 . Planning before Automation. 263.1Pre-requisites Before you Start Recording.263.2 Test Automation Process .304. Introduction to Selenium. 324.1Selenium’s Tool Suite.324.2How to Choose the Right Selenium Tool for your need.364.3Installation Requirements for Selenium .385. Installing Selenium Components. 395.1Installing Selenium IDE.395.2Installing Firebug plug-in.425.3Installing the FirePath .465.4Installing Java Development Kit.505.5Installing and Configuring Eclipse.535.6Installing WinANT.573

Test Automation Using Selenium WebDriver with Java6. Using Selenium IDE. 626.1Selenium IDE Interface.636.2Recording Using Selenium IDE.656.3Save and Replay the Script using IDE.686.4Inserting/Editing Test Steps Manually.726.5Adding Verifications and Asserts with the Context Menu.747. Managing User Interface Controls. 807.1How Does Selenium IDE Replay Scripts?.807.2Locate the elements on a Web page.817.3Find XPath using Firefox Add-on.888. Basics of Java. 918.1Object-oriented Programming Concepts.918.2Language and Syntax Basics.998.3 Working with Classes, Objects and Methods.1168.4Exception Handling.1269. Creating First Selenium WebDriver Script. 1319.1Recording and Exporting Script from IDE.1319.2Configure Eclipse to Work with Selenium.1379.3Running the Test.14810. Selenium Methods. 15210.1Common Selenium WebDriver Methods.15411. Multiple Choice Questions Set-1. 15812. Verification Point in Selenium. 16212.1Need for a Verification Point.16212.2Inserting a Verification Point.16312.3Understand how to Implement a Few Common Validations.17112.4Assert Statements in Junit.1734

Contents13. Shared UI Map. 17713.1 What is a Shared UI Map?.17813.2Add a Shared UI Map to Selenium Project.18013.3Using a Shared UI Map file in Script.18514. Using Functions . 19114.1Creating Functions in WebDriver.19114.2Calling a Function in WebDriver Script.19915. Using a Configuration File. 20315.1Create a Configuration File.20415.2Using Configuration File Parameters in a Script.20616. Data Driven Testing - Parameterization. 20916.1Data Drive a Script with a Single Value from an Excel Sheet.21016.2Parameterize the Script with Multiple Values from an Excel Sheet.21917. Synchronizing WebDriver scripts. 22317.1 What is Synchronization?.22417.2Approaches used for Script Synchronization.22417.3Using Script Synchronization in a Script.23018. Handling Pop-up Dialogs and Multiple Windows. 23918.1Handle Alerts or Prompts.23918.2 Working with Multiple Windows.24319. Working with Dynamic UI Objects. 24719.1Understanding Dynamic UI Objects.24719.2Handling Dynamic Objects using Programming.24919.3Handling Dynamic Objects using Partial Match.25420. Multiple Choice Questions Set-2. 25721. Debugging Scripts. 26021.1Debugging Features.26021.2Run Tests in Debug mode with Breakpoints.2625

Test Automation Using Selenium WebDriver with Java21.3Step Commands, Variables and Watch.26722. Exception Handling in WebDriver. 27222.1Handling WebDriver Exceptions .27322.2Handle Specific Exceptions.27922.3Common WebDriver Exceptions.28023. Reporting in Selenium. 28223.1 Test Framework Reporting Tools.28223.2Configuring JUnit HTML Reports.28323.3Configuring TestNG Report for your Tests.29223.4Custom Reporting in Excel Sheets or Databases.30824. Batch Execution. 31024.1Batch Execution with TestNG.31024.2Batch Execution with Master WebDriver Script.31425. Continuous Integration with Jenkins. 31925.1Installing Jenkins Tool.32025.2Jenkins Configuration.32225.3Selenium WebDriver Test Execution in Jenkins.32426. Automation Frameworks. 33526.1 Why do we need Automation Frameworks?.33526.2 What exactly is an Automation Framework?.33626.3 Types of Frameworks.33827. Selenium Functions, Common Questions and Tips. 34327.1How to use JavaScript.34327.2How to take a Screenshot.34527.3How to use Keyboard or Mouse movements.34727.4How to read Rows, Columns and Cell Data from Table.35027.5 Working with Multiple Browsers.35227.66How to Maximize Browser Window.353

Contents27.7Checking an Element’s Presence.35327.8Checking an Element’s Status.

Test Automation Using Selenium WebDriver with Java Navneesh Garg Selenium WebDriver 2.0 Learn Automation on a Web Based Application Real Life Experiences Step By Step Instructions Interview Questions Based on Selenium Selenium WebDriver Step By Step Guide