Automating GUI testing with Selenium WebDriver, Java and Eclipse

Slides:



Advertisements
Similar presentations
J-Unit Framework.
Advertisements

Test Automation with Selenium
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,
Selenium HP Web Test Tool Training
The Web Warrior Guide to Web Design Technologies
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Presentation Outline What is JUnit? Why Use JUnit? JUnit Features Design of JUnit Downloading JUnit Writing Tests – TestCase – TestSuite Organizing The.
Automated Testing Nathan Weiss April 23, Overview History of Testing Advantages to Automated Testing Types of Automated Testing Automated Testing.
1 Chapter 20 — Creating Web Projects Microsoft Visual Basic.NET, Introduction to Programming.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
JsUnit An introduction to unit testing in-browser JavaScript with JsUnit Edward Hieatt February, 2005 JsUnit.
Automation using Selenium Authored & Presented by : Chinmay Sathe & Amit Prabhu Cybage Software Pvt. Ltd.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Val Kravets, Luis Sanchez, Allen Chung, Phillip Anderson, Leyla Norooz, Brian Ramnarian, Todd Watson.
Robot Framework – Basic Level. Date: Version:1.0 Page 1.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
1 Test Automation For Web-Based Applications Selenium HP Web Test Tool Training Portnov Computer School.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Selenium Web Test Tool Training Discover The Automating Power Of Selenium Author : Girija Prasad Panda Alcatel-Lucent.
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.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
EMBEDDED REAL-TIME, INC. December 8, 2015 Java Unit Mark Mosher Rochester Java Users Group.
JUnit Don Braffitt Updated: 10-Jun-2011.
WARSZAWQA#10.  Author: Michal Lamperski  Contact:  Find me on LinkedIn.
Selenium January Selenium course content  Introduction (Session-1)Session-  Automation  What is automation testing  When to go for automation.
Lec 19 Web Driver 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Lecture 19 Selenium Web Driver 11/4/
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.
Lec 18 Web with Selenium 1 CSCE 747 Fall 2013 CSCE 747 Software Testing and Quality Assurance Lecture 16 Testing Web Applications 10/23/
JUnit A Unit Testing Framework for Java. The Objective Introduce JUnit as a tool for Unit Testing Provide information on how to: Install it Build a test.
Software Development Introduction
ScriptOnce™ & Best Practices. Agenda 2 Automation that works ScriptOnce –Minimal maintenance –Easy to add devices Robustness –Reliable Scripts - Minimize.
Selenium server By, Kartikeya Rastogi Mayur Sapre Mosheca. R
Test Automation Using Selenium Presented by: Shambo Ghosh Ankit Sachan Samapti Sinhamahapatra Akshay Kotawala.
Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek.
Robot Framework – Basic Level. Date: Version:1.0 Page 1.
- 1 - SeeTestAutomation Product Introduction SeeTest Product Suite.
Testing Your Alfresco Add-ons Michael Suzuki Software Engineer.
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
Microsoft Expression Web - Illustrated Unit A: Getting Started With Microsoft Expression Web.
Introduction of Selenium Eli Lu 2016/10/13. Outline What is selenium ? Selenium Projects Selenium Sponsors Easy to use Useful Feature & Tools Useful Links.
SWE 434 SOFTWARE TESTING AND VALIDATION LAB2 – INTRODUCTION TO JUNIT 1 SWE 434 Lab.
Getting Started with Dreamweaver
Appium Studio Appium testing made easy at any scale.
Test Web applications using Selenium
Selenium HP Web Test Tool Training
The Zen of UI Test Automation
JRA2: Acceptance Testing senarious
Data Virtualization Tutorial… CORS and CIS
Introduction of Selenium Webdriver Using Java
Introduction to JUnit CS 4501 / 6501 Software Testing
PYTHON: AN INTRODUCTION
CSCE 747 Software Testing and Quality Assurance
Executing Runtime Checks (For Comp401 and Comp410)
Atit Leelasuksan Rungroj Maipradit
Cross platform automated appium testing - A Primer
What is selenium? Selenium is a portable software-testing framework for web applications. Selenium provides a playback (formerly also recording) tool.
Haden Jackson-Robbins
WEB PROGRAMMING JavaScript.
Test Automation For Web-Based Applications
Getting Started with Dreamweaver
Login For Excellence Selenium Training In Chennai.
DevOps Meetup | Test Automation | 3/19/2012
Selenium Tutorials Cheyat Training.
JUnit Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from the Eclipse 3.0 and.
Selenium IDE Installation and Use.
Presentation transcript:

Automating GUI testing with Selenium WebDriver, Java and Eclipse Selenium Basics Automating GUI testing with Selenium WebDriver, Java and Eclipse Tom Wimsatt, CTAL Columbia Software Test Meetup December 1, 2016 1

Selenium Basics - Agenda Introduction to Selenium Eclipse JUnit Selenium Environments IDE WebDriver Browsers – IE and FF 2 ©2013 Sotera Defense Solutions, Inc. All Rights Reserved. 2

Selenium Basics - Agenda Test Formatting Test Case, Test Suite, Test Runner Design Patterns Making the Most of Test Automation Handling Errors and Exceptions Object Identification - Locators Resources 3 ©2013 Sotera Defense Solutions, Inc. All Rights Reserved. 3

Selenium Basics - Introduction Selenium is for browser automation FireFox Internet Explorer Chrome Etc. Supports many languages Java Python Ruby 4 ©2013 Sotera Defense Solutions, Inc. All Rights Reserved. 4

Selenium Basic - Introduction Selenium leverages JUnit and is supported by Eclipse: Asserts TestCase, TestSuite, TestRunner 5 ©2013 Sotera Defense Solutions, Inc. All Rights Reserved. 5

Selenium Basics - Environments Selenium IDE FireFox Browser plug-in Includes formatters for Ruby, Python, Java, C# Useful for debugging – Locating objects in particular Quick scripting of tests Not recommended for long term or serious test development – inflexible (no looping, etc).

Selenium Basics - Environments Selenium WebDriver Works with Eclipse through jars Step toward Selenium Grid – multiple machine and environment automation. Ultimate in flexibility

Selenium Basics - Environments Browsers Internet Explorer – simple but somewhat inflexible browser for testing. Tips Object ID – F12 for Developer Tools Compatibility View pre-IE 11

Selenium Basics - Environments Browsers FireFox – very flexible. Profiles give the tester options for setting up the browser for different purposes. Object ID – Developer Tools > Inspector FireBug plug-in for older FF versions Disable all add-ins for a clean profile for testing. Use that as the default. firefox.exe -p

Selenium Basics - Environments Browsers FireFox (cont'd) Create profiles or rename them for specific purposes firefox.exe -p Older versions of Selenium required separate FF jar To get all FF preferences: about:config in the address bar

Selenium Basics – Test Formatting JUnit Classes Test Case – Individual or collected tests @Before or setUp – execute this method before every test Initialize the browser with default timing Navigate to initial home page to begin testing

Selenium Basics – Test Formatting JUnit Classes Test Case (cont'd) @Test or testName – the actual test One or more tests in a test class @Before and @After are executed for each test @After or tearDown executed after each test method Close the browser

Selenium Basics – Test Formatting JUnit Classes Test Suite – collection of Test Cases Test Runner – Execution of test cases (main)

Selenium Basics – Test Formatting Design Patterns Classes for browser initialization Include default timing parameters for page loads, object appearances, failure waits. Default settings e.g. default certificate handling Object Repositories Repository class for each page Collect in a separate package

Selenium Basics – Making the Most of Automated Testing The keys to GUI test automation are: Handling errors – when the test fails. Handling dynamic object names – the code may name the objects on the page as it loads or after compiling.

Selenium Basics – Making the Most of Automated Testing Handling errors – capture the error and continue testing. Define your initial condition for all tests All tests in a suite begin at the same place Return to the initial condition at the end of each test – reset to default. Carefully plan tests that may have to build on one another

Selenium Basics – Making the Most of Automated Testing Handling errors (cont'd) If testing for errors, know what the possible errors could be: Runtime exceptions Error dialog – modal? Browser crashing

Selenium Basics – Making the Most of Automated Testing Object Identification – Locators By ID, By Name, By Xpath – Not as widely supported. IE and FF support Xpath. By CSS Selector Native support in most browsers. Faster than Xpath

Selenium Basics – Making the Most of Automated Testing Object Identification – Locators (cont'd) The findElement() method Locate a single element on a page Perform actions on elements click clear getAttribute and getText sendKeys

Selenium Basics – Making the Most of Automated Testing Object Identification - Locators (cont'd) The findElements() method Locate a list of similar elements on a page Use to navigate down to the element you need Narrows down the elements Select the Nth element in a set Example: List<WebElement> elements = driver.findElements(By.cssSelector(“div.button”));

Selenium Basics – Making the Most of Automated Testing Object Identification - Locators (cont'd) The trick to locators is in the wildcarding: Element div attribute id begins with 't' by.cssSelector(“div[id^='t']”) Element div attribute id ends with 't' by.cssSelector(“div[id$='t']”)

Selenium Basics – Making the Most of Automated Testing Object Identification - Locators (cont'd) Combine attributes to better locate the element: Element div attribute id and class ends with 't' by.cssSelector(“div[id^='t'][class$='t']”)

Selenium Basics – Making the Most of Automated Testing Object Identification - Locators (cont'd) Iterate through a list using attributes: List<WebElement> elements = driver.findElements(by.cssSelector... for(WebElement element : elements) { String attrib = element.getAttribute(“value”); }

Selenium Basics – Making the Most of Automated Testing Object Identification - Locators (cont'd) Iterate through a list using containing text: List<WebElement> elements = driver.findElements(by.cssSelector... for(WebElement element : elements) { String attrib = element.getText(); }

Selenium Basics – Making the Most of Automated Testing Selection When presented with a list of options: Select(WebElement).selectByVisibleText(“This One”); Switching Windows Set<String> handles = driver.getWindowHandles(); Driver.switchTo().window(handle);

Selenium Basics - Resources Selenium HQ - http://www.seleniumhq.org/ Rosetta Stone for Locators: http://www.cheat-sheets.org/saved-copy/Locators_groups_1_0_2.pdf http://www.cheat-sheets.org/saved-copy/Locators_table_1_0_2.pdf Selenium 2 Testing Tools Selenium Testing Tools Cookbook Selenium WebDriver Practical Guide Packt Publishing: https://www.packtpub.com/ 2626 ©2014 Sotera Defense Solutions, Inc. All Rights Reserved. 26

Selenium Basics - Resources Robert T. (Tom) Wimsatt, CTAL Robert.Wimsatt@soteradefense.com 410-379-5658 Sotera Defense Solutions, Inc. https://www.linkedin.com/in/tomwimsatt 2727 ©2014 Sotera Defense Solutions, Inc. All Rights Reserved. 27