Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Selenium test script
@Test
public void addPersonSuccessfully() {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 10);
driver.get("http://localhost:8888/javaone");
By addButton = By.id("add");
wait.until(ExpectedConditions.presenceOfElementLocated(addButton));
driver.findElement(addButton).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("back")));
driver.findElement(By.id("name")).sendKeys("Daenerys Targaryen");
driver.findElement(By.name("address")).sendKeys("Dragonstone");
driver.findElement(By.cssSelector("input[ng-model='post.hobbies']")).sendKeys("Break Chains");
driver.findElement(By.cssSelector(".w3-btn.w3-teal")).click();
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("address")));
String dataOnPage = driver.getPageSource();
assertTrue(dataOnPage.contains("Daenerys Targaryen"));
assertTrue(dataOnPage.contains("Dragonstone"));
assertTrue(dataOnPage.contains("Break Chains"));
driver.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.