This is as straight forward. The following is the test script using the Safari Driver:
public class SearchTest { WebDriver driver; @BeforeMethod public void setup() { driver = new SafariDriver(); driver.get("http://demo-store.seleniumacademy.com/"); } @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'"); } @AfterMethod public void tearDown() { driver.quit(); }}
In the preceding code, we created an instance ...