Book Image

Selenium WebDriver Practical Guide

By : Satya Avasarala
Book Image

Selenium WebDriver Practical Guide

By: Satya Avasarala

Overview of this book

<p>Selenium WebDriver is an open source web UI automation tool implemented through a browser-specific browser driver, which sends commands to a browser and retrieves results.<br /><br />Selenium WebDriver Practical Guide will guide you through the various APIs of WebDriver which should be used in automation tests, followed by a discussion of the various WebDriver implementations available. This guide will support you by offering you access to source code fi les, including the essential HTML&nbsp; fi les, that allow you to work with jQuery and other examples throughout the book. Finally, you will receive an in-depth explanation of how to deal with the latest features of WebDriver through step-by-step practical tutorials.</p>
Table of Contents (17 chapters)
Selenium WebDriver Practical Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating test cases for our WordPress blog


Here, we are using a WordPress blog with the following URL http://pageobjectpattern.wordpress.com/. Let us 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 in to the Admin portal of our WordPress blog and add a new blog post:

public class TestAddNewPost {
   public static void main(String... args) {
       WebDriver driver = new FirefoxDriver();
       // Login to Admin portal
       driver.get("http://pageobjectpattern.wordpress.com/wp-admin");
       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("[email protected]");
       pwd.sendKeys("webdriver123");
       submit.click();	
       // Go to AllPosts page
       driver.get("http://pageobjectpattern...