How to write your first test case

We'll look at how to write your first test case in this blog.

Below is a sample test case that we'll automate as part of this course.

So let's start.

  1. Open eclipse and create maven project as shown in previous tutorial.
  2. Use webdriver manager to open browser as shown in webdriver manager tutorial. this will complete test step 1 from TC01.
  3. Fow test step 2, from TC01, add below code snippet.

    driver.get("https://freeguideex.blogspot.com/");

  4. For TC02, we need to search selenium keyword in search box.

    driver.findElement(By.className("search-expand-text")).click();

    driver.findElement(By.name("q")).sendKeys("Selenium");

    driver.findElement(By.xpath("/svg[@class=\"svg-icon-24 touch-icon search-icon\"]
    /use[@xmlns:xlink=\"http://www.w3.org/1999/xlink\"]@xmlns:xlink"
    )).click();

  5. Now that we are on selenium article page, we'll need to scroll down a little.

    Actions at = new Actions(driver);

    at.sendKeys(Keys.PAGE_DOWN).build().perform();

  6. Now click on 3rd article

    driver.findElement(By.linkText("Introduction to Selenium")).click();

Done, this way you'll need to automate test cases.

Comments

Popular Posts