値の検証(valueIs, valueContains, …)

in English

要素のラベルではなく値(入力欄の内容など)を検証します。構成は テキストの検証と同じです。

対象は常に「直前に取得した要素」で、これらのコマンドにセレクタは渡しません。 まず select(または exist / tap など)で要素を取得し、そのうえで検証します。

select("#email").valueIs("test@example.com")              // 戻り値へチェーン
select("#email"); lastElement.valueIs("test@example.com") // lastElement を明示
select("#email"); valueIs("test@example.com")              // 暗黙(直前に取得した要素)

引数は、肯定形が (期待値, requireVisible:, strict:, waitSeconds:)、否定形が (期待値, strict:, waitSeconds:)、空判定が (strict:, waitSeconds:) です(valueMatchesDateFormat は strict: を取りません。下の表のとおり)。セレクタを渡す形はありません。暗黙形に渡せない期待値の制約はテキストの検証を参照してください。

関数

肯定 否定 判定
select(selector).valueIs(expected, requireVisible:, strict:, waitSeconds:) valueIsNot(expected, strict:, waitSeconds:) 完全一致
valueContains(expected, requireVisible:, strict:, waitSeconds:) valueContainsNot(expected, strict:, waitSeconds:) 部分一致
valueStartsWith(expected, requireVisible:, strict:, waitSeconds:) valueStartsWithNot(expected, strict:, waitSeconds:) 前方一致
valueEndsWith(expected, requireVisible:, strict:, waitSeconds:) valueEndsWithNot(expected, strict:, waitSeconds:) 後方一致
valueMatches(pattern, requireVisible:, strict:, waitSeconds:) valueMatchesNot(pattern, strict:, waitSeconds:) 正規表現(部分一致。全体一致は ^…$)
valueMatchesDateFormat(format, requireVisible:, waitSeconds:) — DateFormatter の書式文字列
valueIsNotEmpty(strict:, waitSeconds:) valueIsEmpty(strict:, waitSeconds:) 空でない / 空

比較規則はテキストの検証と同じ「見た目が完全に一致していれば同じ」です(strict: で無効化可能)。 詳細はテキストの検証を参照してください。

例

select("#email").valueIs("test@example.com")
select("#email").valueContains("@example.com")

注意点