tap (Vision)

You can tap an element on the screen using these functions.

Functions

function description
tap(expression) Tap the first element that matches the expression. Scrolling occurs within withScroll function.
tap(x, y) Tap the coordinates (x, y).
tapWithScrollDown(expression) Tap the first element that matches the expression with scrolling down.
tapWithScrollUp(expression) Tap the first element that matches the expression with scrolling up.
tapWithScrollRight(expression) Tap the first element that matches the expression with scrolling right.
tapWithScrollLeft(expression) Tap the first element that matches the expression with scrolling left.
tapWithoutScroll(expression) Tap the first element that matches the expression without scrolling.
tapCenterOfScreen Tap the center of the screen.
tapCenterOf(expression) Tap the center of the element.
tapItemUnder(expression) Tap the element below of the element of expression.
tapItemOver(expression) Tap the element above of the element of expression.
tapItemRightOf(expression) Tap the element right of the element of expression.
tapItemLeftOf(expression) Tap the element left of the element of expression.
tapTextUnder(expression) Tap the text element below of the element of expression.
tapTextOver(expression) Tap the text element above of the element of expression.

Sample code

Getting samples

Tap1.kt

(src/test/kotlin/tutorial/basic/Tap1.kt)

    @Test
    fun tap() {

        scenario {
            case(1) {
                action {
                    it.tap("Network & internet")
                        .tap("Internet")
                    it.pressBack()
                        .pressBack()
                }
            }
            case(2) {
                action {
                    it.tapWithScrollDown("Display")
                        .tapWithScrollDown("Colors")
                    it.pressBack()
                        .pressBack()
                }
            }
        }
    }

    @Test
    fun tapByCoordinates() {

        scenario {
            case(1) {
                action {
                    val v = detect("Network & internet")
                    it.tap(x = v.bounds.centerX, y = v.bounds.centerY)
                }.expectation {
                    it.screenIs("[Network & internet Screen]")
                }
            }
        }
    }

Link