Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Selenium Testing Tools Cookbook
Selenium Testing Tools Cookbook

Selenium Testing Tools Cookbook: Unlock the full potential of Selenium WebDriver to test your web applications in a wide range of situations. The countless recipes and code examples provided ease the learning curve and provide insights into virtually every eventuality.

Arrow left icon
Profile Icon UNMESH GUNDECHA
Arrow right icon
₱2500.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (23 Ratings)
Paperback Nov 2012 326 pages 1st Edition
eBook
₱579.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Arrow left icon
Profile Icon UNMESH GUNDECHA
Arrow right icon
₱2500.99
Full star icon Full star icon Full star icon Full star icon Empty star icon 4 (23 Ratings)
Paperback Nov 2012 326 pages 1st Edition
eBook
₱579.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
eBook
₱579.99 ₱2000.99
Paperback
₱2500.99
Subscription
Free Trial

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Selenium Testing Tools Cookbook

Chapter 2. Working with Selenium API

In this chapter, we will cover:

  • Checking an element's text

  • Checking an element's attribute values

  • Checking an element's CSS values

  • Using Advanced User Interactions API for mouse and keyboard events

  • Performing double-click on an element

  • Performing drag-and-drop operations

  • Executing JavaScript code

  • Capturing screenshots with Selenium WebDriver

  • Capturing screenshots with RemoteWebDriver/Grid

  • Maximizing the browser window

  • Automating dropdowns and lists

  • Checking options in dropdowns and lists

  • Checking selected options in dropdowns and lists

  • Automating radio buttons and radio groups

  • Automating checkboxes

  • Controlling a Windows process

  • Reading a Windows registry value from Selenium WebDriver

  • Modifying a Windows registry value from Selenium WebDriver

Introduction


Selenium WebDriver implements a very comprehensive API for working with web elements, Advanced User Interactions, executing JavaScript code, and support for various types of controls such as List, Dropdown, Radio Button, and Checkbox.

In this chapter, we will explore how these APIs can be used to build simple to complex test steps. This chapter will also help in overcoming some common issues while building tests with Selenium WebDriver. The chapter examples are created with Selenium WebDriver Java bindings. The sample code for this chapter contains some of these recipes implemented with C#, Ruby, and Python.

Checking an element's text


While testing a web application, we need to verify that elements are displaying correct values or text on the page. Selenium WebDriver's WebElement API provides various ways to retrieve and verify text. Sometimes, we need to retrieve text or value from an element into a variable at runtime and later use it at some other place in the test flow.

In this recipe, we will retrieve and verify text from an element by using the WebElement class' getText() method .

How to do it...

Here, we will create a test that locates an element and then retrieves text from the element in a string variable. We will verify contents of this string for correctness.

@Test
public void testElementText()
{
  //Get the message Element
  WebElement message = driver.findElement(By.id("message"));
  
  //Get the message elements text
  String messageText = message.getText();
  
  //Verify message element's text displays "Click on me and my //color will change"
  assertEquals("Click on me and my color...

Checking an element's attribute values


Developers configure various attributes of elements displayed on the web page during design or at runtime to control the behavior or style of elements when they are displayed in the browser. For example, the <input> element can be set to read-only by setting the readonly attribute.

There will be tests that need to verify that element attributes are set correctly. We can retrieve and verify an element's attribute by using the getAttribute() method of the WebElement class.

In this recipe, will check the attribute value of an element by using the getAttribute() method.

How to do it...

Create a test which locates an element and check its attribute value as follows:

@Test
public void testElementAttribute()
{
  WebElement message = driver.findElement(By.id("message"));
  assertEquals("justify",message.getAttribute("align"));
}

How it works...

By passing the name of the attribute to the getAttribute() method, it returns the value of the attribute back to the...

Checking an element's CSS values


Various styles are applied on elements displayed in a web application, so they look neat and become more usable. Developers add these styles using CSS (also known as Cascading Style Sheets). There may be tests that need to verify that correct styles have been applied to the elements. This can be done using WebElement class's getCSSValue() method, which returns the value of a specified style attribute.

In this recipe, we will use the getCSSValue() function to check the style attribute defined for an element.

How to do it...

Let's create a test which reads the CSS width attribute and verifies the value.

@Test
public void testElementStyle()
{
  WebElement message = driver.findElement(By.id("message"));
  String width = message.getCssValue("width");
  assertEquals("150px",width);
}

How it works...

By passing the name of CSS attribute to the getCSSValue() method, it returns the value of the CSS attribute. In this example, we are checking that the width attribute of...

Using Advanced User Interactions API for mouse and keyboard events


The Selenium WebDriver's Advanced User Interactions API allows us to perform operations from keyboard events and simple mouse events to complex events such as dragging-and-dropping, holding a key and then performing mouse operations by using the Actions class, and building a complex chain of events exactly like a user doing these manually.

The Actions class implements the builder pattern to create a composite action containing a group of other actions.

In this recipe, we will use the Actions class to build a chain of events to select rows in a table.

How to do it...

Let's create a test to select the multiple rows from different positions in a table using the Ctrl key. We can select multiple rows by selecting the first row, then holding the Ctrl key, and then selecting another row and releasing the Ctrl key. This will select the desired rows from the table.

@Test
public void testRowSelectionUsingControlKey() {
  
  List<WebElement...

Performing double-click on an element


There will be elements in a web application that need double-click events fired for performing some actions. For example, double-clicking on a row of a table will launch a new window. The Advanced User Interaction API provides a method to perform double-click.

In this recipe, we will use the Actions class to perform double-click operations.

How to do it...

Let's create a test that locates an element for which a double-click event is implemented. When we double-click on this element, it changes its color.

@Test
public void testDoubleClick() throws Exception
{
  WebDriver driver = new ChromeDriver();
  driver.get("http://dl.dropbox.com/u/55228056/DoubleClickDemo.html");
    
  WebElement message = driver.findElement(By.id("message"));
    
  //Verify color is Blue
  assertEquals("rgb(0, 0, 255)",message.getCssValue("background-color").toString());
  
  Actions builder = new Actions(driver);
  builder.doubleClick(message).build().perform();
  
  //Verify Color...

Performing drag-and-drop operations


Selenium WebDriver implements Selenium RC's dragAndDrop command using Actions class. As seen in earlier recipes the Actions class supports advanced user interactions such as firing various mouse and keyboard events. We can build simple or complex chains of events using this class.

In this recipe, we will use the Actions class to perform drag-and-drop operations.

How to do it...

Let's implement a test which will perform a drag-and-drop operation on a page using the Actions class.

@Test
public void testDragDrop() {
  
  driver.get("http://dl.dropbox.com/u/55228056/DragDropDemo.html");
  
  WebElement source = driver.findElement(By.id("draggable"));
  WebElement target = driver.findElement(By.id("droppable"));

  Actions builder = new Actions(driver);
  builder.dragAndDrop(source, target).perform();
  try
  {
    assertEquals("Dropped!", target.getText());
  } catch (Error e) {
    verificationErrors.append(e.toString());
  }
}

How it works...

For dragging an element...

Executing JavaScript code


Selenium WebDriver API provides the ability to execute JavaScript code with the browser window. This is a very useful feature where tests need to interact with the page using JavaScript. Using this API, client-side JavaScript code can also be tested using Selenium WebDriver. Selenium WebDriver provides a JavascriptExecutor interface that can be used to execute arbitrary JavaScript code within the context of the browser.

In this recipe, we will explore how to use JavascriptExecutor for executing JavaScript code. This book has various other recipes where JavascriptExecutor has been used to perform some advanced operations that are not yet supported by the Selenium WebDriver.

How to do it...

Let's create a test that will call JavaScript code to return title and count of links (that is a count of Anchor tags) from a page. Returning a page title can also be done by calling the driver.getTitle() method.

@Test
public void testJavaScriptCalls() throws Exception
{
  WebDriver...

Capturing screenshots with Selenium WebDriver


Selenium WebDriver provides the TakesScreenshot interface for capturing a screenshot of a web page. This helps in test runs, showing exactly happened when an exception or error occurred during execution, and so on. We can also capture screenshots during verification of element state, values displayed, or state after an action is completed.

Capturing screenshots also helps in verification of layouts, field alignments, and so on where we compare screenshots taken during test execution with baseline images.

In this recipe, we will use the TakesScreenshot interface to capture a screenshot of the web page under test.

How to do it...

Let's create a test that will open our test application and take a screenshot of the page in PNG format.

@Test
public void testTakesScreenshot()
{
  try {
    File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(scrFile, new File("c:\\tmp\\main_page.png"));
  } catch (Exception e...

Capturing screenshots with RemoteWebDriver/Grid


While running tests with RemoteWebDriver or Grid it is not possible to take the screenshots, as the TakesScreenshot interface is not implemented in RemoteWebDriver.

However, we can use the Augmenter class which adds the TakesScreenshot interface to the remote driver instance.

In this recipe, we will use the Augmenter class to capture a screenshot from RemoteWebDriver.

Getting ready

Create a test which uses RemoteWebDriver.

How to do it...

Add the following code to the test using RemoteWebDriver:

driver = new Augmenter().augment(driver);
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

How it works...

The Augmenter class enhances the RemoteWebDriver by adding to it various interfaces including the TakesScreenshot interface.

driver = new Augmenter().augment(driver);

Later we can use the TakesScreenshot interface from RemoteWebDriver to capture the screenshot.

Maximizing the browser window


Selenium RC's windowMaximize() command was missing in Selenium WebDriver. However starting from release 2.21, Selenium WebDriver supports maximizing the browser window.

In this short recipe, we will see how to maximize the browser window.

Getting ready

Create a new test which will get an instance of WebDriver, navigate to a site and perform some basic actions and verifications.

How to do it...

To maximize a browser window, we need to call the maximize() method of the Window interface of the driver class. Add the second line right below where you define an instance of FirefoxDriver.

driver = new FirefoxDriver();
driver.manage().window().maximize();

How it works...

The WebDriver class provides the window interface for setting up the browser window size, state, and so on. When we call the maximize() method, the browser window will be maximized from normal or minimized state.

driver.manage().window().maximize();

Automating dropdowns and lists


Selenium WebDriver supports testing Dropdown and List controls using a special Select class instead of the WebElement class.

The Select class provides various methods and properties to interact with dropdowns and lists created with the HTML <select> element.

In this recipe, we will automate Dropdown and List control using Select class.

How to do it...

Let's create a test for a Dropdown control. This test will perform some basic checks and then call various methods to select options in dropdown.

@Test
public void testDropdown()
{
  //Get the Dropdown as a Select using its name attribute
  Select make = new Select(driver.findElement(By.name("make")));
  
  //Verify Dropdown does not support multiple selection
  assertFalse(make.isMultiple());
  //Verify Dropdown has four options for selection
  assertEquals(4, make.getOptions().size());
  
  //With Select class we can select an option in Dropdown using //Visible Text
  make.selectByVisibleText("Honda");
  assertEquals...

Checking options in dropdowns and lists


While testing the dropdowns and lists created with the <select> element, there will be a need to check that correct options are displayed for user selection. These options may be static or populated from a database.

In this recipe we will see how options can be checked against the expected values.

Getting ready

This recipe will need the test created from the earlier Automating dropdowns and lists recipe. We will add additional steps for checking the options.

How to do it...

Let's modify the testDropdown() test method for checking the options. Add the following highlighted code to the test:

@Test
public void testDropdown()
{
  //Get the Dropdown as a Select using its name attribute
  Select make = new Select(driver.findElement(By.name("make")));
  
  //Verify Dropdown does not support multiple selection
  assertFalse(make.isMultiple());
  //Verify Dropdown has four options for selection
  assertEquals(4, make.getOptions().size());
  
  //We will verify...

Checking selected options in dropdowns and lists


In earlier recipes, we saw how to select options in the Dropdown and List controls as well as check what options are available for selection. We also need to verify that the correct options are selected in these controls, either by default or by the user.

In this recipe, we will see how to check options which are selected in a dropdown or list.

Getting ready

This recipe will need the test created from the earlier Automating dropdowns and lists recipe. We will add additional steps for checking the options.

How to do it...

Let's modify the testDropdown() test method for checking the options. Add the following highlighted code to the test:

@Test
public void testDropdown()
{
  ...
  
  //With Select class we can select an option in Dropdown using //Visible Text
  make.selectByVisibleText("Honda");
  assertEquals("Honda", make.getFirstSelectedOption().getText());
  
  //or we can select an option in Dropdown using value attribute
  make.selectByValue...

Automating radio buttons and radio groups


Selenium WebDriver supports Radio Button and Radio Group controls using the WebElement class. We can select and deselect the radio buttons using the click() method of the WebElement class and check whether a radio button is selected or deselected using the isSelected() method.

In this recipe, we will see how to work with the Radio Button and Radio Group controls.

How to do it...

Let's create a test which gets Radio Button and Radio Group controls. We will perform select and deselect operations.

@Test
public void testRadioButton()
{
  //Get the Radiobutton as WebElement using it's value attribute
  WebElement petrol = driver.findElement(By.xpath("//input[@value='Petrol']"));
  
  //Check if its already selected? otherwise select the Radiobutton 
  //by calling click() method 
  if (!petrol.isSelected())
    petrol.click();
  
  //Verify Radiobutton is selected 
  assertTrue(petrol.isSelected());
  
  //We can also get all the Radiobuttons from a Radio...

Automating checkboxes


Selenium WebDriver supports Checkbox control using the WebElement class. We can select or deselect a checkbox using the click() method of the WebElement class and check whether a checkbox is selected or deselected using the isSelected() method.

In this recipe, we will see how to work with the Checkbox control.

How to do it...

Here is a test which gets a Checkbox control. We will perform select and deselect operations.

@Test
public void testCheckBox()
{
  //Get the Checkbox as WebElement using it's value attribute
  WebElement airbags = driver.findElement(By.xpath("//input[@value='Airbags']"));
  
  //Check if its already selected? otherwise select the Checkbox
  //by calling click() method
  if (!airbags.isSelected())
    airbags.click();
  
  //Verify Checkbox is Selected
  assertTrue(airbags.isSelected());

  //Check Checkbox if selected? If yes, deselect it
  //by calling click() method
  if (airbags.isSelected())
    airbags.click();
  
  //Verify Checkbox is Deselected...

Controlling Windows processes


Selenium WebDriver Java bindings provide the WindowsUtils class with methods to interact with the Windows operating system. During test runs, there might be a need to close open instances of browser windows or processes at the beginning of the test. By using the WindowsUtils class, we can control the process and perform tasks, such as killing an open process, and so on.

In this recipe, we will use the WindowsUtils class to kill the open browser window.

How to do it...

Let's close an open instance of Firefox by using the WindowsUtils class in the setUp() method as follows:

@Before
public void setUp()
{
  WindowsUtils.tryToKillByName("firefox.exe");
  driver = new FirefoxDriver();
  driver.get("http://www.google.com");
  driver.manage().window().maximize();
}

How it works...

We can close or kill any process running on the Windows OS by using the tryToKillByName() function of the WindowsUtils class. We need to pass the name of process we wish to close.

WindowsUtils.tryToKillByName...

Reading a Windows registry value from Selenium WebDriver


The WindowsUtils class provides various methods to interact with the registry on the Windows operating system. While running tests on the Windows operating system and Internet Explorer, the test might need to read and modify IE settings or there may be a need to get some settings related to the web server or database from the registry in tests. The WindowsUtils class comes handy in these situations.

In this recipe, we will use WindowsUtil to read the exact name of the operating system on which the test is running. We might need this information printed in our test logs.

How to do it...

We need to import the org.openqa.selenium.os.WindowsUtils class and use the readStringRegistryValue() method for reading a registry value that is represented as a String.

String osname = WindowsUtils.readStringRegistryValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProductName");
System.out.println(osname);

How it works...

The WindowsUtils...

Modifying a Windows registry value from Selenium WebDriver


The WindowsUtils class also provides methods to update existing Windows registry values or create new registry keys and values. Similar to reading registry values, WindowsUtils class provides multiple methods to modify keys and values.

In this recipe, we will use the WindowsUtils class to create a new registry key with a string value.

How to do it...

Use the writeStringRegistryValue() method for modifying existing Windows registry value or creating a new key and value represented as a string.

WindowsUtils.writeStringRegistryValue("HKEY_CURRENT_USER\\SOFTWARE\\Selenium\\SeleniumVersion", "2.24");
assertEquals("2.24",WindowsUtils.readStringRegistryValue("HKEY_CURRENT_USER\\SOFTWARE\\Selenium\\SeleniumVersion")); 

How it works...

When the writeStringRegistryValue() method is executed along with the path, a new registry key will be created in HKEY_CURRENT_USER\SOFTWARE with Selenium and a new value will be stored in SeleniumVersion.

WindowsUtils...
Left arrow icon Right arrow icon

Key benefits

  • Learn to leverage the power of Selenium WebDriver with simple examples that illustrate real world problems and their workarounds
  • Each sample demonstrates key concepts allowing you to advance your knowledge of Selenium WebDriver in a practical and incremental way
  • Explains testing of mobile web applications with Selenium Drivers for platforms such as iOS and Android

Description

Web technologies are becoming increasingly complex and there is a need to test your web applications against a vast number of browsers and platforms, so you need to build highly reliable and maintainable test automation. This book will help you test your web applications effectively and efficiently with Selenium WebDriver."Selenium Testing Tools Cookbook" is an incremental guide that will help you learn and use advanced features of Selenium WebDriver API in various situations for building reliable test automation. You will learn how to effectively use features of Selenium using simple and detailed examples. This book will also teach you best practices, design patterns, and how to extend Selenium."Selenium Testing Tools Cookbook" shows developers and testers who already use Selenium, how to go to the next step and build a highly maintainable and reliable test framework using advanced features of the tool.The book starts with tips on advanced location strategy and effective use of Selenium WebDriver API. Then it demonstrates the use of design patterns such as Data Driven Tests and PageFactory for building maintainable test automation. It also explains extending Selenium WebDriver API along with implementing custom tasks and setting up your own distributed environment to run tests in parallel.It concludes with tips on integrating Selenium WebDriver with other popular tools, testing mobile web applications, and capturing videos of test runs. This books provides examples in Java, C#, Ruby, and Python."Selenium Testing Tools Cookbook" will help you in building a highly robust and maintainable test automation framework from start to finish.

Who is this book for?

This book is intended for software quality assurance/testing professionals, software project managers, or software developers with prior experience in using Selenium and Java for testing web-based applications. This book also provides examples for C#, Python, and Ruby users.

What you will learn

  • Understand Locators and use various locator methods to build reliable tests
  • Build reliable and maintainable tests with Selenium WebDriver API
  • Use PageFactory Pattern to build a robust and easy- to-maintain test framework
  • Build data driven tests and extend Selenium API to implement custom steps and checks
  • Learn to integrate and use ATDD/BDD tools such as JBehave, SpecFlow, and FitNesses with Selenium WebDriver
  • Set up iPhone/iPad & Android simulators and devices for testing your mobile web application
  • Set up Selenium Grid for faster and parallel run of tests, increasing test coverage and reducing test execution time
  • Capture screenshots and videos of test runs
Estimated delivery fee Deliver to Philippines

Standard delivery 10 - 13 business days

₱492.95

Premium delivery 5 - 8 business days

₱2548.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 23, 2012
Length: 326 pages
Edition : 1st
Language : English
ISBN-13 : 9781849515740
Category :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Philippines

Standard delivery 10 - 13 business days

₱492.95

Premium delivery 5 - 8 business days

₱2548.95
(Includes tracking information)

Product Details

Publication date : Nov 23, 2012
Length: 326 pages
Edition : 1st
Language : English
ISBN-13 : 9781849515740
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 4,337.98
Selenium Design Patterns and Best Practices
₱1836.99
Selenium Testing Tools Cookbook
₱2500.99
Total 4,337.98 Stars icon
Banner background image

Table of Contents

11 Chapters
Locating Elements Chevron down icon Chevron up icon
Working with Selenium API Chevron down icon Chevron up icon
Controlling the Test Flow Chevron down icon Chevron up icon
Data-driven Testing Chevron down icon Chevron up icon
Using the Page Object Model Chevron down icon Chevron up icon
Extending Selenium Chevron down icon Chevron up icon
Testing on Mobile Browsers Chevron down icon Chevron up icon
Client-side Performance Testing Chevron down icon Chevron up icon
Testing HTML5 Web Applications Chevron down icon Chevron up icon
Recording Videos of Tests Chevron down icon Chevron up icon
Behavior-driven Development Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
(23 Ratings)
5 star 30.4%
4 star 52.2%
3 star 13%
2 star 0%
1 star 4.3%
Filter icon Filter
Top Reviews

Filter reviews by




kotoko Mar 02, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very well written for someone who is beginning to learn working on Selenium as well as advancing to refining and enhancing knowledge. It presents a good information recipe to accomplish functional test scripts. It also, easy to understand for technical and non-technical
Amazon Verified review Amazon
Roy Fine Feb 10, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
If you are doing automated web testing, you should consider Selenium. Not a lot of info in the book that cannot be found online, but having it handy on my Kindle is well worth the modest price of the book. Note - the books works very nicely with Kindle HD and Kindle PC AppThe book is full of "How to do" cases with complete details, and at the end of each there is a "How it works" sections.Selenium API are available to supports several languages: Java, C#, Python, and others I suspect. All of our test work is driven from python - and fortunate for us there were plenty of plenty of python based examples in the bookIf you have experience in one of the driver languages, and if you are accomplished enough to have developed a website with more than just one page, then this book is a good first read. Others have noted it is not for the beginner - but I found it well written and detailed enough for the average web developer.
Amazon Verified review Amazon
M. Zuzic Jul 14, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I read this book cover to cover over the space of a week, which is the first time I've ever read an entire techical book before.You will benefit largely to have an understanding of programming languages when reading this book. In my case, I have a software development background and an automated test development background which must be why I found the book so interesting.I have started to apply the concepts detailed in the book to my current project which is proving to be a fantastic basis for a highly maintainable and well structured framework.Well done to the author, I will certainly cnsider future updates as Selenium evolves
Amazon Verified review Amazon
Michael Larsen Jan 21, 2013
Full star icon Full star icon Full star icon Full star icon Full star icon 5
As the experience level with Selenium and other open source automation tools grows, naturally there will also develop more questions. How would I effectively access elements? What's a good way to compartmentalize tests? How can I make my tests extensible? What's the best way to parallelize tests? What if my project doesn't use a standard approach like so many others? What if I'm not on Linux, or don't use Java?The idea and benefit of a "Cookbook" approach is that it allows developers and testers to look at the aspects that they need at that time, and see how they work in example formats, and then see how they relate to other topics. Packt has decided to take this approach with Selenium by publishing the Selenium Testing Tools Cookbook. In it, author Unmesh Gundecha has broken down thirteen areas of interest (eleven in the book itself, plus two additional areas as bonus download sections), and presents small sections and ideas to allow the developer or tester to leverage the ability to create tests, use the Selenium API, and test applications such as browsers and mobile applications. The book demonstrates examples primarily in Java, but several are provided that use C#, Python and Ruby.For the tl;dr crowd, if you have never used Selenium before, this should not be the book to start your exploration. I would suggest reading David Burns "Selenium 2 Testing Tools Beginner's Guide" or Alan Richardson's "Selenium Simplified" first. David's book is also a Packt Publishing title, and uses many of the same documentation standards, so it would feel very natural looking at section's of David's book, and then coming back to try out more examples in Unmesh's Cookbook here.As this is a Cookbook style title, I must give a disclaimer that I have not yet tried every single example in the book. For that matter, I haven't gone through even a minority of the examples, and that's OK. Cookbook's are not designed to be read from cover to cover, and neither is this one. It is expected, and intended, that the user pick an area that interested them, and explore that area. Different projects have different needs, and being able to skip around will help focus the reader's time on the areas that matter most to them at that given time.Each chapter uses a similar structure, with an introduction to explain the tools and calls that will be used in that section. The given recipe is described and gives the reader an idea as to what can be done (along with sample code for each of the recipes, which can be downloaded from Packt's site if you prefer to see the projects in their entirety, and would rather not have to type out the examples from the book directly. Each item then goes through and describes what you will need to accomplish the project at hand (if you need tools like Firebug or Intellij IDEA, it tells you what you need and where to get them). The recipe concludes with a How it Works section, and in many cases, additional recipes that relate to the one you are working with.The book starts out with locating elements, and the different ways in which that can be accomplished (CSS, XPath, text values, jQuery, locating table rows and cells, etc.).Next the Selenium API is explored and the various methods available to examine and determine what you are looking at (text, attributes, CSS values, interacting with the mouse and keyboard, using JavaScript, capturing screenshots, drop downs and menu items, even going in and changing values in the Windows Registry if desired).Chapters Three and Four will be important to testers especially, since these chapters deal with test flow and ways to create data driven tests. Topics such as waiting for elements, handling pop-ups, determining if elements are the correct state, working with JavaScript alerts, handling frames and iFRAME's, plus using a variety of frameworks to interact with tests and set up data driven tests in these frameworks are explored, with examples for Java, win32, Ruby and Python.Chapter Five talks about the Page Object model and how to use it when developing your tests in the languages covered in the book (Java especially, but examples also show how to use .NET, Python and Ruby).Chapter Six gets into some examples of how to extend selenium and shows some in depth examples using Java (examples include making an extension class for web tables, jQueryUI Tab widget, creating an object map for Selenium tests, capturing screenshots and comparing images).Chapter Seven Shows how to perform mobile testing using Selenium, and some of the tools and ways to automate tests on iPhone an Android devices using RemoteWebDriver and other tools, such as the iWebDriver App to be used on a simulator or real device, or AndroidDriver on an android Simulator or device)Chapter Eight demonstrates some examples of how to get a handle on the Performance aspects of your sites or applications. Using timers, accessing and using BrowserMob proxy, and integrating with dynaTrace or HttpWatch are likewise covered. For the Ruby users among us, an example with Watir-WebDriver-Performance is demonstrated.Chapter Nine covers HTML5 and some of the unique tools provided with HTML5, JavaScript and CSS3, such as video widgets, canvas and web storage, and how to interact with those elements.Chapter Ten shows a number of ways in which a user could Record a Video of a Test (not record and playback of a test, actually recording an instance of the test being run as a video file, so it can be reviewed later. Tools such as the Monte Media Library (Java), Microsoft Expression Encoder (.NET) and Castro (Python) are demonstrated.Chapter Eleven discusses Behavior Driven Development (BDD). There are several different books that go into this topic at length, so for more on how this works and how to leverage that aspect, you will definitely want to read more than this single chapter. Still, if you are interested in how BDD can be performed in different environments, this will be of interest. The goal of TDD is meant to be a way to write test cases in a more natural language that those who do not program can both read and, in some cases, create themselves. Ruby users will find examples using Cucumber and Cabybara. Java users will see examples using Cucumber-JVM and JBehave. .NET uses will see examples using SpecFlow.NET.Two additional chapters, Integration with Other Tools and Distributed Testing with Selenium Grid are not included with the book itself, but can be downloaded from the Packt site. these deal with integrating with tools like Eclipse and IntelliJ IDEA, as well as using Ant and Maven for Continuous Integration, as well as parallelization of tests using Selenium Grid.Bottom Line:We now have a number of titles to help users get into the world of Selenium and SeleniumWebDrier. Each of these titles, by necessity, can only go so deep and with so many examples. For many, that would be fine. For those who want to know "what's next" or "where could I take these ideas and expand on them" or even "can you give me some ideas as to where I might use the variety of options?", then Selenium Testing Tools Cookbook may be a great next step to explore. One thing's for sure, there's plenty in this book to keep the Selenium enthusiast busy for quite some time.
Amazon Verified review Amazon
Aziz Mar 15, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Written for the Tester novice, this book is a concise, thorough, and accurate and helps immensely for Test Managers also.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela