How to use withTagValue method of android.support.test.espresso.matcher.ViewMatchers class

Best Appium-espresso-driver code snippet using android.support.test.espresso.matcher.ViewMatchers.withTagValue

InstrumentationTest.kt

Source:InstrumentationTest.kt Github

copy

Full Screen

...41 IdlingRegistry.getInstance().unregister(idlingResource)42 }43 @Test44 fun testRecyclerViewLastMatch() {45 onView(allOf(withTagValue(`is`("Last_Match" as Any)), withId(listMatch))).check(matches(isDisplayed()))46 onView(47 allOf(48 withTagValue(`is`("Last_Match" as Any)),49 withId(listMatch)50 )51 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(14))52 onView(53 allOf(54 withTagValue(`is`("Last_Match" as Any)),55 withId(listMatch)56 )57 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(1))58 onView(59 allOf(60 withTagValue(`is`("Last_Match" as Any)),61 withId(listMatch)62 )63 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click()))64 }65 @Test66 fun testRecyclerViewNextMatch() {67 onView(withId(tabs)).check(matches(isDisplayed()))68 onView(withContentDescription("Next Match")).check(matches(isDisplayed()))69 onView(withContentDescription("Next Match")).perform(click())70 onView(allOf(withTagValue(`is`("Next_Match" as Any)), withId(listMatch))).check(matches(isDisplayed()))71 onView(72 allOf(73 withTagValue(`is`("Next_Match" as Any)),74 withId(listMatch)75 )76 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(3))77 onView(78 allOf(79 withTagValue(`is`("Next_Match" as Any)),80 withId(listMatch)81 )82 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(7))83 onView(84 allOf(85 withTagValue(`is`("Next_Match" as Any)),86 withId(listMatch)87 )88 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(7, click()))89 }90 @Test91 fun testRecyclerViewFavMatch() {92 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))93 onView(withId(R.id.favorites)).perform(click())94 onView(allOf(withTagValue(`is`("fav_match" as Any)), withId(listFav))).check(matches(isDisplayed()))95 onView(96 allOf(97 withTagValue(`is`("fav_match" as Any)),98 withId(listFav)99 )100 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(14))101 onView(102 allOf(103 withTagValue(`is`("fav_match" as Any)),104 withId(listFav)105 )106 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(1))107 onView(108 allOf(109 withTagValue(`is`("fav_match" as Any)),110 withId(listFav)111 )112 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click()))113 }114 @Test115 fun testRecyclerViewFavTeam() {116 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))117 onView(withId(R.id.favorites)).perform(click())118 onView(withId(tabsFavorite)).check(matches(isDisplayed()))119 onView(withContentDescription("Team")).check(matches(isDisplayed()))120 onView(withContentDescription("Team")).perform(click())121 onView(allOf(withTagValue(`is`("fav_team" as Any)), withId(listFav))).check(matches(isDisplayed()))122 onView(123 allOf(124 withTagValue(`is`("fav_team" as Any)),125 withId(listFav)126 )127 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(5))128 onView(129 allOf(130 withTagValue(`is`("fav_team" as Any)),131 withId(listFav)132 )133 ).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(0))134 onView(135 allOf(136 withTagValue(`is`("fav_team" as Any)),137 withId(listFav)138 )139 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))140 }141 @Test142 fun testRecyclerViewTeam() {143 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))144 onView(withId(R.id.tab_teams)).perform(click())145 onView(withId(listTeam)).check(matches(isDisplayed()))146 onView(withId(listTeam)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(7))147 onView(withId(listTeam)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(3))148 onView(withId(listTeam)).perform(149 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(150 3,151 click()152 )153 )154 pressBack()155 onView(ViewMatchers.withId(listTeam)).check(matches(isDisplayed()))156 onView(withId(spinner_teams)).check(matches(isDisplayed()))157 onView(withId(spinner_teams)).perform(click())158 onView(withText("Spanish La Liga")).perform(click())159 onView(withId(listTeam)).check(matches(isDisplayed()))160 onView(withId(listTeam)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(10))161 onView(withId(listTeam)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(1))162 onView(withId(listTeam)).perform(163 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(164 1,165 click()166 )167 )168 }169 @Test170 fun testFavoriteTeam() {171 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))172 onView(withId(R.id.tab_teams)).perform(click())173 onView(withId(listTeam)).check(matches(isDisplayed()))174 onView(withId(listTeam)).perform(175 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(176 3,177 click()178 )179 )180 onView(withId(add_to_favorite)).check(matches(isDisplayed()))181 onView(withId(add_to_favorite)).perform(click())182 onView(ViewMatchers.withText("Added to FavoriteTeams")).check(matches(isDisplayed()))183 onView(withId(add_to_favorite)).check(matches(isDisplayed()))184 onView(withId(add_to_favorite)).perform(click())185 onView(ViewMatchers.withText("Removed from FavoriteTeams")).check(matches(isDisplayed()))186 }187 @Test188 fun testFavoriteLastMatch() {189 onView(allOf(withTagValue(`is`("Last_Match" as Any)), withId(listMatch))).check(matches(isDisplayed()))190 onView(191 allOf(192 withTagValue(`is`("Last_Match" as Any)),193 withId(listMatch)194 )195 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(5, click()))196 onView(withId(add_to_favorite)).check(matches(isDisplayed()))197 onView(withId(add_to_favorite)).perform(click())198 onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed()))199 onView(withId(add_to_favorite)).check(matches(isDisplayed()))200 onView(withId(add_to_favorite)).perform(click())201 onView(ViewMatchers.withText("Removed from FavoriteMatches")).check(matches(isDisplayed()))202 }203 @Test204 fun testFavoriteNextMatch() {205 onView(withId(tabs)).check(matches(isDisplayed()))206 onView(withContentDescription("Next Match")).check(matches(isDisplayed()))207 onView(withContentDescription("Next Match")).perform(click())208 onView(allOf(withTagValue(`is`("Next_Match" as Any)), withId(listMatch))).check(matches(isDisplayed()))209 onView(210 allOf(211 withTagValue(`is`("Next_Match" as Any)),212 withId(listMatch)213 )214 ).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(5, click()))215 onView(withId(add_to_favorite)).check(matches(isDisplayed()))216 onView(withId(add_to_favorite)).perform(click())217 onView(ViewMatchers.withText("Added to FavoriteMatches")).check(matches(isDisplayed()))218 onView(withId(add_to_favorite)).check(matches(isDisplayed()))219 onView(withId(add_to_favorite)).perform(click())220 onView(ViewMatchers.withText("Removed from FavoriteMatches")).check(matches(isDisplayed()))221 }222 @Test223 fun testDetailViewTeam() {224 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))225 onView(withId(R.id.tab_teams)).perform(click())226 onView(withId(listTeam)).check(matches(isDisplayed()))227 onView(withId(listTeam)).perform(228 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(229 0,230 click()231 )232 )233 onView(withId(tabs_detail_team)).check(matches(isDisplayed()))234 onView(withContentDescription("Overview")).check(matches(isDisplayed()))235 onView(withContentDescription("Players")).check(matches(isDisplayed()))236 onView(withContentDescription("Players")).perform(click())237 onView(withId(listPlayer)).check(matches(isDisplayed()))238 onView(withId(listPlayer)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(10))239 onView(withId(listPlayer)).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(0))240 onView(withId(listPlayer)).perform(241 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(242 0,243 click()244 )245 )246 }247 @Test248 fun testAddMatchToCalendar() {249 onView(withId(tabs)).check(matches(isDisplayed()))250 onView(withContentDescription("Next Match")).check(matches(isDisplayed()))251 onView(withContentDescription("Next Match")).perform(click())252 onView(allOf(withTagValue(`is`("Next_Match" as Any)), withId(listMatch))).check(matches(isDisplayed()))253 onView(254 allOf(255 withTagValue(`is`("Next_Match" as Any)),256 withId(listMatch)257 )258 ).perform(259 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(260 0,261 MyImageButtonAction.clickChildViewWithId(R.id.btn_to_calendar)262 )263 )264 }265 @Test266 fun testSearchTeam() {267 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))268 onView(withId(R.id.tab_teams)).perform(click())269 onView(withId(button_search)).check(matches(isDisplayed()))...

Full Screen

Full Screen

Assertions.kt

Source:Assertions.kt Github

copy

Full Screen

...154 * @param tag Tag that view must have155 */156 fun hasTag(tag: String) {157 view.check(ViewAssertions.matches(158 ViewMatchers.withTagValue(Matchers.`is`(tag))))159 }160 /**161 * Checks if the view has at least one of the given tags162 *163 * @param tags Tags with at least one of them should be present in view164 */165 fun hasAnyTag(vararg tags: String) {166 val matchers = ArrayList<Matcher<Any>>(tags.size)167 tags.forEach {168 matchers.add(Matchers.`is`(it))169 }170 view.check(ViewAssertions.matches(171 ViewMatchers.withTagValue(Matchers.anyOf(matchers))))172 }173 /**174 * Checks if the matched view does not exists175 */176 fun doesNotExists() {177 view.check(ViewAssertions.doesNotExist())178 }179 /**180 * Checks if the view has given descendant181 *182 * @param function ViewBuilder that will result in descendant matcher183 *184 * @see ViewBuilder185 */...

Full Screen

Full Screen

PageExtensions.kt

Source:PageExtensions.kt Github

copy

Full Screen

...49fun BasePage.onViewWithResourceName(arg0: String): ViewInteraction = Espresso.onView(ViewMatchers.withResourceName(arg0))50fun BasePage.onViewWithResourceName(arg0: Matcher<String>): ViewInteraction = Espresso.onView(ViewMatchers.withResourceName(arg0))51fun BasePage.onViewWithTagKey(arg0: Int, arg1: Matcher<Any>): ViewInteraction = Espresso.onView(ViewMatchers.withTagKey(arg0, arg1))52fun BasePage.onViewWithTagKey(arg0: Int): ViewInteraction = Espresso.onView(ViewMatchers.withTagKey(arg0))53fun BasePage.onViewWithTagValue(arg0: Matcher<Any>): ViewInteraction = Espresso.onView(ViewMatchers.withTagValue(arg0))54fun BasePage.onViewWithHint(arg0: Int): ViewInteraction = Espresso.onView(ViewMatchers.withHint(arg0))55fun BasePage.onViewWithHint(arg0: Matcher<String>): ViewInteraction = Espresso.onView(ViewMatchers.withHint(arg0))56fun BasePage.onViewWithHint(arg0: String): ViewInteraction = Espresso.onView(ViewMatchers.withHint(arg0))57fun BasePage.onViewWithEffectiveVisibility(arg0: ViewMatchers.Visibility): ViewInteraction = Espresso.onView(ViewMatchers.withEffectiveVisibility(arg0))58fun BasePage.onViewWithChild(arg0: Matcher<View>): ViewInteraction = Espresso.onView(ViewMatchers.withChild(arg0))59fun BasePage.onViewWithSpinnerText(arg0: String): ViewInteraction = Espresso.onView(ViewMatchers.withSpinnerText(arg0))60fun BasePage.onViewWithSpinnerText(arg0: Matcher<String>): ViewInteraction = Espresso.onView(ViewMatchers.withSpinnerText(arg0))61fun BasePage.onViewWithSpinnerText(arg0: Int): ViewInteraction = Espresso.onView(ViewMatchers.withSpinnerText(arg0))62fun BasePage.onViewWithInputType(arg0: Int): ViewInteraction = Espresso.onView(ViewMatchers.withInputType(arg0))63fun BasePage.waitForViewWithParent(arg0: Matcher<View>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withParent(arg0))64fun BasePage.waitForViewWithText(arg0: String): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withText(arg0))65fun BasePage.waitForViewWithText(arg0: Matcher<String>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withText(arg0))66fun BasePage.waitForViewWithText(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withText(arg0))67fun BasePage.waitForViewWithId(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withId(arg0))68fun BasePage.waitForViewWithId(arg0: Matcher<Int>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withId(arg0))69fun BasePage.waitForViewWithClassName(arg0: Matcher<String>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withClassName(arg0))70fun BasePage.waitForViewWithContentDescription(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withContentDescription(arg0))71fun BasePage.waitForViewWithContentDescription(arg0: Matcher<out CharSequence>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withContentDescription(arg0))72fun BasePage.waitForViewWithContentDescription(arg0: String): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withContentDescription(arg0))73fun BasePage.waitForViewWithResourceName(arg0: String): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withResourceName(arg0))74fun BasePage.waitForViewWithResourceName(arg0: Matcher<String>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withResourceName(arg0))75fun BasePage.waitForViewWithTagKey(arg0: Int, arg1: Matcher<Any>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withTagKey(arg0, arg1))76fun BasePage.waitForViewWithTagKey(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withTagKey(arg0))77fun BasePage.waitForViewWithTagValue(arg0: Matcher<Any>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withTagValue(arg0))78fun BasePage.waitForViewWithHint(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withHint(arg0))79fun BasePage.waitForViewWithHint(arg0: Matcher<String>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withHint(arg0))80fun BasePage.waitForViewWithHint(arg0: String): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withHint(arg0))81fun BasePage.waitForViewWithEffectiveVisibility(arg0: ViewMatchers.Visibility): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withEffectiveVisibility(arg0))82fun BasePage.waitForViewWithChild(arg0: Matcher<View>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withChild(arg0))83fun BasePage.waitForViewWithSpinnerText(arg0: String): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withSpinnerText(arg0))84fun BasePage.waitForViewWithSpinnerText(arg0: Matcher<String>): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withSpinnerText(arg0))85fun BasePage.waitForViewWithSpinnerText(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withSpinnerText(arg0))86fun BasePage.waitForViewWithInputType(arg0: Int): ViewInteraction = WaitForViewMatcher.waitForView(ViewMatchers.withInputType(arg0))87fun BasePage.getStringFromResource(stringResource: Int): String{88 val targetContext = InstrumentationRegistry.getTargetContext()89 return targetContext.resources.getString(stringResource)90}91fun BasePage.callOnClick(matcher: Matcher<View>) = ViewCallOnClick.callOnClick(matcher)...

Full Screen

Full Screen

MainActivityInstrumentationTest.kt

Source:MainActivityInstrumentationTest.kt Github

copy

Full Screen

...77 Espresso.onView(withId(R.id.menu_getData)).perform(click())78 Espresso.onView(withId(R.id.flexboxImages))79 .perform(scrollTo())80 Espresso.onView(81 withTagValue(`is`("Image0" as Object))82 ).perform(click())83 Espresso.onView(withText("Save image")).check(ViewAssertions.matches(isDisplayed()))84 }85 @Test86 fun show_toast_after_save_file_correct(){87 Espresso.onView(allOf(withParent(withId(R.id.menu)), withClassName(endsWith("ImageView")), isDisplayed()))88 .perform(click())89 Espresso.onView(withId(R.id.menu_getData)).perform(click())90 Espresso.onView(withId(R.id.flexboxImages))91 .perform(scrollTo())92 Espresso.onView(93 withTagValue(`is`("Image0" as Object))94 ).perform(click())95 Espresso.onView(withId(android.R.id.button1)).perform(click())96 Espresso.onView(withText("Image saved!")).inRoot(withDecorView(not(`is`(activityRule.activity.window.decorView)))).97 check(ViewAssertions.matches(isDisplayed()))98 }99 @Test100 fun snackbar_should_be_displayed_after_login(){101 activityRule.activity.setIsLog(true)102 activityRule.activity.setUser("test test")103 Espresso.onView(allOf(withParent(withId(R.id.menu)), withClassName(endsWith("ImageView")), isDisplayed()))104 .perform(click())105 Espresso.onView(withId(R.id.menu_getData)).perform(click())106 Espresso.onView(withText("Logged as test test")).check(ViewAssertions.matches(isDisplayed()))107 }...

Full Screen

Full Screen

MainActivityTest.kt

Source:MainActivityTest.kt Github

copy

Full Screen

...22 var mActivityRule: ActivityTestRule<MainActivity> = object : ActivityTestRule<MainActivity>(MainActivity::class.java) {}23 @Test24 fun testMainActivity() {25 // check recycler view26 onView(withTagValue(`is`("rvPrevEventFrag")))27 .check(matches(isDisplayed()))28 Thread.sleep(5000)29 // click 1st card30 onView(withTagValue(`is`("rvPrevEventFrag"))).perform(31 actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())32 )33 Thread.sleep(3000)34 // check favorite button35 onView(withId(R.id.favorite_add))36 .check(matches(isDisplayed()))37 // click favorite button38 onView(withId(R.id.favorite_add))39 .perform(click())40 onView(withText("Added to favorite"))41 .check(matches(isDisplayed()))42 Thread.sleep(3000)43 // click back button44 pressBack()45 // check favorite navigation on bottom46 onView(withId(nav_favorite))47 .check(matches(isDisplayed()))48 // click favorite navigation49 onView(withId(nav_favorite))50 .perform(click())51 Thread.sleep(3000)52 // click 1st card53 onView(withTagValue(`is`("rvFavMatchesFrag"))).perform(54 actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())55 )56 Thread.sleep(3000)57 // check favorite button58 onView(withId(R.id.favorite_add))59 .check(matches(isDisplayed()))60 // click favorite button61 onView(withId(R.id.favorite_add))62 .perform(click())63 onView(withText("Removed from favorite"))64 .check(matches(isDisplayed()))65 Thread.sleep(3000)66 // click back button67 pressBack()68 // check next navigation69 onView(withId(nav_match))70 .check(matches(isDisplayed()))71 Thread.sleep(3000)72 // click next navigation73 onView(withId(nav_team))74 .perform(click())75 // check recycler view76 onView(withTagValue(`is`("rvTeamFrag")))77 .check(matches(isDisplayed()))78 Thread.sleep(5000)79 // click 1st card80 onView(withTagValue(`is`("rvTeamFrag"))).perform(81 actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())82 )83 onView(withId(R.id.main_layout_detai_team))84 .check(matches(isDisplayed()))85 Thread.sleep(3000)86 // check favorite button87 onView(withId(R.id.favorite_add))88 .check(matches(isDisplayed()))89 // click favorite button90 onView(withId(R.id.favorite_add))91 .perform(click())92 onView(withText("Added to favorite"))93 .check(matches(isDisplayed()))94 Thread.sleep(3000)95 // click back button96 pressBack()97 // check next navigation98 onView(withId(nav_match))99 .check(matches(isDisplayed()))100 Thread.sleep(3000)101 // check favorite navigation on bottom102 onView(withId(nav_favorite))103 .check(matches(isDisplayed()))104 // click favorite navigation105 onView(withId(nav_favorite))106 .perform(click())107 Thread.sleep(3000)108 val matcher = allOf(withText("TEAMS"),109 isDescendantOfA(withId(R.id.fav_tabs)))110 onView(matcher).check(matches(isDisplayed()))111 onView(matcher).perform(click())112 // click 1st card113 onView(withTagValue(`is`("rvFavTeamFrag"))).perform(114 actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click())115 )116 Thread.sleep(3000)117 // check favorite button118 onView(withId(R.id.favorite_add))119 .check(matches(isDisplayed()))120 // click favorite button121 onView(withId(R.id.favorite_add))122 .perform(click())123 onView(withText("Removed from favorite"))124 .check(matches(isDisplayed()))125 Thread.sleep(3000)126 // click back button127 pressBack()128 // lanjut test pencarian129 testTeamFragment()130 }131 @Test132 fun testTeamFragment() {133 // check next navigation134 onView(withId(nav_match))135 .check(matches(isDisplayed()))136 Thread.sleep(3000)137 // click next navigation138 onView(withId(nav_team))139 .perform(click())140 // check recycler view141 onView(withTagValue(`is`("rvTeamFrag")))142 .check(matches(isDisplayed()))143 onView(withId(R.id.search))144 .check(matches(isDisplayed()))145 onView(withId(R.id.search))146 .perform(click())147 Thread.sleep(3000)148 onView(withId(search_src_text))149 .check(matches(isDisplayed()))150 onView(withId(search_src_text))151 .perform(typeText("Ars"))152 Thread.sleep(1000)153 onView(withId(search_src_text))154 .perform(typeText("enal"))155 Thread.sleep(5000)156 // check recycler view157 onView(withTagValue(`is`("rvTeamFrag")))158 .perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))159 Thread.sleep(5000)160 pressBack()161 Thread.sleep(5000)162 }163}...

Full Screen

Full Screen

MainActivityOnboardingTest.kt

Source:MainActivityOnboardingTest.kt Github

copy

Full Screen

...102 assertIsNotVisibleInTab(R.id.lytFilteredEntities, tabClass)103 assertIsNotVisibleInTab(R.id.lytContextHelp, tabClass)104 }105 private fun assertIsVisibleInTab(viewId: Int, tabClass: Any) {106 onView(AllOf.allOf(withId(viewId), isDescendantOfA(ViewMatchers.withTagValue(`is`(tabClass)))))107 .check(matches(ViewMatchers.isDisplayed()))108 }109 private fun assertIsNotVisibleInTab(viewId: Int, tabClass: Any) {110 onView(AllOf.allOf(withId(viewId), isDescendantOfA(ViewMatchers.withTagValue(`is`(tabClass)))))111 .check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))112 }113 private fun assertDrawerTogglesIsVisible() {114 Assert.viewIsVisible(CoreMatchers.allOf(CoreMatchers.instanceOf(ImageButton::class.java), isDescendantOfA(withId(R.id.toolbar))))115 }116 private fun assertDrawerTogglesIsNotVisible() {117 Assert.viewIsNotVisible(CoreMatchers.allOf(CoreMatchers.instanceOf(ImageButton::class.java), isDescendantOfA(withId(R.id.toolbar))))118 }119 private fun assertIsVisible(viewId: Int) {120 onView(withId(viewId)).check(matches(isDisplayed()))121 }122 private fun assertIsNotVisible(viewId: Int) {123 onView(withId(viewId)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))124 }...

Full Screen

Full Screen

BaseRobot.kt

Source:BaseRobot.kt Github

copy

Full Screen

...34 fun componentInList(component: Matcher<View>, list: Matcher<View>, index: Int): ViewInteraction {35 return Espresso.onView(Matchers.allOf(component, ViewMatchers.isDescendantOfA(childAtPosition(list, index))))36 }37 fun componentInTagged(component: Matcher<View>, tagValue: Matcher<Any>): ViewInteraction {38 return Espresso.onView(Matchers.allOf(component, ViewMatchers.isDescendantOfA(ViewMatchers.withTagValue(tagValue))))39 }40 fun componentInTagged(component: Matcher<View>, key: Int, tagValue: Matcher<Any>): ViewInteraction {41 return Espresso.onView(Matchers.allOf(component, ViewMatchers.isDescendantOfA(ViewMatchers.withTagKey(key, tagValue))))42 }43 fun scrollTo(list: Matcher<View>, item: Matcher<View>) {44 Espresso.onView(list).perform(RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(item))45 }46 fun scrollTo(item: Matcher<View>) {47 scrollTo(ViewMatchers.withId(R.id.list), item)48 }49 fun scrollToPosition(list: Matcher<View>, position: Int) {50 Espresso.onView(list).perform(RecyclerViewActions.scrollToPosition<RecyclerView.ViewHolder>(position))51 }52 fun scrollToPosition(position: Int) {...

Full Screen

Full Screen

ImageWidgetTest.kt

Source:ImageWidgetTest.kt Github

copy

Full Screen

...7import androidx.test.espresso.assertion.ViewAssertions.matches8import androidx.test.espresso.intent.Intents.intending9import androidx.test.espresso.intent.matcher.IntentMatchers10import androidx.test.espresso.matcher.ViewMatchers.isDisplayed11import androidx.test.espresso.matcher.ViewMatchers.withTagValue12import org.hamcrest.Matchers.`is`13import org.hamcrest.Matchers.not14import org.junit.Rule15import org.junit.Test16import org.junit.rules.RuleChain17import org.odk.collect.android.BuildConfig18import org.odk.collect.android.R19import org.odk.collect.android.application.Collect20import org.odk.collect.android.storage.StoragePathProvider21import org.odk.collect.android.support.FileUtils22import org.odk.collect.android.support.rules.CollectTestRule23import org.odk.collect.android.support.rules.TestRuleChain24import org.odk.collect.androidtest.NestedScrollToAction.nestedScrollTo25import org.odk.collect.androidtest.RecordedIntentsRule26import java.io.File27class ImageWidgetTest {28 var rule = CollectTestRule()29 @get:Rule30 var copyFormChain: RuleChain = TestRuleChain.chain()31 .around(RecordedIntentsRule())32 .around(rule)33 @Test // https://github.com/getodk/collect/issues/481934 fun attachingGifsShouldBePossible() {35 intending(not(IntentMatchers.isInternal())).respondWith(36 Instrumentation.ActivityResult(37 Activity.RESULT_OK,38 gifFileResultIntent()39 )40 )41 rule.startAtMainMenu()42 .copyForm("image_widget.xml")43 .startBlankForm("image_widget")44 .clickOnString(R.string.choose_image)45 onView(withTagValue(`is`("ImageView")))46 .perform(nestedScrollTo())47 .check(matches(isDisplayed()))48 }49 private fun gifFileResultIntent(): Intent {50 val resultIntent = Intent()51 val file = File.createTempFile("file", "gif", File(StoragePathProvider().odkRootDirPath))52 FileUtils.copyFileFromAssets("media" + File.separator + "file.gif", file.path)53 resultIntent.data = FileProvider.getUriForFile(54 Collect.getInstance(),55 BuildConfig.APPLICATION_ID + ".provider",56 file57 )58 return resultIntent59 }...

Full Screen

Full Screen

withTagValue

Using AI Code Generation

copy

Full Screen

1import android.support.test.espresso.matcher.ViewMatchers.withTagValue2import org.hamcrest.Matchers.`is`3import org.hamcrest.Matchers.isA4val tagMatcher = withTagValue(`is`(isA(String::class.java)))5import android.support.test.espresso.matcher.ViewMatchers.withTagKey6import org.hamcrest.Matchers.`is`7import org.hamcrest.Matchers.isA8val tagMatcher = withTagKey(`is`(isA(String::class.java)))9import android.support.test.espresso.matcher.ViewMatchers.withText10val textMatcher = withText("test")11import android.support.test.espresso.matcher.ViewMatchers.withId12val idMatcher = withId(R.id.test)13import android.support.test.espresso.matcher.ViewMatchers.withParent14val parentMatcher = withParent(withId(R.id.test))15import android.support.test.espresso.matcher.ViewMatchers.withChild16val childMatcher = withChild(withId(R.id.test))17import android.support.test.espresso.matcher.ViewMatchers.withHint18val hintMatcher = withHint("test")19import android.support.test.espresso.matcher.ViewMatchers.withSpinnerText20val spinnerTextMatcher = withSpinnerText("test")21import android.support.test.espresso.matcher.ViewMatchers.withContentDescription22val contentDescriptionMatcher = withContentDescription("test")23import android.support.test.espresso.matcher.ViewMatchers.withContentDescription24val contentDescriptionMatcher = withContentDescription("test")25import android.support.test.espresso.matcher.ViewMatchers.withContentDescription26val contentDescriptionMatcher = withContentDescription("test")27import android.support.test.espresso.matcher.ViewMatchers.withContentDescription28val contentDescriptionMatcher = withContentDescription("test

Full Screen

Full Screen

withTagValue

Using AI Code Generation

copy

Full Screen

1public static Matcher<View> withTagValue(final Object tagValue) {2 return new TypeSafeMatcher<View>() {3 public void describeTo(Description description) {4 description.appendText("with tag value: ");5 description.appendValue(tagValue);6 }7 public boolean matchesSafely(View view) {8 return tagValue.equals(view.getTag());9 }10 };11}12public static Matcher<View> withTagValue(final Matcher<Object> tagValueMatcher) {13 return new TypeSafeMatcher<View>() {14 public void describeTo(Description description) {15 description.appendText("with tag value: ");16 tagValueMatcher.describeTo(description);17 }18 public boolean matchesSafely(View view) {19 return tagValueMatcher.matches(view.getTag());20 }21 };22}23public static Matcher<View> withTagKey(final int tagKey) {24 return new TypeSafeMatcher<View>() {25 public void describeTo(Description description) {26 description.appendText("with tag key: ");27 description.appendValue(tagKey);28 }29 public boolean matchesSafely(View view) {30 return view.getTag(tagKey) != null;31 }32 };33}34public static Matcher<View> withTagKey(final Matcher<Integer> tagKeyMatcher) {35 return new TypeSafeMatcher<View>() {36 public void describeTo(Description description) {37 description.appendText("with tag key: ");38 tagKeyMatcher.describeTo(description);39 }40 public boolean matchesSafely(View view) {41 for (int key :

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful