Skip to content

Instantly share code, notes, and snippets.

@michelpf
Created July 2, 2017 00:13
Show Gist options
  • Save michelpf/26edc4b4bd34ce2367f9d847a7806c09 to your computer and use it in GitHub Desktop.
Save michelpf/26edc4b4bd34ce2367f9d847a7806c09 to your computer and use it in GitHub Desktop.
Exemplo de Java com Selenium realizando interações
public class Main {
public static void main(String[] args) {
File file = new File("drivers/IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
driver.get("http://michelpf.com/exemplo-de-calculadora-em-javascript/");
driver.findElement(By.xpath("//input[@id='1']")).click();
driver.findElement(By.xpath("//input[@id='plus']")).click();
driver.findElement(By.xpath("//input[@id='6']")).click();
driver.findElement(By.xpath("//input[@id='equals']")).click();
String result = driver.findElement(By.xpath("//input[@id='Resultbox']")).getAttribute("value");
System.out.println("Resultado 1+6 = " + result);
driver.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment