Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created February 11, 2012 21:53
Show Gist options
  • Save mauricioaniche/1804470 to your computer and use it in GitHub Desktop.
Save mauricioaniche/1804470 to your computer and use it in GitHub Desktop.
Exemplo simples com Seleium
package exercicio.selenium;
import static junit.framework.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ProdutoSystemTest {
private WebDriver browser;
private WebDriverBackedSelenium selenium;
@Before
public void setUp(){
browser = new FirefoxDriver();
selenium = new WebDriverBackedSelenium(browser, "");
}
@Test
public void deveAdicionarUmProduto() {
browser.get("http://localhost:8080/produtos");
browser.findElement(By.linkText("New Produto")).click();
browser.findElement(By.name("produto.nome")).sendKeys("CD da Ivete");
browser.findElement(By.name("produto.descricao")).sendKeys("Cantora baiana");
browser.findElement(By.name("produto.valor")).sendKeys("35.8");
browser.findElement(By.tagName("button")).click();
assertTrue(selenium.isTextPresent("CD da Ivete"));
assertTrue(selenium.isTextPresent("Cantora baiana"));
assertTrue(selenium.isTextPresent("35.8"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment