Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.obernardovieira.seleniumChrome;
- import java.util.logging.Logger;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- /**
- * Hello world!
- *
- */
- public class App
- {
- private static Logger LOG = Logger.getLogger(App.class.getSimpleName());
- public static void main( String[] args )
- {
- LOG.log( null, "Hello World!" );
- }
- @Test
- public void testGoogleSearch() {
- // Optional, if not specified, WebDriver will search your path for chromedriver.
- System.setProperty("webdriver.chrome.driver", "chromedriver");
- WebDriver driver = new ChromeDriver();
- driver.get("http://www.google.com/xhtml");
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- LOG.log( null, e.getMessage() );
- Runtime.getRuntime().exit(1);
- }
- // Let the user actually see something!
- WebElement searchBox = driver.findElement(By.name("q"));
- searchBox.sendKeys("ChromeDriver");
- searchBox.submit();
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- LOG.log( null, e.getMessage() );
- Runtime.getRuntime().exit(1);
- }
- // Let the user actually see something!
- driver.quit();
- }
- }
Add Comment
Please, Sign In to add comment