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 ...