Writing your first test script for the Safari browser

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 of the SafariDriver class to launch and execute tests on the Safari browser.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.159.192