detect (Vision)
これらの関数を使用してテキスト要素を検出することができます。
セレクター式 を引数に取ります。
関数はVisionElementオブジェクトを返します。
関数
| 関数 | 説明 |
|---|---|
| detect | 現在の画面内でセレクターにマッチする最初の要素を取得します。withScroll関数内で使用するとスクロールが発生します。 |
| detectLast | 現在の画面内でセレクターにマッチする最後の要素を取得します。withScroll関数内で使用するとスクロールが発生します。 |
| detectWithScrollDown | セレクターにマッチする最初の要素を取得します。(下方向スクロールあり) |
| detectWithScrollUp | セレクターにマッチする最初の要素を取得します。(上方向スクロールあり) |
| detectWithScrollRight | セレクターにマッチする最初の要素を取得します。(右方向スクロールあり) |
| detectWithScrollLeft | セレクターにマッチする最初の要素を取得します。(左方向スクロールあり) |
| detectWithoutScroll | セレクターにマッチする最初の要素を取得します。(スクロールなし) |
主要な引数
| 引数 | 説明 |
|---|---|
| expression | セレクター式 |
| language | AI-OCRの言語 |
| last | true: 最後の要素を取得します false: 最初の要素を取得します(デフォルト) |
| looseMatch | true: テキスト検出にルースマッチングを適用します false: ルースマッチングを適用しません(デフォルト) |
| autoImageFilter | true: 画像フィルターを自動適用してAI-OCRの認識精度を向上させます false: 画像フィルターを適用しません |
サンプルコード
Detect1.kt
(kotlin/tutorial/basic/Detect1.kt)
@Test
@Order(10)
fun detect() {
scenario {
case(1) {
action {
it.detect("設定を検索")
output(it)
it.detect("ネットワークとインターネット")
output(it)
}
}
}
}
@Test
@Order(20)
fun detectWithScrollDown_detectWithScrollUp() {
scenario {
case(1) {
action {
it.detectWithScrollDown("ヒントとサポート")
output(it)
}
}
}
}
@Test
@Order(30)
fun detect_patterns() {
scenario {
case(1) {
action {
it.detect("設定を検索")
output(it)
it.detect("*定を検*")
output(it)
it.detect("設定を*")
output(it)
it.detect("*を検索")
output(it)
it.detect("設定を*&&*を検索")
output(it)
}
}
}
}