Packt Publishing, 2015. — 284 p. — ISBN: 978-1784394332.
Utilize Selenium WebDriver features for automation testing using outstanding techniques and strategies.
Learn how to build, customize, and maintain Selenium frameworks.
Packed with numerous practical examples, this book covers all the functions and commands that will help you grasp Selenium functions quickly.
Who This Book Is ForIf you are a developer who wants to migrate from Selenium RC or any other automation tool to Selenium WebDriver, then this book is for you. Knowledge of automation tools is necessary to follow the examples in this book.
In DetailThis book will help you seamlessly migrate from Selenium RC to Selenium WebDriver. You will be able to quickly develop automated tests with little effort. Based on popularity, support, and usage, the scripts throughout the book are in Java.
We will start off by familiarizing you with the Selenium IDE, teaching you its functions, and using it to automate and debug a complex website. Next, we will harness the power of Selenium WebDriver to perform cross-browser automation tests. We will then go to the next level and run automation tests on the cloud. After this, we will cover a wide range of functions provided by the Selenium WebDriver API that can be used for effective web automation tests. Finally, you will learn how to perform Data-Driven and Behavior-Driven tests.
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. The Selenium IDE
WebDriver playback
Prerequisites for the WebDriver playback feature
Locator prioritization
Avoiding Selenium export
The Selenium IDE clipboard
Data Driven tests
User-defined JavaScript methods
Selenium IDE JavaScript functions
Simple JavaScript execution
Mouse scroll
Parameterization using arrays
Selenium Builder
Recording and playback
Data Driven tests
Testing using a JSON file
Testing using an XML file
Selenium Builder on the cloud
Summary
2. Selenium WebDriver Cross-browser Tests
Selenium WebDriver compatibility tests
TestNG
Selenium cross-browser tests on the cloud
SauceLabs
BrowserStack
TestingBot
Selenium headless browser testing
PhantomJS
HTMLUnitDriver
Switching user agents
Firefox user agent
Chrome user agent
Tests on specific Firefox versions
Tests from the custom Firefox profile
Tests from the custom Chrome profile
Summary
3. Selenium WebDriver Functions
Basic WebDriver functions
Locating WebElements
WebElement functions
Navigation
Cookies
Window functions
Select functions
Handling alerts and pop-ups
Mouse and keyboard actions
Summary
4. Selenium WebDriver Best Practices
Handling Ajax websites
The isElementPresent method
Waits
Explicit wait
The FluentWait method
Sleeper
Timeouts
The PageObject pattern
The PageFactory class
The @FindBy annotation
The @FindBys annotation
The EventFiringWebDriver class
Event-firing WebDriver example
Handling iframes
Handling native OS and browser pop-ups using Java Robot
Downloading browser pop-ups
Screen capture
Firefox profile to download files
The JavascriptExecutor class
Page scroll
Highlighting elements
Opening a new browser window
JavaScript error collector
Summary
5. Selenium WebDriver Frameworks
Behaviour-Driven Development
Cucumber BDD framework
Cucumber JVM
JBehave BDD framework
JXL API Data-Driven framework
Reading and writing in an Excel sheet
Simple Data-Driven approach
Data-Driven testing using reusable library
Data-Driven testing using TestNG with the @dataProvider annotation
Apache POI Data-Driven framework
HSSF usermodel – Binary workbook
XSSF usermodel – SpreadsheetML workbook (.xlsx)
SS usermodel – Binary and SpreadsheetML workbooks
Text file Data-Driven framework
Data-Driven testing using TestNG with the @dataProvider annotation – text file
Properties file Data-Driven framework
Data-Driven testing using TestNG with @dataProvider annotation – properties file
CSV file Data-Driven framework
Keyword-Driven framework
Hybrid-Driven framework
Summary
Index