Comments (6)
Thank you for the report!
We will investigate it in the coming days.
from kakao.
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.
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.
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.
Ok, now it is working. Thanks for the help.
I will try to find a solution for withIndex
.
from kakao.
You're welcome. Closing this issue then.
from kakao.
Related Issues (20)
- NestedScrollView not supported by ScrollTo ViewAction HOT 1
- [Question] how to do action on compound customview child ? HOT 1
- ActionBar - Support homeAsUpIndicator HOT 10
- Add TextInputLayoutAssertions.hasHint(@StringRes resId: Int) HOT 6
- isDescendantOfA{ } and withMatcher(isDescendantOfA( )) not the same? HOT 2
- Misleading readme? HOT 2
- AmbiguousViewMatcherException with recycler views HOT 2
- Lot of UI Test fail after upgrading to 2.3.3 HOT 7
- Issue with hasDrawable when ImageView is using scaleType HOT 5
- RecyclerView inside RecyclerView items, cannot get it to be recognized
- Does hasDrawable method work for AppCompatImageView? HOT 2
- Upgrade Espresso version to 3.3.0 HOT 4
- Optional View Elements HOT 2
- Android Compose support HOT 2
- Migrate away from JCenter HOT 8
- DrawableMatcher fails in 2.3.4 HOT 5
- Scroll to RecyclerView element that part can be off screen HOT 1
- Impossible to check if KAlertDialog isn't on the screen HOT 3
- Checking MenuItems
- DrawableMatcher getDrawable from resource
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kakao.