Solve your Selenium WebDriver problems with this quick guide to automated testing of web applications with Selenium WebDriver in C#. This third editioncontains hundreds of solutions to real-world problems, with clear explanations and ready-to-run Selenium test scripts that you can use in your own pr
Selenium WebDriver Recipes in C#: Practical Testing Solutions for Selenium WebDriver
✍ Scribed by Courtney Zhan, Zhimin Zhan
- Publisher
- Apress
- Year
- 2023
- Tongue
- English
- Leaves
- 331
- Edition
- 3
- Category
- Library
No coin nor oath required. For personal study only.
✦ Synopsis
Solve your Selenium WebDriver problems with this quick guide to automated testing of web applications with Selenium WebDriver in C#. This third editioncontains hundreds of solutions to real-world problems, with clear explanations and ready-to-run Selenium test scripts that you can use in your own projects.
Updated to Selenium version 4, this revision includes Visual Studio Code set up, additional recipes, and new chapters on Selenium DevTools and continuous testing. You'll see how to use Selenium WebDriver for select lists, navigation, assertions, frames, file upload and pop-up dialogs. You'll also learn how to locate web elements and test functions for hyperlinks, buttons, TextFields and TextAreas, radio buttons, CheckBoxes, and more.
What You'll Learn
Debug test scripts and test data
Work with Selenium Remote Control Server
Manage and deal with browser profiles and capabilities
Monitor tests for advanced user interactions and experiences (UX)Who This Book Is For Experienced .NET and C# Windows application programmers/developers.
✦ Table of Contents
Table of Contents
About the Authors
Preface
Chapter 1: Introduction
Selenium WebDriver
Selenium Language Bindings
Set Up the Development Environment - Visual Studio Code
Prerequisites
Set Up Visual Studio Code
Cross-Browser Testing
Chrome
Firefox
Safari
Edge
Internet Explorer
Visual Studio Unit Testing Framework
Visual Studio Unit Testing Framework Fixtures
Alternative Framework: NUnit
Run Recipe Scripts
Run Test(s) in VS Code
Find the Test Case
Run an Individual Test Case
Run All Test Cases in a Test Script File
Run Tests from the Command Line
Chapter 2: Locating Web Elements
Start a Browser
Inspect a Web Element in a Browser
Find an Element by ID
Find an Element by Name
Find an Element by Link Text
Find an Element by Partial Link Text
Find an Element by XPath
Find an Element by a Tag Name
Find an Element by Class
Find an Element by CSS Selector
Find an Element by Relative Locators
Chain FindElement to Find Child Elements
Find Multiple Elements
Locate a Web Element That Disappears After Inspect
Chapter 3: Hyperlink
Click a Link by Text
Click a Link by ID
Click a Link by Partial Text
Click a Link by XPath
Click the Nth Link with Exact Same Label
Click the Nth Link by CSS Selector
Verify If a Link Is Present or Not
Get Link Data Attributes
Test If a Link Opens a New Browser Window
Chapter 4: Button
Click a Button by Text
Click a Form Button by Text
Submit a Form
Click a Button by ID
Click a Button by Name
Click an Image Button
Click a Button via JavaScript
Assert If a Button Is Present
Assert If a Button Is Enabled or Disabled
Chapter 5: TextField and TextArea
Enter Text into a Text Field by Name
Enter Text into a Text Field by ID
Enter Text into a Password Field
Clear a Text Field
Enter Text into a Multiline Text Area
Assert a Value
Focus on a Control
Set a Value to a Read-Only or Disabled Text Field
Set and Assert the Value of a Hidden Field
Chapter 6: Radio Button
Select a Radio Button
Clear the Radio Option Selection
Assert a Radio Option Is Selected
Iterate Radio Buttons in a Radio Group
Click the Nth Radio Button in a Group
Click a Radio Button by the Following Label
Customized Radio Buttons with iCheck
Chapter 7: CheckBox
Check by Name
Check by Id
Uncheck a Checkbox
Assert a Checkbox Is Checked (or Not)
Chain FindElement to Find Child Elements
Customized Checkboxes using iCheck
Chapter 8: Select List
Import Selenium.Support
Select an Option by Text
Select an Option by a Value
Select an Option by an Index
Send Keys to the Select Element
Select an Option by Iterating All Options
Select Multiple Options
Clear One Selection
Clear All Selections
Assert a Selected Option
Assert a Label or Value of a Select List
Assert Multiple Selections
Chapter 9: Navigation and Browser
Go to a URL
Visit Pages Within a Site
Open Browser in a Certain Size
Maximize the Browser Window
Move the Browser Window
Minimize a Browser Window
Scroll Focus to Control via JavaScript
Scroll with Scroll Wheel Actions
Switch Between Browser Windows or Tabs
New Browser Window or Tab
Open and Close Browser Tabs Using JavaScript
Remember Current Web Page URL and Come Back to It Later
Chapter 10: Assertion
Assert a Page Title
Assert Page Text
Assert the Page Source
Assert Label Text
Assert Span Text
Assert Div Text or HTML
Assert Table Text
Assert Text in a Table Cell
Assert Text in a Table Row
Assert If an Image Is Present
Assert Element Location and Width
Assert Element CSS Style
Assert JS Errors on a Web Page
Chapter 11: Frames
Testing Frames
Find a Frame with FindElement
Test an IFrame
Test Multiple IFrames
Chapter 12: Testing AJAX
Pause for a Specific Duration of Time
Explicit Waits Until Time Out
Implicit Waits Until Time Out
Fluent Waits Until Time Out
Create Your Own Polling Check Function
Refactor with a Reusable Function
Wait for the AJAX Call to Complete Using JQuery
Chapter 13: File Upload and Popup Dialogs
File Upload
File Upload with a Relative Path
JavaScript Popups
Handle JavaScript Popups Using Alert API
Handle JavaScript Popups with JavaScript
Modal Style Dialogs
Timeout on an Operation
Popup Handler Approach
Basic or Proxy Authentication Dialog
Bypass Basic Authentication by Embedding the Username and Password in the URL
Internet Explorer Modal Dialog
Chapter 14: Debugging Test Scripts
Print Text for Debugging
Write the Page Source or Element HTML into a File
Take a Screenshot
Leave the Browser Open After a Test Finishes
Debug Test Execution using Debuggers
Enable Breakpoints
Execute One Test Case in Debugging Mode
Step Over Test Execution
Chapter 15: Test Data
Get Data Dynamically
Get a Random Boolean Value
Get a Random Boolean Value with Timestamps
Generate a Number Within a Range
Get a Random Character
Get a Random String at a Fixed Length
Get a Random String in a Collection
Generate a Test File at a Fixed Size
Retrieve Data from a Database
Chapter 16: Browser Profile and Capabilities
Get Browser Type and Version
Set the Page Load Strategy
Set an HTTP Proxy for a Browser
Verify File Download in Chrome
Verify File Download in Firefox
Bypass Basic Authentication with the Firefox AutoAuth Plugin
Manage Cookies
Headless Browser Testing with Chrome
Test Responsive Websites
Chapter 17: Advanced User Interactions
Double-Click a Control
Move the Mouse to a Control (Mouse Over)
Click and Hold (Select Multiple Items)
Context Click (Right-Click a Control)
Drag-and-Drop
Drag a Slider
Send Key Sequences (Select All and Delete)
Chapter 18: HTML5 and JavaScript
HTML5 Email Type Field
HTML5 Time Field
Invoke the onclick JavaScript Event
Invoke JavaScript Events Such As OnChange
Scroll to the Bottom of a Page
Chosen - Standard Select
Chosen - Multiple Select
AngularJS Web Pages
Ember JS Web Pages
Faking Geolocation with JavaScript
Save an SVG Chart to a PNG Image
Save a Canvas to a PNG Image
Chapter 19: WYSIWYG HTML Editors
TinyMCE
CKEditor
SummerNote
CodeMirror
Chapter 20: Leveraging Programming
Throw Exceptions to Fail Tests
Ignorable Test Statement Error
Read an External File
Data-Driven Tests with Excel
Data-Driven Tests with CSV
Identify Element IDs with Dynamically Generated Long Prefixes
Sending Special Keys Such as Enter to an Element or Browser
Use of Unicode in Test Scripts
Extract a Group of Dynamic Data: Verify Search Results in Order
Verify Uniqueness of a Set of Data
Extract Dynamic Visible Data Rows from a Results Table
Extract Dynamic Text Following a Pattern Using Regex
Chapter 21: Optimization
Assert Text in a Page Source Is Faster Than the Text
Getting Text From a More Specific Element Is Faster
Avoid Programming If-Else Blocks If Possible
Use a Variable to Cache Unchanged Data
Enter Large Text into a Text Box
Use Environment Variables to Change Test Behaviors Dynamically
Testing a Web Site in Multiple Languages
Multi-Language Testing with Lookups
Chapter 22: Gotchas
Test Starts Browser But No Execution but a Blank Screen
Failed to Assert Copied Text in Browser
The Same Test Works for Chrome, But Not for IE
“unexpected tag name ‘input’”
Element Is Not Clickable or Visible
Chapter 23: Selenium 4
Chrome For Testing
New Browser Window or Tab
Basic Authentication via Register
Print to PDF
Save Element Screenshot
Drive Elements Inside a Shadow DOM
Relative Locators
Get the Element on the Right of a Checkbox
Get the Element(s) on the Left of a Checkbox
Above in a Table
Below in a Table
Near
Summary
Chapter 24: Selenium DevTools
Emulate Browser Crash
CDP Send Command
Emulate GEO Location
Emulate Locale
Emulate Timezone
Network Interception
Network Latency
Security: Ignore CertificateErrors
Chapter 25: Selenium Grid
Selenium Server Standalone
Execute Tests on a Remote Machine
Set Up Selenium Grid
Using Selenium Grid to Run Tests
Issues with Selenium Grid
Chapter 26: Continuous Testing
CI vs. CT
Preparation
Source Control Test Scripts in Git
Compile Test Scripts
Execute a Test Script from the Command Line
Execute a Test Script with JUnit XML
Set Up BuildWise Server
Set Up a Build Project
Run a Suite of C# tests in BuildWise
What’s the Magic?
Chapter 27: Case Studies
Verify Chart Generation
Test Design
Test Steps
Test Script
Drawing on a Canvas
Test Steps
Log In and Get to the Canvas Page
Set a Fixed Canvas and Choose an Anchor Point
Draw a Circle and Move It
Draw a Cross (Hand-Drawing Mode)
Add Text
Test Script
Automated Testing Elements on a Lazy Load Page
Test Design
Test Steps
Generate a User Guide with an Automation Script
Test Design
Test Steps
Generated Files
What Does It Look Like?
Summary
Broken Link Checker
Test Design
Test Steps
Afterword
Practice Makes Perfect
Successful Test Automation
Resources
Books
Web Sites
Tools
Appendix 1: Visual Studio IDE Setup
Setup
Prerequisite
Set Up Visual Studio Solution
Create a Test and Run It
Run Test(s) in Visual Studio
Find the Test Case
Run an Individual Test Case
Run All Test Cases in a Test Script File
Run All Test Scripts
Visual Studio IDE or VS Code?
Appendix 2: Visual Studio IDE Debugging Test Execution
Enable Breakpoints
Execute One Test Case in Debugging Mode
Step Over Test Execution
Index
📜 SIMILAR VOLUMES
Solve your Selenium WebDriver problems with this quick guide to automated testing of web applications with Selenium WebDriver in C#. <i>Selenium WebDriver Recipes in C#, Second Edition </i>contains hundreds of solutions to real-world problems, with clear explanations and ready-to-run Selenium test s
<p><p>Solve your Selenium WebDriver problems with this quick guide to automated testing of web applications with Selenium WebDriver in C#. <i>Selenium WebDriver Recipes in C#, Second Edition </i>contains hundreds of solutions to real-world problems, with clear explanations and ready-to-run Selenium
Selenium WebDriver is an open source web UI automation tool implemented through a browser-specific browser driver, which sends commands to a browser and retrieves results.<br>Selenium WebDriver Practical Guide will guide you through the various APIs of WebDriver which should be used in automation te