Last active
June 14, 2016 07:18
-
-
Save ksakae1216/21ef6d1da3121f564acd339ec2aed00e to your computer and use it in GitHub Desktop.
This file contains 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
package webDriverSample; | |
import static org.junit.Assert.*; | |
import org.junit.After; | |
import org.junit.Before; | |
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 SeleniumWebDriverJunit { | |
private WebDriver driver; | |
@Before | |
public void beforeTest() { | |
System.setProperty("webdriver.chrome.driver", "driver/chromedriver"); | |
driver = new ChromeDriver(); | |
} | |
@After | |
public void afterTest() throws InterruptedException { | |
Thread.sleep(2000); | |
driver.quit(); | |
} | |
// google検索画面を開いて、検索する | |
@Test | |
public void searchTest() { | |
driver.get("https://www.google.co.jp/"); | |
WebElement element = driver.findElement(By.name("q")); | |
element.sendKeys("フリーランス チャレンジ selenium"); //検索文字をセット; | |
element.submit(); | |
assertEquals("Google", driver.getTitle()); //ページタイトルが想定通りか、チェック | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment