Version 3 (modified by luiz-fernando, 13 years ago) (diff) |
---|
10 Minutos com Maven, TestNG e Selenium
- Criar um novo projeto Maven no Eclipse:
- Editar pom.xml para adicionar as dependencias do projeto logo abaixo da tag <name> do projeto
<dependencies> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>5.14.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium</artifactId> <version>2.0b1</version> </dependency> </dependencies>
Automaticamente o maven baixará todos as dependências e colocará no path do projeto.
- Criar uma classe para testar a configuração:
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.annotations.Test; public class FirefoxDriverExample { @Test public void testIt() { // Create a new instance of the firefox driver WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.close(); } }
- Rodar o teste usando o TestNG.
Attachments
- maven1.png (54.0 KB) - added by luiz-fernando 13 years ago.
- maven2.png (47.6 KB) - added by luiz-fernando 13 years ago.
- maven3.png (61.7 KB) - added by luiz-fernando 13 years ago.
- maven4.png (168.7 KB) - added by luiz-fernando 13 years ago.
- maven5.png (112.1 KB) - added by luiz-fernando 13 years ago.