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
Learning Selenium Testing Tools - Third Edition
Learning Selenium Testing Tools - Third Edition

Learning Selenium Testing Tools - Third Edition: Leverage the power of Selenium to build your own real-time test cases from scratch , Third Edition

Arrow left icon
Profile Icon Raghavendra Prasad MG
Arrow right icon
S$46.99 S$52.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (11 Ratings)
eBook Feb 2015 318 pages 3rd Edition
eBook
S$46.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
Arrow left icon
Profile Icon Raghavendra Prasad MG
Arrow right icon
S$46.99 S$52.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4 (11 Ratings)
eBook Feb 2015 318 pages 3rd Edition
eBook
S$46.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial
eBook
S$46.99 S$52.99
Paperback
S$66.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

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

Learning Selenium Testing Tools - Third Edition

Chapter 1. Getting Started with Selenium IDE

Test automation has grown in popularity over the years because developers do not have the time or money to invest in large test teams to make sure that applications work as they are expected. Developers also want to make sure that the code they have created works as they expect it to.

Jason Huggins saw this issue too and wanted to make sure that any system he was working on would work on multiple operating systems and browsers. So he created Selenium.

Selenium IDE is a fully-featured IDE (Integrated Development Environment) that installs as a plugin in Mozilla Firefox and enables developers to test their web applications through Selenium. With the Selenium IDE, you can record user interactions with the web browser and play them back to test for errors. It's a powerful, robust IDE that radically simplifies and automates the QA testing process.

Selenium is one of the most well-known testing frameworks in the world that is in use. It is an open source project that allows testers and developers alike to develop functional tests to drive the browser. It can be used to record workflows so that it reduces the time in regression testing. Selenium can work on any browser that supports JavaScript, since Selenium has been built using JavaScript.

In this chapter, you will learn the basics of the Selenium IDE, how to use it, and how to locate a web element on a web page. We shall cover the following topics:

  • What is Selenium IDE
  • Recording our first test
  • Updating tests to work with AJAX sites
  • Using variables in our tests
  • Debugging tests
  • Saving tests to be used later
  • Creating and saving test suites

Note

So, let's get on with it...

Before we start working through this chapter, we need to make sure that Mozilla Firefox is installed on your machine. If you do not have Mozilla Firefox installed, you will need to download it from http://www.getfirefox.com/.

Understanding Selenium IDE

Selenium IDE is a Firefox add-on developed originally by Shinya Kasatani as a way to use the original Selenium Core code without having to copy Selenium Core onto the server. Selenium Core is the key JavaScript module that allows Selenium to drive the browser. It has been developed using JavaScript so that it can interact with DOM (Document Object Model) using native JavaScript calls.

Selenium IDE was developed to allow testers and developers to record their actions as they follow the workflow that they need to test.

Installing Selenium IDE

Now that we understand what Selenium IDE is, it is a good time to install it. At the end of these steps, you will have successfully installed Selenium IDE onto your computer:

  1. Go to http://seleniumhq.org/download/.
  2. Click on the download link for Selenium IDE. You may see a message appear saying Firefox prevented this site (seleniumhq.org) from asking you to install software on your computer. If you do, click the Allow button.
  3. A Firefox prompt will appear, as shown in the following screenshot:
    Installing Selenium IDE
  4. You will then be asked if you would like to install Selenium IDE and the exporter add-ons. These have been made pluggable to the IDE by the work that Adam Goucher did. You will see a screenshot similar to the following one:
    Installing Selenium IDE
  5. Click on Install button. This will now install Selenium IDE and formatters as Firefox add-ons.
  6. Once the installation process is complete, it will ask you to restart Firefox. Click the Restart Now button. Firefox will close and then reopen. If you have anything open in another browser, it might be worth saving your work as Firefox will try to go back to its original state. However, this cannot be guaranteed.
    Installing Selenium IDE
  7. Once the installation is complete, the add-ons window will show the Selenium IDE and its current version:
    Installing Selenium IDE

You have successfully installed Selenium IDE and we can start thinking about writing our first test.

Getting acquainted with the Selenium IDE tool

Now that Selenium IDE has been installed, let's take some time to familiarize ourselves with it. This will give us the foundation that we can use in later chapters. Open up Selenium IDE by going through the tools menu in Mozilla Firefox. Navigate to Tools | Selenium IDE. A window will appear. If the menu bar is not available, which is now the default in Firefox, you can launch Selenium IDE via Firefox | Web Developer | Selenium IDE.

Getting acquainted with the Selenium IDE tool

Starting from the top, I will explain what each of the items are:

  • Base URL: This is the URL that the test will start at. All open commands will be relative to Base URL unless a full path is inserted in the open command.
  • Speed Slider: This is the slider under the Fast and Slow labels in the screenshot.
  • Getting acquainted with the Selenium IDE tool: This play entire test suite icon runs all the tests in the IDE.
  • Getting acquainted with the Selenium IDE tool: This play current test case icon runs a single test in the IDE.
  • Getting acquainted with the Selenium IDE tool: This pause/resume icon pauses a test that is currently running.
  • Getting acquainted with the Selenium IDE tool: This step icon steps through the test once it has paused.
  • Getting acquainted with the Selenium IDE tool: This is the record button. This will be engaged when the test is recording.
  • The Command drop-down list has a list of all the commands that are needed to create a test. You can type into it to use the autocomplete functionality or use it as a dropdown.
  • The Target textbox allows you to input the location of the element that you want to work against.
  • The Find button, once the target box is populated, can be clicked to highlight the element on the page.
  • The Value textbox is where you place the value that needs to change. For example, if you want your test to type in an input box on the web page, you will put what you want it to type in the value box.
  • The Table tab will keep track of all your commands, targets, and values. It has been structured this way because the original version of Selenium was styled on FIT tests. FIT (Framework for Integrated Testing) was created by Ward Cunningham. The tests were originally designed to be run from HTML files and the IDE keeps this idea for its tests.
  • If you click the Source tab, you will be able to see the HTML that will store the test. Each of the rows will look like this:
      <tr>
        <td>open</td>
        <td>/chapter1</td>
        <td></td>
      </tr>
  • The area below the Value textbox will show the Selenium log while the tests are running. If an item fails, then it will have an [error] entry. This area will also show help on Selenium commands when you are working in the Command drop-down list. This can be extremely useful when typing commands into Selenium IDE instead of using the record feature.
  • The Log tab will show a log of what is happening during the test. The Reference tab gives you documentation on the command that you have highlighted, and is also useful if you forgot some command; users can just start writing command in the Command field, then select some like searched and read the reference.

Rules in creating tests with Selenium IDE

Now that we have installed Selenium IDE and understand what it is, we can think about working through our first tests. There are a few things that you need to consider when creating your first test. These rules apply to any form of test automation but need to be adhered to, especially when creating tests against a user interface:

  • Tests should always have a known starting point. In the context of Selenium, this can mean opening a certain page to start a workflow.
  • Tests should not have to rely on any other tests to run. If a test is going to add something, do not have a separate test to delete it. This is to ensure that if something goes wrong in one test, it will not mean you have a lot of unnecessary failures to check.
  • Tests should only test one thing at a time.
  • Tests should clean up after themselves.

These rules, like most rules, can be broken. However, breaking them can mean that you may run into issues later on, and when you have hundreds, or even thousands of tests, these small issues can mean that large parts of a test suite are failing.

With these rules in mind, let's create our first Selenium IDE test.

Recording your first test with Selenium IDE

We will record our first test using Selenium IDE. To start recording the tests, we will need to start Mozilla Firefox. Once it has been loaded, you will need to start Selenium IDE. You will find it under the Tools drop-down menu in Mozilla Firefox or in the Web Developer drop-down menu. Once loaded, it will look like the next screenshot. Note that the record button is engaged when you first load the IDE.

To start recording your tests, let's do the following:

  1. When in the record mode, navigate to http://book.theautomatedtester.co.uk/chapter1.
  2. On the web application, do the following:
    1. Click on the record button (red-colored radio button).
    2. Select another value from the drop-down box, for example, Selenium RC.
    3. Click on the Home Page link.
    Recording your first test with Selenium IDE
  3. Your test has now been recorded and should look like the preceding screenshot.
  4. Click the play button that looks like this icon: Recording your first test with Selenium IDE
  5. Once your test has completed, it will look like the following screenshot:
    Recording your first test with Selenium IDE

We have successfully recorded our first test and played it back. As we can see, Selenium IDE tried to apply the first rule of test automation by specifying the open command. It set the starting point of the test, in this case, /chapter1, and then it began stepping through the workflow that we want to record.

Once the actions have all been completed, you will see that all of the actions have a green background. This shows that they have completed successfully. On the left, you will see that it has completed one successful test, or run, within Selenium IDE. If you were to write a test that failed, the Failure label will have a 1 next to it.

Validating a test with assert and verify

In the last few steps, we were able to record a workflow that we would expect the user to perform. It will test that the relevant bit of functionality is there, such as buttons and links to work against. Unfortunately, we are not checking whether the other items on the page are there or if they are visible when they should be hidden. We will now work against the same page as before, but we shall make sure that different items are on the page.

There are two mechanisms for validating elements available on the application under test. The first is assert: this allows the test to check whether the element is on the page. If it is not available, then the test will stop on the step that failed. The second is verify: this allows the test to check if the element is on the page, but if it isn't, then the test will carry on execution. To add the assert or verify commands to the tests, we need to use the context menu that Selenium IDE adds to Firefox. All that one needs to do is right-click on the element if on Windows or Linux. If you have a Mac, then you will need to do the two-finger click to show the context menu.

When the context menu appears, it will look roughly like the following screenshot with the normal Firefox functions above it:

Validating a test with assert and verify

We will record the test and learn how to use/verify some commands as follows:

  1. Open the IDE so that we can start recording.
  2. Navigate to http://book.theautomatedtester.co.uk/chapter1.
  3. Select Selenium Grid from the drop-down box.
  4. Change the selection to Selenium Grid.
  5. Verify that the Assert that this text is on the page text is mentioned on the right-hand side of the drop-down box, by right-clicking on the text and selecting verifyText id=diveontheleft Assert that this text is on the page. You can see the command in the previous screenshot.
  6. Verify that the button is on the page. You will need to add a new command for verifyElementPresent with the verifybutton target in Selenium IDE.
  7. Now that you have completed the previous steps, your Selenium IDE should look like the following screenshot:
    Validating a test with assert and verify

If you now run the test, you will see it has verified that what you are expecting to see on the page has appeared. Notice that the verify commands have a darker green color. This is to show that they are more important to the test than moving through the steps. The test has now checked that the text we required is on the page and that the button is there too.

What will happen if the verify command did not find what it was expecting? The IDE would have thrown an error stating what was expected was not there, but then carried on with the rest of the test. We can see an example of this in the following screenshot:

Validating a test with assert and verify

The test would not have carried on if it was using assert as the mechanism for validating that the elements and text were loaded with the page.

We have just seen that we can add asserts or verification to the page. Selenium IDE does not do this when recording, so it will always be a manual step. The assert command will stop the running tests, unlike the verify command in which the tests will continue running even after failure. In both the cases, Selenium IDE will log an error. Each of these have their own merits.

Some of the verify and assert methods are as follows:

Selenium Command

Command Description

verifyElementPresent

This verifies an expected element is present on the page.

assertElementPresent

This asserts an expected element is present on the page.

verifyElementNotPresent

This verifies an expected element is not present on the page.

assertElementNotPresent

This asserts an expected element is not present on the page.

verifyText

This verifies expected text and its corresponding HTML tags are present on the page.

assertText

This asserts expected text and its corresponding HTML tags are present on the page.

verifyAttribute

This verifies the value of an attribute of any HTML tag on the page.

assertAttribute

This asserts the value of an attribute of any HTML tag on the page.

verifyChecked

This verifies whether the condition of the checkbox is checked or not on the page.

assertChecked

This asserts whether the condition of the checkbox is checked or not on the page.

verifyAlert

This verifies the alert present on the page.

assertAlert

This asserts the alert present on the page.

verifyTitle

This verifies an expected page title.

assertTitle

This asserts an expected page title.

Left arrow icon Right arrow icon

Description

If you are a software developer with a basic knowledge of testing and are interested in automated testing using Selenium, this is the book for you. No prior knowledge of Selenium is required.

Who is this book for?

If you are a software developer with a basic knowledge of testing and are interested in automated testing using Selenium, this is the book for you. No prior knowledge of Selenium is required.

What you will learn

  • Understand designing and implementing the automation framework
  • Understand and implement AJAX in your web pages
  • Set up Selenium WebDriver in both IntelliJ and Eclipse
  • Build test suites in Selenium using PageObjects
  • Get to know about WebElement handling with Selenium WebDriver
  • Install Selenium WebDriver for mobile devices
  • Understand and learn testing in Selenium Grid

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 24, 2015
Length: 318 pages
Edition : 3rd
Language : English
ISBN-13 : 9781784398040
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
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

Billing Address

Product Details

Publication date : Feb 24, 2015
Length: 318 pages
Edition : 3rd
Language : English
ISBN-13 : 9781784398040
Category :
Languages :
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 S$6 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 S$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total S$ 160.97
Selenium Essentials
S$44.99
Selenium Design Patterns and Best Practices
S$48.99
Learning Selenium Testing Tools - Third Edition
S$66.99
Total S$ 160.97 Stars icon

Table of Contents

16 Chapters
1. Getting Started with Selenium IDE Chevron down icon Chevron up icon
2. Locators Chevron down icon Chevron up icon
3. Overview of the Selenium WebDriver Chevron down icon Chevron up icon
4. Finding Elements Chevron down icon Chevron up icon
5. Design Patterns Chevron down icon Chevron up icon
6. Working with WebDriver Chevron down icon Chevron up icon
7. Automation Framework Development and Building Utilities Chevron down icon Chevron up icon
8. Mobile Devices Chevron down icon Chevron up icon
9. Getting Started with the Selenium Grid Chevron down icon Chevron up icon
10. Advanced User Interactions Chevron down icon Chevron up icon
11. Working with HTML5 Chevron down icon Chevron up icon
12. Advanced Topics Chevron down icon Chevron up icon
13. Migrating from Remote Control to WebDriver Chevron down icon Chevron up icon
A. Automation Prerequisites for Selenium Automation Chevron down icon Chevron up icon
B. Answers for Self-test Questions Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.4
(11 Ratings)
5 star 63.6%
4 star 9.1%
3 star 27.3%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Amazon Customer Feb 19, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Clearly written with good examples. Was able to get going quickly.
Amazon Verified review Amazon
Bhushan Jun 03, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Perfect book for fresher’s and new learnerWell summarized each and every feature
Amazon Verified review Amazon
Naveen Bharadwaj May 22, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I just started my career in automation team and selenium was a complete rocket science for me. The book authored by Raghavendra Prasad MG has been a great guide to me the whole time. Things are explained from scratch and any person who knows or understands English can learn selenium if he/she practices what's given in the book. Of-course, the person reading the book must have that interest or the need to learn selenium. To finalize, this is an extremely well written book with screenshots at every stage explaining how to go about with things. The book is a very good deal for the price it is being sold at, because what one can make after learning selenium is no-where close to the cost at what the book is sold.
Amazon Verified review Amazon
Mike Ludemann Jul 18, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Alle wichtigen Information und mehr sind vorhanden.
Amazon Verified review Amazon
buya Jun 28, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Ich habe gleich zwei Bücher gekauft für die Automatiserung mit dem Selenium Framework.Dieses Buch bietet einen guten Leitfaden.Im Vergleich zu dem anderen Buch welches ich mir auch über Amazon erworben habe, ist dieses Buch besser in der Praxis einsetzbar. Ich habe dieses Buch als Grundlage für das Selbstudium gekauft und bin recht zufrieden damit.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.