Comments (4)
I resolved by create custom action like
class NestedScrollActions(private val original: ScrollToAction = ScrollToAction()) : ViewAction by original {
override fun getConstraints(): Matcher<View> = CoreMatchers.anyOf(
CoreMatchers.allOf(
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
isDescendantOfA(isAssignableFrom(NestedScrollView::class.java)))
, original.constraints
)
}
and use act
for perform it
button {
act {
NestedScrollActions()
}
click()
}
Anyway, I'm not sure this is good enough solution for make a PR.
from kakao.
Maybe the problem was with how you matched your button. It is possible that you need to match your button as a child of nested scroll view in your screen class. Cheers!
from kakao.
Hello there! Can you provide more info? Stacktrace at least?
And by the way, your button in provided example is named snackbarButton
. Are you actually calling snackbar? If so, snackbar is added to your root view and there is no need to scroll to it. Also please provide your screen class, maybe matching is wrong.
from kakao.
Hi, sorry to have confused you.
I try to scroll to button, which inside NestedScrollView
and click it
and lastly assert SnackBar
should display
Updated code as below
Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Space
android:layout_width="wrap_content"
android:layout_height="600dp"
android:textColor="@color/background_color" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BUTTON" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Screen
val content: KView = KView { withId(R.id.content) }
val button: KButton = KButton { withId(R.id.button) }
val snackbar: KSnackbar = KSnackbar()
Test
@Test
fun testContentScreen() {
screen {
content {
isVisible()
}
button {
scrollTo()
click()
}
snackbar {
isDisplayed()
}
}
}
An exception
android.support.test.espresso.PerformException: Error performing 'scroll to' on view '(with id: com.agoda.sample:id/button)'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:84)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:81)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:167)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:110)
at com.agoda.kakao.BaseActions$DefaultImpls.scrollTo(Actions.kt:148)
at com.agoda.kakao.KBaseView.scrollTo(Views.kt:30)
at com.agoda.sample.NestedScrollViewActivityTest$testContentScreen$1$2.invoke(NestedScrollViewActivityTest.kt:26)
at com.agoda.sample.NestedScrollViewActivityTest$testContentScreen$1$2.invoke(NestedScrollViewActivityTest.kt:11)
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.