Selenium WebDriver 3 Practical Guide
eBook - ePub

Selenium WebDriver 3 Practical Guide

End-to-end automation testing for web and mobile browsers with Selenium WebDriver, 2nd Edition

Unmesh Gundecha, Satya Avasarala

  1. 280 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Selenium WebDriver 3 Practical Guide

End-to-end automation testing for web and mobile browsers with Selenium WebDriver, 2nd Edition

Unmesh Gundecha, Satya Avasarala

Book details
Book preview
Table of contents
Citations

About This Book

Real-world examples of cross-browser, mobile, and data-driven testing with all the latest features of Selenium WebDriver 3

Key Features

  • Unlock the full potential of Selenium to test your web applications
  • Use Selenium Grid for faster, parallel running, and cross-browser testing
  • Test iOS and Android Apps with Appium

Book Description

Selenium WebDriver is an open source automation tool implemented through a browser-specific driver, which sends commands to a browser and retrieves results. The latest version of Selenium 3 brings with it a lot of new features that change the way you use and setup Selenium WebDriver. This book covers all those features along with the source code, including a demo website that allows you to work with an HMTL5 application and other examples throughout the book.

Selenium WebDriver 3 Practical Guide will walk you through the various APIs of Selenium WebDriver, which are used in automation tests, followed by a discussion of the various WebDriver implementations available. You will learn to strategize and handle rich web UI using advanced WebDriver API along with real-time challenges faced in WebDriver and solutions to handle them. You will discover different types and domains of testing such as cross-browser testing, load testing, and mobile testing with Selenium. Finally, you will also be introduced to data-driven testing using TestNG to create your own automation framework.

By the end of this book, you will be able to select any web application and automate it the way you want.

What you will learn

  • Understand what Selenium 3 is and how is has been improved than its predecessor
  • Use different mobile and desktop browser platforms with Selenium 3
  • Perform advanced actions, such as drag-and-drop and action builders on web page
  • Learn to use Java 8 API and Selenium 3 together
  • Explore remote WebDriver and discover how to use it
  • Perform cross browser and distributed testing with Selenium Grid
  • Use Actions API for performing various keyboard and mouse actions

Who this book is for

Selenium WebDriver 3 Practical Guide is for software quality assurance/testing professionals, software project managers, or software developers interested in using Selenium for testing their applications. Prior programming experience in Java is necessary.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Selenium WebDriver 3 Practical Guide an online PDF/ePUB?
Yes, you can access Selenium WebDriver 3 Practical Guide by Unmesh Gundecha, Satya Avasarala in PDF and/or ePUB format, as well as other popular books in Ciencia de la computación & Programación en Java. We have over one million books available in our catalogue for you to explore.

Information

Year
2018
ISBN
9781788996013

The PageObject Pattern

So far, we have seen various APIs of WebDriver and learned how to use them to accomplish various actions on the web application we have been testing. We created a number of tests that use these APIs and are executed continuously to validate the application. However, as your test suite grows, the complexity of your tests and code will also grow. This becomes a challenge, with respect to the maintainability of your scripts and code. You will need to design a maintainable, modular, and reusable test code that will scale as you add more test coverage. In this chapter, we will explore the PageObject pattern to build a highly maintainable test suite. We will cover the following topics:
  • What is the PageObject pattern design?
  • Good practices for designing PageObjects
  • Extensions to the PageObject pattern
  • An end-to-end example
A decently written test script would work just fine, as long as the target web application doesn't change. But once one or more pages in your web application change, as a test-script developer, you shouldn't be in a position where you have to refactor your test scripts in a hundred different places. Let's understand this statement better with the help of an example. We will try to go through this chapter by working on a WordPress blog. Before we start, I would like you to create a WordPress blog (http://wordpress.com/about) or use one of your existing ones.

Creating test cases for our WordPress blog

Here, we are using a WordPress blog: http://demo-blog.seleniumacademy.com/wp/. Let's create three test cases for it before we start talking about the PageObject pattern.

Test case 1 – adding a new post to our WordPress blog

The following test script will log into the Admin portal of our WordPress blog and add a new blog post:
@Test
public void testAddNewPost() {
WebElement email = driver.findElement(By.id("user_login"));
WebElement pwd = driver.findElement(By.id("user_pass"));
WebElement submit = driver.findElement(By.id("wp-submit"));
email.sendKeys("admin");
pwd.sendKeys("$$SUU3$$N#");
submit.click();

// Go to AllPosts page
driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin/edit.php");

// Add New Post
WebElement addNewPost = driver.findElement(By.linkText("Add New"));
addNewPost.click();

// Add New Post's Content
WebElement title = driver.findElement(By.id("title"));
title.click();
title.sendKeys("My First Post");

driver.switchTo().frame("content_ifr");
WebElement postBody = driver.findElement(By.id("tinymce"));
postBody.sendKeys("This is description");
driver.switchTo().defaultContent();

// Publish the Post
WebElement publish = driver.findElement(By.id("publish"));
publish.click();
}
The following is the sequence of steps that the preceding code performs:
  1. Log into the WordPress Admin portal.
  2. Go to the All Posts page.
  3. Click on the Add New post button.
  4. Add a new post by providing the title and description.
  5. Publish the post.

Test case 2 – deleting a post from our WordPress blog

The following test script will log into our WordPress blog and delete an existing post:
@Test
public void testDeleteAPost() {
WebElement email = driver.findElement(By.id("user_login"));
WebElement pwd = driver.findElement(By.id("user_pass"));
WebElement submit = driver.findElement(By.id("wp-submit"));
email.sendKeys("admin");
pwd.sendKeys("$$SUU3$$N#");
submit.click();

// Go to AllPosts page
driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin/edit.php");

// Click on the post to be deleted
WebElement post = driver.findElement(By.linkText("My First Post"));
post.click();

// Delete Post
WebElement publish = driver.findElement(By.linkText("Move to Trash"));
publish.click();
}
The following is the sequence of steps that the preceding test script follows to delete a post:
  1. Log into the WordPress Admin portal.
  2. Go to the All Posts page.
  3. Click...

Table of contents

Citation styles for Selenium WebDriver 3 Practical Guide

APA 6 Citation

Gundecha, U., & Avasarala, S. (2018). Selenium WebDriver 3 Practical Guide (2nd ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/778161/selenium-webdriver-3-practical-guide-endtoend-automation-testing-for-web-and-mobile-browsers-with-selenium-webdriver-2nd-edition-pdf (Original work published 2018)

Chicago Citation

Gundecha, Unmesh, and Satya Avasarala. (2018) 2018. Selenium WebDriver 3 Practical Guide. 2nd ed. Packt Publishing. https://www.perlego.com/book/778161/selenium-webdriver-3-practical-guide-endtoend-automation-testing-for-web-and-mobile-browsers-with-selenium-webdriver-2nd-edition-pdf.

Harvard Citation

Gundecha, U. and Avasarala, S. (2018) Selenium WebDriver 3 Practical Guide. 2nd edn. Packt Publishing. Available at: https://www.perlego.com/book/778161/selenium-webdriver-3-practical-guide-endtoend-automation-testing-for-web-and-mobile-browsers-with-selenium-webdriver-2nd-edition-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Gundecha, Unmesh, and Satya Avasarala. Selenium WebDriver 3 Practical Guide. 2nd ed. Packt Publishing, 2018. Web. 14 Oct. 2022.