Hands on functional test automation with visual studio 2017 and selenium

261 158 0
Hands on functional test automation with visual studio 2017 and selenium

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Hands-On Functional Test Automation With Visual Studio 2017 and Selenium — Chaminda Chandrasekara Pushpa Herath Hands-On Functional Test Automation With Visual Studio 2017 and Selenium Chaminda Chandrasekara Pushpa Herath Hands-On Functional Test Automation Chaminda Chandrasekara Dedigamuwa, Sri Lanka ISBN-13 (pbk): 978-1-4842-4410-4 https://doi.org/10.1007/978-1-4842-4411-1 Pushpa Herath Hanguranketha, Sri Lanka ISBN-13 (electronic): 978-1-4842-4411-1 Copyright © 2019 by Chaminda Chandrasekara, Pushpa Herath This work is subject to copyright All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed Trademarked names, logos, and images may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made The publisher makes no warranty, express or implied, with respect to the material contained herein Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Nikhil karkal Development Editor: Mathew Moodie Coordinating Editor: Divya Modi Cover designed by eStudioCalamar Cover image designed by Freepik (www.freepik.com) Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springersbm.com, or visit www.springeronline.com Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc) SSBM Finance Inc is a Delaware corporation For information on translations, please e-mail rights@apress.com, or visit http://www.apress.com/ rights-permissions Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-4410-4 For more detailed information, please visit http://www.apress.com/source-code Printed on acid-free paper Let this book be the ultimate guide for test automation engineers to make their team run the extra mile Table of Contents About the Authors���������������������������������������������������������������������������������������������������� ix About the Technical Reviewer��������������������������������������������������������������������������������� xi Acknowledgments������������������������������������������������������������������������������������������������� xiii Introduction�������������������������������������������������������������������������������������������������������������xv Chapter 1: Understanding the Concepts������������������������������������������������������������������� Examining Different Software Testing Types��������������������������������������������������������������������������������� Functional Testing������������������������������������������������������������������������������������������������������������������� Non-Functional Testing������������������������������������������������������������������������������������������������������������ The Importance of Testing Software Systems������������������������������������������������������������������������������� Automating Testing����������������������������������������������������������������������������������������������������������������������� The Impact of Future Industry Trends on Software Testing��������������������������������������������������������� 10 Summary������������������������������������������������������������������������������������������������������������������������������������ 11 Chapter 2: Getting Started with Selenium and Visual Studio��������������������������������� 13 Lesson 2.01: Set Up a Test Project with Selenium in Visual Studio�������������������������������������������� 13 Setting Up Visual Studio Test Project������������������������������������������������������������������������������������� 14 Verifying the Test Project������������������������������������������������������������������������������������������������������� 19 Lesson 2.02: Set Up a Test Project with Selenium and Python in Visual Studio�������������������������� 27 Setting up Visual Studio to Work with Python����������������������������������������������������������������������� 27 Executing Sample Python Test Code������������������������������������������������������������������������������������� 33 Lesson 2.03: Set Up Test Project with Visual Studio and MAQS Open Framework��������������������� 36 Setting Up Visual Studio for Work with MAQS Open Framework������������������������������������������� 37 Executing Sample Test Code with MAQS Open Framework in Visual Studio 2017���������������� 40 v Table of Contents Lesson 2.04: Set Up A Test Project with Visual Studio and SpecFlow����������������������������������������� 41 Setting Up Visual Studio to Work with SpecFlow and Selenium�������������������������������������������� 42 Execute Sample Test with the SpecFlow Framework������������������������������������������������������������ 47 Summary������������������������������������������������������������������������������������������������������������������������������������ 55 Chapter 3: Functional Testing for Web Applications����������������������������������������������� 57 Lesson 3.01: Create Test Project with C#������������������������������������������������������������������������������������ 57 Lesson 3.02: How to Capture Web Elements������������������������������������������������������������������������������� 59 Locator: ID����������������������������������������������������������������������������������������������������������������������������� 61 Locator: Name����������������������������������������������������������������������������������������������������������������������� 63 Locator: Class Name�������������������������������������������������������������������������������������������������������������� 64 Locator: CSS Selector������������������������������������������������������������������������������������������������������������ 65 Locator: Link Text������������������������������������������������������������������������������������������������������������������� 71 Locator: Tag Name����������������������������������������������������������������������������������������������������������������� 72 Locator: Partial Link Text������������������������������������������������������������������������������������������������������� 73 Locator: XPath����������������������������������������������������������������������������������������������������������������������� 75 Lesson 3.03: Web Elements Commands������������������������������������������������������������������������������������� 77 Command: Click��������������������������������������������������������������������������������������������������������������������� 77 Command: Send Keys������������������������������������������������������������������������������������������������������������ 78 Command: Clear�������������������������������������������������������������������������������������������������������������������� 78 Command: Find Element������������������������������������������������������������������������������������������������������� 78 Command: Find Elements������������������������������������������������������������������������������������������������������ 78 Command: GetAttribute��������������������������������������������������������������������������������������������������������� 79 Command: GetCssValue��������������������������������������������������������������������������������������������������������� 81 Command: Submit����������������������������������������������������������������������������������������������������������������� 81 Action Commands on IWebElements������������������������������������������������������������������������������������� 82 Lesson 3.04: Handling Web Driver Waits������������������������������������������������������������������������������������� 85 Implicit Wait��������������������������������������������������������������������������������������������������������������������������� 87 Explicit Wait��������������������������������������������������������������������������������������������������������������������������� 88 Using Expected Conditions���������������������������������������������������������������������������������������������������� 93 Lesson 3.05: C# Automation Code Example�������������������������������������������������������������������������������� 95 Lesson 3.06: Python Automation Code Example������������������������������������������������������������������������� 98 vi Table of Contents Lesson 3.07: MAQS Framework with C# Automation Code Example���������������������������������������� 101 HomePage.cs����������������������������������������������������������������������������������������������������������������������� 103 UserLoginPage.cs���������������������������������������������������������������������������������������������������������������� 106 MyOrders.cs������������������������������������������������������������������������������������������������������������������������ 109 Adding the Test Class���������������������������������������������������������������������������������������������������������� 111 Lesson 3.08: SpecFlow Framework with C# Automation Code Example���������������������������������� 113 Summary���������������������������������������������������������������������������������������������������������������������������������� 118 Chapter 4: Functional Testing for Windows Apps������������������������������������������������� 119 Lesson 4.01: Create a Test Project with Coded UI and C#��������������������������������������������������������� 119 Install the Coded UI test component in Visual Studio 2017������������������������������������������������� 119 Setting Up the Visual Studio Test Project����������������������������������������������������������������������������� 120 Lesson 4.02: How to Capture Windows Elements��������������������������������������������������������������������� 123 Lesson 4.03: Element Commands��������������������������������������������������������������������������������������������� 129 Click( )���������������������������������������������������������������������������������������������������������������������������������� 129 DoubleClick( )����������������������������������������������������������������������������������������������������������������������� 132 Hover( )�������������������������������������������������������������������������������������������������������������������������������� 135 MoveScrollWheel����������������������������������������������������������������������������������������������������������������� 136 StartDragging���������������������������������������������������������������������������������������������������������������������� 137 StopDragging����������������������������������������������������������������������������������������������������������������������� 138 SendKeys����������������������������������������������������������������������������������������������������������������������������� 139 Lesson 4.04: Handle Element Waits������������������������������������������������������������������������������������������ 141 Lesson 4.05: Coded UI Test Builder–Record and Playback������������������������������������������������������� 142 Lesson 4.06: Automation Code Example with Coded UI with C#����������������������������������������������� 145 Lesson 4.07: Using Sikuli for Windows App Testing������������������������������������������������������������������ 148 Lesson 4.08: Using Winium for Windows App Testing��������������������������������������������������������������� 151 Summary���������������������������������������������������������������������������������������������������������������������������������� 154 vii Table of Contents Chapter 5: Test Data Management in Functional Testing������������������������������������� 155 Lesson 5.01: Using External Data Sources to Keep Test Data��������������������������������������������������� 156 Lesson 5.02: Cleaning Test Data After Test Execution��������������������������������������������������������������� 163 Lesson 5.03: Making the Test Data Cleanup Robust����������������������������������������������������������������� 169 Summary���������������������������������������������������������������������������������������������������������������������������������� 179 Chapter 6: Integrating Functional Testing to Deployment Pipelines��������������������� 181 Lesson 6.01: Set Up Agent Pools����������������������������������������������������������������������������������������������� 182 Setting Up Organization Agent Pools����������������������������������������������������������������������������������� 182 Setting Up Project Agent Pools�������������������������������������������������������������������������������������������� 184 Lesson 6.02: Setting Up Deployment Pools������������������������������������������������������������������������������� 186 Lesson 6.03: Set Up Test Clients with Agent Pool��������������������������������������������������������������������� 188 Lesson 6.04: Set Up Test Clients with Deployment Group Pool������������������������������������������������� 192 Lesson 6.05: Create a Build Pipeline to Build Test Automation Code���������������������������������������� 197 Lesson 6.06: Create a Deployment Pipeline to Execute Test Automation���������������������������������� 206 Summary���������������������������������������������������������������������������������������������������������������������������������� 218 Chapter 7: Load and Performance Testing������������������������������������������������������������ 219 Lesson 7.01: Load Test with Visual Studio and Azure DevOps�������������������������������������������������� 219 Install Web Performance and Load Testing Tools Components in Visual Studio 2017��������� 220 Setting Up Visual Studio Web Performance and Load Test Project�������������������������������������� 221 Lesson 7.02: Load Testing with Azure DevOps�������������������������������������������������������������������������� 235 Lesson 7.03: Load Testing in the Azure Portal��������������������������������������������������������������������������� 240 Lesson 7.04: Comparing Load Test Results������������������������������������������������������������������������������� 246 Summary���������������������������������������������������������������������������������������������������������������������������������� 248 Index��������������������������������������������������������������������������������������������������������������������� 249 viii About the Authors Chaminda Chandrasekara is a Microsoft Most Valuable Professional (MVP) for Visual Studio ALM and Scrum Alliance Certified ScrumMaster® and focuses on and believes in continuous improvement of the software development life cycle He works as a DevOps consultant for Jabil Circuit Sdn Bhd Chaminda is an active Microsoft Community Contributor (MCC) who is well recognized for his contributions in Microsoft forums, TechNet galleries, wikis, and Stack Overflow, and he contributes extensions to Azure DevOps Server and Services (former VSTS/TFS) in the Microsoft Visual Studio Marketplace He also contributes to other open source projects in GitHub Chaminda has published two books, Beginning Build and Release Management with VSTS (www.apress.com/in/book/9781484228104) and Effective Team Management with VSTS (https://www.apress.com/in/ book/9781484235577) He blogs about technology at https://chamindac.blogspot.com and http://devopsbeyondms.blogspot.com/.  Pushpa Herath is a Senior Test Automation Engineer at Datavail Lanka (Pvt) Ltd She has many years of experience in QA automation and Azure DevOps Server and Services (former VSTS/TFS) She is an expert on functional test automation using Selenium and Coded UI. Pushpa blogs about technology at https://devopsadventure.blogspot com/ Pushpa has experience with Microsoft tools (C#, VSTS/TFS, SQL Server, and Azure) and open source tools (MAQS open framework and Sikuli)   ix About the Technical Reviewer TR Mittal Mehta has a total of 15 years of IT experience Currently, he is working as a configuration manager and is MCP in TFS 2012 He also has experience working in TFS, VSTS, c#, Navision, build-release, DevOps, automation and configuration areas over his last years in Microsoft Technologies   xi .. .Hands- On Functional Test Automation With Visual Studio 2017 and Selenium Chaminda Chandrasekara Pushpa Herath Hands- On Functional Test Automation Chaminda Chandrasekara Dedigamuwa,... provided with hands- on experience to get you started with automation testing using Microsoft Visual Studio in combination with Selenium and other test automation tools and frameworks Lessons will... the functional automation testing integrated with deployment pipelines Step-by-step lessons will give you understanding about how to functional test automation using selenium with C# and python

Ngày đăng: 17/01/2020, 08:54

Từ khóa liên quan

Mục lục

  • Table of Contents

  • About the Authors

  • About the Technical Reviewer

  • Acknowledgments

  • Introduction

  • Chapter 1: Understanding the Concepts

    • Examining Different Software Testing Types

      • Functional Testing

      • Non-Functional Testing

      • The Importance of Testing Software Systems

      • Automating Testing

      • The Impact of Future Industry Trends on Software Testing

      • Summary

      • Chapter 2: Getting Started with  Selenium and Visual Studio

        • Lesson 2.01: Set Up a Test Project with Selenium in Visual Studio

          • Setting Up Visual Studio Test Project

          • Verifying the Test Project

          • Lesson 2.02: Set Up a Test Project with Selenium and Python in Visual Studio

            • Setting up Visual Studio to Work with Python

            • Executing Sample Python Test Code

            • Lesson 2.03: Set Up Test Project with Visual Studio and MAQS Open Framework

              • Setting Up Visual Studio for Work with MAQS Open Framework

              • Executing Sample Test Code with MAQS Open Framework in Visual Studio 2017

              • Lesson 2.04: Set Up A Test Project with Visual Studio and SpecFlow

                • Setting Up Visual Studio to Work with SpecFlow and Selenium

                • Execute Sample Test with the SpecFlow Framework

                • Summary

Tài liệu cùng người dùng

Tài liệu liên quan