Skip to content

Instantly share code, notes, and snippets.

@goofmint
Created January 19, 2018 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goofmint/b2130f663b93d9dd011355879f928512 to your computer and use it in GitHub Desktop.
Save goofmint/b2130f663b93d9dd011355879f928512 to your computer and use it in GitHub Desktop.
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import com.htmlhifive.pitalium.core.PtlTestBase;
public class SampleTest extends PtlTestBase {
@Test
public void test() throws Exception {
// 1. hifiveサイトのトップページを開きます
driver.get("http://www.htmlhifive.com/conts/web/view/Main/?language=ja");
// 2. hifiveサイトのトップページのスクリーンショットを撮影します
assertionView.assertView("OpenhifiveTopPage");
// 3. "#about" に表示されているタイトルが正しいことをチェックします
WebElement about = driver.findElementById("about");
WebElement title = about.findElement(By.tagName("h2"));
assertThat(title.getText(), is("hifiveとは"));
}
@Test
public void testClickAndCapture() throws Exception {
// 1. hifiveサイトのトップページを開きます
driver.get("http://www.htmlhifive.com/conts/web/view/Main/?language=ja");
// 2. hifiveサイトのトップページのスクリーンショットを撮影します。
assertionView.assertView("OpenhifiveTopPage");
// 3. "過去のお知らせ一覧" ボタン要素を取得してクリックします。
WebElement infoHistoryButton = driver.findElementByCssSelector("#news a.btn");
infoHistoryButton.click();
// 4. ページ遷移後のスクリーンショットを撮影します。
assertionView.assertView("OpenNewsListPage");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment