Skip to content

Instantly share code, notes, and snippets.

@Se7soz
Created July 18, 2016 20:50
Show Gist options
  • Save Se7soz/44f4811c6e0ecf124b573cdc8103ec2c to your computer and use it in GitHub Desktop.
Save Se7soz/44f4811c6e0ecf124b573cdc8103ec2c to your computer and use it in GitHub Desktop.
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2;
import org.apache.logging.log4j.Level;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@Log4j2
public class Example {
@SneakyThrows
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "/home/se7so/Downloads/chromedriver"); // In real life setting it this way is a bad practice :)
log.log(Level.INFO, "Init Amazon web search page");
WebDriver driver = new ChromeDriver();
driver.get("http://amazon.de");
Thread.sleep(5000); // Let me see something
log.log(Level.INFO, "Lets search for something");
/* Let's search for books */
driver.findElement(By.id("twotabsearchtextbox")).sendKeys("Thinking in java");
driver.findElement(By.className("nav-input")).click();
Thread.sleep(5000); // Let me see what happens :)
log.log(Level.INFO, "Page title = {}", driver.getTitle());
driver.quit(); // Don't forget to quit the driver
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment