Parameterizing Tests using suite parameters

In Chapter 1, Introducing WebDriver and WebElements, we created a search test that performs a simple search on the application under test. This test searches for a given product and validates the title. We used a hardcoded value, phones, for the search, as shown in the following code snippet:

 @Test
 public void searchProduct() {

        // find search box and enter search string
        WebElement searchBox = driver.findElement(By.name("q"));

        searchBox.sendKeys("Phones");

        WebElement searchButton =
                driver.findElement(By.className("search-button"));

        searchButton.click();

        assertThat(driver.getTitle())
                .isEqualTo("Search results for: 'Phones'");
    }

Instead of using hardcoded values, we can parameterize these values ...

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.