Selenium WebDriver Recipes in C# (eBook)

Second Edition

(Autor)

eBook Download: PDF
2015 | 2nd ed.
XXIV, 164 Seiten
Apress (Verlag)
978-1-4842-1742-9 (ISBN)

Lese- und Medienproben

Selenium WebDriver Recipes in C# - Zhimin Zhan
Systemvoraussetzungen
56,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen
A quick practical problem-solving guide to automated testing web applications with Selenium WebDriver in C#. Selenium WebDriver Recipes in C#, Second Edition contains 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.

What You'll Learn
  • How to locate web elements and test functions for hyperlinks, buttons, TestFields and TextAreas, Radio Buttons, CheckBox, and more
  • How to use Selenium WebDriver for select lists, navigation, assertions, frames, file upload and pop-up dialogs
  • How to debug test scripts and test data
  • How to manage and deal with browser profiles and capabilities
  • How to manage tests for advanced User Interactions and Experiences (UX)
  • How to work with and manage tests and testing using the Selenium Remote Control Server

Audience
This book is for experienced .NET and C# Windows application programmers/developers.





Zhimin Zhan is the founder and Continuous Integration Officer of AgileWay Pty Ltd, Australia. As an advisor and coach, he helps organzations by implementing test automation with Continuous Integration using open technologies such as Selenium WebDriver and Watir. Zhimin is the creator of TestWise, the next-generation functional testing tool that supports functional test refactorings, a frequent speaker and writer. He shares his test automation and CI experience at testwisely-dot-com.


Solve your SeleniumWebDriver problems with this quick guide to automated testing of webapplications with Selenium WebDriver in C#. Selenium WebDriver Recipes inC#, Second Edition contains hundreds of solutions to real-world problems,with clear explanations and ready-to-run Selenium test scripts that you can usein your own projects.You'll learn: How to locate web elements and test functions for hyperlinks, buttons, TextFields and TextAreas, radio buttons, CheckBoxes, and more How to use Selenium WebDriver for select lists, navigation, assertions, frames, file upload and pop-up dialogs How to debug test scripts and test data How to manage and deal with browser profiles and capabilitiesAudienceThis book is for experienced .NET and C# Windows application programmers/developers.

Zhimin Zhan is the founder and Continuous Integration Officer of AgileWay Pty Ltd, Australia. As an advisor and coach, he helps organzations by implementing test automation with Continuous Integration using open technologies such as Selenium WebDriver and Watir. Zhimin is the creator of TestWise, the next-generation functional testing tool that supports functional test refactorings, a frequent speaker and writer. He shares his test automation and CI experience at testwisely-dot-com.

Contents at a Glance 5
Contents 7
About the Author 17
About the Technical Reviewer 18
Acknowledgments 19
Preface 20
Chapter 1: Introduction 22
Selenium Language Bindings 22
Set up the Development Environment 24
Prerequisites 24
Set up Visual Studio Solution 24
Create a test and run it 27
Cross-Browser Testing 30
Firefox 30
Chrome 30
Internet Explorer 31
Edge 33
Visual Studio Unit Testing Framework 33
Visual Studio Unit Testing Framework Fixtures 35
Alternative Framework NUnit 36
Run Recipe Scripts 36
Run Tests in Visual Studio 36
Find the Test Case 36
Run Individual Test Case 37
Run all Test Cases in a Test Script File 38
Run all Tests 38
Run Tests from the Command Line 39
Chapter 2: Locating Web Elements 41
Start browser 41
Find element by ID 42
Find element by Name 42
Find element by Link Text 42
Find element by Partial Link Text 42
Find element by XPath 43
Find element by Tag Name 44
Find element by Class 44
Find element by CSS Selector 45
Chain FindElement to find child elements 45
Find multiple elements 45
Chapter 3: Hyperlink 46
Click a link by text 46
Click a link by ID 46
Click a link by partial text 47
Click a link by XPath 47
Click nth link with exact same label 48
Click nth link by CSS selector 48
Verify that a link is present or not 48
Getting link data attributes 49
Test links open a new browser window 49
Chapter 4: Button 50
Click a button by text 50
Click a form button by text 51
Submit a form 51
Click a button by ID 52
Click a button by name 52
Click an image button 52
Click a button via JavaScript 52
Assert a button present 53
Assert a button enabled or disabled 53
Chapter 5: TextField and TextArea 54
Enter Text into a Text Field by Name 54
Enter Text into a Text Field by ID 54
Enter Text into a Password Field 55
Clear a Text Field 55
Enter Text into a Multiline Text Area 55
Assert Value 55
Focus on a Control 55
Set a Value to a Read-only or Disabled Text Field 56
Set and assert the value of a hidden field 56
Chapter 6: Radio Button 57
Select a Radio Button 57
Clear Radio Option Selection 58
Assert a Radio Option is Selected 58
Iterate Radio Buttons in a Radio Group 59
Click nth Radio Button in a Group 59
Click Radio Button by the Following Label 59
Customized Radio Buttons: iCheck 60
Chapter 7: Check Box 62
Check by name 62
Check by ID 62
Clear a check box 63
Assert a check box is checked (or not) 63
Chain FindElement to find child elements 63
Customized Check Boxes: iCheck 64
Chapter 8: Select List 65
Select an option by text 65
Select an option by value 66
Select an option by index 66
Select an option by iterating all options 66
Select multiple options 67
Clear one selection 67
Clear all selections 68
Assert selected option 68
Assert the value of a select list 68
Assert multiple selections 68
Chapter 9: Navigation and Browser 69
Go to a URL 69
Visit pages within a site 69
Perform actions from the right-click context menu 70
Open browser in certain size 70
Maximize browser window 70
Move browser window 70
Minimize browser window 71
Scroll focus to control 71
Switch between browser windows or tabs 71
Remember current web page URL and return to it later 72
Chapter 10: Assertion 73
Assert page title 73
Assert page text 73
Assert page source 74
Assert checkbox selected 74
Assert button enabled 74
Assert label text 74
Assert span text 75
Assert div text or HTML 75
Assert table text 76
Assert text in a table cell 76
Assert text in a table row 77
Assert image present 77
Chapter 11: Frames 78
Testing Frames 78
Testing iframe 79
Test multiple iframes 80
Chapter 12: AJAX 81
Wait within a time frame 82
Explicit waits until time out 82
Implicit waits until time out 82
Wait AJAX call to complete using JQuery 83
Chapter 13: Pop-up 84
File upload 84
JavaScript pop-ups 85
Modal style dialog boxes 86
Timeout on a test 86
Pop-up handler approach 87
Basic or Proxy Authentication dialog box 90
Internet Explorer modal dialog box 91
Chapter 14: Debugging Test Scripts 92
Print text for debugging 92
Write page source or element HTML into a file 92
Take a screenshot 93
Leave the browser open after test finishes 93
Debug test execution using Debugger 94
Enable breakpoints 94
Execute one test case in debugging mode 95
Step over test execution 95
Chapter 15: Test Data 96
Get date dynamically 96
Get a random boolean value 97
Generate a number within a range 98
Get a random character 99
Get a random string at fixed length 99
Get a random string in a collection 99
Generate a test file at fixed sizes 100
Retrieve data from database 100
Chapter 16: Browser Profile 102
Get browser type and version 102
Set HTTP proxy for browser 103
Verify file download in Chrome 103
Ve rify file download in Firefox 103
Bypass basic authentication by embedding username and password in URL 104
Bypass basic authentication with Firefox AutoAuth plug-in 105
Manage cookies 108
Headless browser testing with PhantomJS 108
Test responsive web sites 109
Chapter 17: Advanced User Interactions 110
Double-click a control 111
Move mouse to a control: Mouse over 111
Click and hold: Select multiple items 111
Context click: Right-click a control 112
Drag-and-drop 112
Drag slider 113
Send key sequences: Select All and Delete 114
Chapter 18: HTML5 and JavaScript 115
HTML5 email type field 115
HTML5 time field 116
Invoke ‘onclick’ JavaScript event 117
Invoke JavaScript events such as onchange 117
Scroll to the bottom of a page 118
Chosen: Standard select 118
Chosen: Multiple select 120
AngularJS web pages 124
Ember JS web pages 126
Chapter 19: WYSIWYG Editor 128
TinyMCE 128
CKEditor 129
SummerNote 130
CodeMirror 131
Chapter 20: Leverage Programming 132
Throw exceptions to fail test 132
Flag incomplete tests 133
Stop test execution during debugging a test 133
Ignorable test statement error 133
Read external file 134
Data-driven tests with Excel 134
Data-driven tests with CSV 137
Identify element IDs with dynamically generated long prefixes 138
Sending special keys such as Enter to an element or browser 139
Use of Unicode in test scripts 139
Extract a group of dynamic data: Verify search results in order 139
Verify uniqueness of a set of data 141
Extract dynamic visible data rows from a results table 141
Extract dynamic text following a pattern using Regex 143
Chapter 21: Optimization 145
Assert string in page_source is faster than the text 145
Getting text from more specific elements is faster 146
Avoid programming if-else block code if possible 146
Use variable to cache unchanged data 147
Enter large text into a text box 147
Use environment variables to change test behaviors dynamically 148
Test a web app in two languages 149
Multi-language testing with lookups 150
Chapter 22: Gotchas 153
Test starts browser but no execution with blank screen 153
Be aware of browser and driver changes 154
Failed to assert copied text in browser 154
The same test works for Chrome, but not for Internet Explorer 155
“Unexpected tag name ‘input’” 156
Element is not clickable or not visible 157
Chapter 23: Remote Control Server 158
Selenium Server installation 158
Execute tests in the specified browser on another machine 159
Selenium Grid 160
Start the hub 160
Start the nodes 161
Using Grid to run tests 161
Concerns with Selenium Grid 161
Chapter 24: Afterword 164
Practice makes perfect 164
Write tests 164
Improve programming skills 165
Successful test automation 165
Maintain test scripts to keep up with application changes 165
Shorten test execution time to get quick feedback 166
Chapter 25: Resources 167
Books 167
Web sites 167
Tools 167
Index 168

Erscheint lt. Verlag 28.12.2015
Zusatzinfo XXIV, 164 p. 99 illus.
Verlagsort Berkeley
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Mathematik / Informatik Informatik Software Entwicklung
Wirtschaft Betriebswirtschaft / Management
Schlagworte C# • Coding • C Sharp • Debugging • .NET • Quality Control, Reliability, Safety and Risk • selenium • Software • Testing
ISBN-10 1-4842-1742-X / 148421742X
ISBN-13 978-1-4842-1742-9 / 9781484217429
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 3,7 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Das Handbuch für Webentwickler

von Philip Ackermann

eBook Download (2023)
Rheinwerk Computing (Verlag)
37,43
Das umfassende Handbuch

von Johannes Ernesti; Peter Kaiser

eBook Download (2023)
Rheinwerk Computing (Verlag)
33,68