テスト

Selenide

Seleniumのラッパーライブラリ。 Seleniumをより画面のテストをしやすくしたものだと思ってよい。 Javaを使用していて、jQueryの書き方を知っているのであれば導入の敷居は非常に低い。 とあるID属性が表示されるまで自動でsleepして待ってくれるのも良い。 また、テストがこけた時に自動で スクリーンショット、およびHTMLを保存してくれる。 公式のクイックスタートを読めば何ができるのか大体分かる。 http://selenide.org/quick-start.html Seleniumとの比較も公式ドキュメントとしてまとまっている。 http://selenide.org/documentation/selenide-vs-selenium.html サンプル ログイン 指定した画面まで遷移 検索 を行っている。 import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities; import static com.codeborne.selenide.CollectionCondition.size; import static com.codeborne.selenide.Selectors.byText; import static com.codeborne.selenide.Selenide.*; import static com.codeborne.selenide.Condition.*; import static com.codeborne.selenide.Condition.text; import static com.codeborne.selenide.Selenide.open; public class Test { @org.junit.Test public void test() { String baseUrl = "http://..."; // Chrome Driverのパス System.setProperty("webdriver.chrome.driver", "~/chromedriver/chromedriver"); System.setProperty("selenide.browser", "Chrome"); clearBrowserCookies(); // シークレットモードで起動 ChromeOptions options = new ChromeOptions(); options. »