Created
February 1, 2012 13:00
-
-
Save froop/1716888 to your computer and use it in GitHub Desktop.
[Java][WebDriver] ファイルアップロードテスト例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxDriver; | |
public class FileUploadTest { | |
private static WebDriver driver; | |
@BeforeClass | |
public static void setUpBeforeClass() throws Exception { | |
driver = new FirefoxDriver(); | |
} | |
@AfterClass | |
public static void tearDownAfterClass() throws Exception { | |
// driver.quit(); | |
} | |
@Test | |
public void testGoogleImageSearch() throws Exception { | |
driver.get("http://www.google.co.jp/imghp"); | |
driver.findElement(By.id("qbi")).click(); | |
driver.findElement(By.id("qbug")).findElement(By.tagName("a")).click(); | |
driver.findElement(By.id("qbfile")).sendKeys("C:\\work\\test.png"); | |
assertEquals("一致した画像を含むページ", | |
driver.findElement(By.xpath("//ol[@id='rso']/li/h3")).getText()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment