Giter Club home page Giter Club logo

Comments (6)

Unlimity avatar Unlimity commented on August 16, 2024

Thank you for the report!
We will investigate it in the coming days.

from kakao.

Unlimity avatar Unlimity commented on August 16, 2024

I found the issue in your sample.
The problem is that withIndex matcher is one-time use only. After it matches item, it is no longer usable.
You can make it dynamic though. Modify your InputScreen class in attached sample:

class InputScreen : Screen<InputScreen>() {
    fun inputLayout(lambda: KEditText.() -> Unit) = KEditText { withIndex(0, { withId(R.id.input_layout) }) }.invoke(lambda)
}

Hope this will help you.
This code will create a new instance of KEditText with withIndex matcher in it on every invocation.

from kakao.

michalkierasinski avatar michalkierasinski commented on August 16, 2024

Your solution does not work. I get the same error: No views in hierarchy found matching: (0th view with: (with id: com.agoda.sample:id/input_layout)).

Every invocation executes the same withIndex matcher.

from kakao.

Unlimity avatar Unlimity commented on August 16, 2024

Here's working test:

@RunWith(AndroidJUnit4::class)
class InputTest {
    @Rule
    @JvmField
    val rule = ActivityTestRule(InputActivity::class.java)

    val screen = InputScreen()

    @Test
    fun workingTest() {
        screen {
            inputLayout {
                replaceText("EXAMPLE")
                idle()
            }
        }
    }

    @Test
    fun noWorkingTest() {
        screen {
            inputLayout {
                replaceText("EXAMPLE")
            }

            idle()

            inputLayout {
                hasAnyText()
            }
        }
    }
}

You see, every action and assertion that you perform on a matcher, Espresso is starting over that matching process, because your layout can change since the last invocation. As I said earlier, withIndex is a single-use matcher. So for every action that you perform with that view, you need to provide fresh matcher.
You still can execute a batch of assertions or actions using corresponding assert() and act() functions, where you pass lambda which returns espresso's ViewAction and ViewAssertion.
Hope that helps.
If you have any idea how can we improve withIndex matcher to be reusable, your contributions are always welcome!

from kakao.

michalkierasinski avatar michalkierasinski commented on August 16, 2024

Ok, now it is working. Thanks for the help.
I will try to find a solution for withIndex.

from kakao.

Unlimity avatar Unlimity commented on August 16, 2024

You're welcome. Closing this issue then.

from kakao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.