Skip to content

Instantly share code, notes, and snippets.

@grimrose
Created May 12, 2013 04:39
Show Gist options
  • Save grimrose/5562439 to your computer and use it in GitHub Desktop.
Save grimrose/5562439 to your computer and use it in GitHub Desktop.
ChromeDriverの動作確認。参照先 -> https://code.google.com/p/chromedriver/wiki/GettingStarted
package chromedriver;
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;
public class ChromeDriverTest {
@Test
public void testGoogleSearch() throws InterruptedException {
String userDir = System.getProperty("user.dir");
// Optional, if not specified, WebDriver will search your path for chromedriver.
System.setProperty("webdriver.chrome.driver", userDir + "/driver/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/xhtml");
Thread.sleep(5000); // Let the user actually see something!
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("ChromeDriver");
searchBox.submit();
Thread.sleep(5000); // Let the user actually see something!
driver.quit();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment