Test case 3 – counting the number of posts on our WordPress blog

The following test script will count all the posts currently available on our WordPress blog:

@Testpublic void testPostCount() {    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();    // Count the number of posts    driver.get("http://demo-blog.seleniumacademy.com/wp/wp-admin/edit.php");    WebElement postsContainer = driver.findElement(By.id("the-list"));    List postsList = postsContainer.findElements(By.            tagName("tr"));    Assert.assertEquals(postsList.size(), 1);}

The following is the sequence of ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.