Best Appium-espresso-driver code snippet using android.support.test.espresso.matcher.ViewMatchers.isFocusable
Assertions.kt
Source:Assertions.kt
...108 }109 /**110 * Checks if the view is focusable111 */112 fun isFocusable() {113 view.check(ViewAssertions.matches(114 ViewMatchers.isFocusable()))115 }116 /**117 * Checks if the view is not focusable118 */119 fun isNotFocusable() {120 view.check(ViewAssertions.matches(121 Matchers.not(ViewMatchers.isFocusable())))122 }123 /**124 * Checks if the view is clickable125 */126 fun isClickable() {127 view.check(ViewAssertions.matches(128 ViewMatchers.isClickable()))129 }130 /**131 * Checks if the view is not clickable132 */133 fun isNotClickable() {134 view.check(ViewAssertions.matches(135 Matchers.not(ViewMatchers.isClickable())))...
Builders.kt
Source:Builders.kt
...299 }300 /**301 * Matches root that is focusable302 */303 fun isFocusable() {304 rootMatchers.add(RootMatchers.isFocusable())305 }306 /**307 * Matches root that is not focusable308 */309 fun isNotFocusable() {310 rootMatchers.add(Matchers.not(RootMatchers.isFocusable()))311 }312 /**313 * Matches root that is platform popup314 */315 fun isPlatformPopup() {316 rootMatchers.add(RootMatchers.isPlatformPopup())317 }318 /**319 * Matches root that is not platform popup320 */321 fun isNotPlatformPopup() {322 rootMatchers.add(Matchers.not(RootMatchers.isPlatformPopup()))323 }324 /**...
Test_HomeActivity.kt
Source:Test_HomeActivity.kt
...9import android.support.test.espresso.contrib.RecyclerViewActions.scrollToPosition10import android.support.test.espresso.matcher.ViewMatchers.isClickable11import android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed12import android.support.test.espresso.matcher.ViewMatchers.isDisplayed13import android.support.test.espresso.matcher.ViewMatchers.isFocusable14import android.support.test.espresso.matcher.ViewMatchers.withId15import android.support.test.espresso.matcher.ViewMatchers.withText16import android.support.test.rule.ActivityTestRule17import android.support.test.runner.AndroidJUnit418import android.support.v7.widget.RecyclerView19import app.bola.kotlin.feature.HomeActivity20import app.bola.kotlin.feature.adapter.TeamAdapter21import app.bola.kotlin.feature.event.detail.MatchDetailPresenterImpl.Companion.ADDED_TO_FAVORITE22import app.bola.kotlin.feature.event.detail.MatchDetailPresenterImpl.Companion.REMOVED_FROM_FAVORITE23import org.junit.Before24import org.junit.FixMethodOrder25import org.junit.Rule26import org.junit.Test27import org.junit.runner.RunWith28import org.junit.runners.MethodSorters29import android.support.test.espresso.IdlingRegistry30@RunWith(AndroidJUnit4::class)31@FixMethodOrder(MethodSorters.NAME_ASCENDING)32class Test_HomeActivity {33 @Rule34 @JvmField35 var homeActivityRule = ActivityTestRule(HomeActivity::class.java)36 @Before37 fun setUp() {38 IdlingRegistry.getInstance().register(homeActivityRule.activity.getCountingIdlingResource())39 }40 @Test41 fun openDetailTeamTest() {42 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))43 onView(withId(R.id.main_container)).check(matches(isDisplayed()))44 onView(withId(R.id.team_spinner_id)).check(matches(isDisplayed()))45 onView(withId(R.id.team_spinner_id)).perform(click())46 onView(withText("Italian Serie A")).perform(click())47 onView(withId(R.id.base_recycle_view_id))48 .perform(scrollToPosition<TeamAdapter.TeamHolder>(5), click())49 try {50 clickFavoriteIcon()51 } catch (e: NoMatchingViewException) {52 }53 onView(withId(R.id.menu_favorite)).check(matches(isDisplayed()))54 pressBack()55 onView(withId(R.id.base_recycle_view_id)).check(matches(isDisplayed()))56 }57 @Test58 fun openDetailNextMatchTest() {59 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))60 onView(withId(R.id.menu_match_id)).check(matches(isCompletelyDisplayed())).perform(click())61 onView(withId(R.id.menu_match_id)).check(matches(isFocusable()))62 onView(withId(R.id.main_container)).check(matches(isDisplayed()))63 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0))64 .check(matches(isDisplayed()))65 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0)).perform(click())66 onView(withText("Italian Serie A")).perform(click())67 onView(TestHelper.withIndex(withId(R.id.rv_match),0)).perform(68 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(4, click()))69 onView(withId(R.id.iv_home_team_icon)).check(matches(isDisplayed()))70 onView(withId(R.id.iv_away_team_icon)).check(matches(isDisplayed()))71 pressBack()72 onView(TestHelper.withIndex(withId(R.id.rv_match),0)).check(matches(isDisplayed()))73 }74 @Test75 fun openDetailLastMatchTest() {76 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))77 onView(withId(R.id.menu_match_id)).check(matches(isCompletelyDisplayed())).perform(click())78 onView(withId(R.id.menu_match_id)).check(matches(isFocusable()))79 onView(withId(R.id.main_container)).check(matches(isDisplayed()))80 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0))81 .check(matches(isDisplayed()))82 onView(withText("Last")).perform(click())83 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 1)).perform(click())84 onView(withText("Italian Serie A")).perform(click())85 onView(TestHelper.withIndex(withId(R.id.rv_match),1))86 .perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(2, click()))87 onView(withId(R.id.iv_home_team_icon88 .and(R.id.iv_away_team_icon)))89 .check(matches(isDisplayed()))90 try {91 clickFavoriteIcon()92 } catch (e: NoMatchingViewException) {93 }94 onView(withId(R.id.menu_favorite)).check(matches(isDisplayed()))95 pressBack()96 onView(TestHelper.withIndex(withId(R.id.rv_match),1)).check(matches(isDisplayed()))97 }98 @Test99 fun addNextMatchToFavoriteTest() {100 addNextMatchToFavorite()101 }102 @Test103 fun addLastMatchToFavoriteTest() {104 addLastMatchToFavorite()105 }106 @Test107 fun unfavoriteTest() {108 addNextMatchToFavorite(4)109 addLastMatchToFavorite(1)110 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))111 onView(withId(R.id.menu_favorite_id))112 .check(matches(isCompletelyDisplayed()))113 .perform(click())114 .check(matches(isFocusable()))115 onView(withId(R.id.main_container)).check(matches(isDisplayed()))116 onView(TestHelper.withIndex(withId(R.id.rv_favorite),0))117 .perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))118 onView(withId(R.id.iv_home_team_icon119 .and(R.id.iv_away_team_icon)))120 .check(matches(isDisplayed()))121 clickUnfavoriteIcon()122 pressBack()123 onView(TestHelper.withIndex(withId(R.id.rv_favorite),0))124 .perform(actionOnItemAtPosition<RecyclerView.ViewHolder>(0, click()))125 onView(withId(R.id.iv_home_team_icon126 .and(R.id.iv_away_team_icon)))127 .check(matches(isDisplayed()))128 clickUnfavoriteIcon()129 pressBack()130 onView(TestHelper.withIndex(withId(R.id.rv_favorite),0)).check(matches(isDisplayed()))131 }132 private fun addNextMatchToFavorite(index: Int = 0){133 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))134 onView(withId(R.id.menu_match_id)).check(matches(isCompletelyDisplayed())).perform(click())135 onView(withId(R.id.menu_match_id)).check(matches(isFocusable()))136 onView(withId(R.id.main_container)).check(matches(isDisplayed()))137 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0))138 .check(matches(isDisplayed()))139 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0)).perform(click())140 onView(withText("Italian Serie A")).perform(click())141 onView(TestHelper.withIndex(withId(R.id.rv_match),0)).perform(142 RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(index, click()))143 onView(withId(R.id.iv_home_team_icon144 .and(R.id.iv_away_team_icon)))145 .check(matches(isDisplayed()))146 try {147 // already to add favorite148 clickFavoriteIcon()149 } catch (e: NoMatchingViewException) {150 }151 onView(withId(R.id.menu_favorite)).check(matches(isDisplayed()))152 pressBack()153 onView(TestHelper.withIndex(withId(R.id.rv_match),0)).check(matches(isDisplayed()))154 }155 private fun addLastMatchToFavorite(index: Int = 0) {156 onView(withId(R.id.bottom_navigation)).check(matches(isDisplayed()))157 onView(withId(R.id.menu_match_id)).check(matches(isCompletelyDisplayed())).perform(click())158 onView(withId(R.id.menu_match_id)).check(matches(isFocusable()))159 onView(withId(R.id.main_container)).check(matches(isDisplayed()))160 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 0))161 .check(matches(isDisplayed()))162 onView(withText("Last")).perform(click())163 onView(TestHelper.withIndex(withId(R.id.event_spinner_id), 1)).perform(click())164 onView(withText("Italian Serie A")).perform(click())165 onView(TestHelper.withIndex(withId(R.id.rv_match),1))166 .perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(index, click()))167 onView(withId(R.id.iv_home_team_icon168 .and(R.id.iv_away_team_icon)))169 .check(matches(isDisplayed()))170 try {171 clickFavoriteIcon()172 } catch (e: NoMatchingViewException) {...
SignInActivityTest.kt
Source:SignInActivityTest.kt
...25import android.support.test.espresso.matcher.ViewMatchers.isChecked26import android.support.test.espresso.matcher.ViewMatchers.isClickable27import android.support.test.espresso.matcher.ViewMatchers.isDisplayed28import android.support.test.espresso.matcher.ViewMatchers.isEnabled29import android.support.test.espresso.matcher.ViewMatchers.isFocusable30import android.support.test.espresso.matcher.ViewMatchers.withId31import android.support.test.espresso.matcher.ViewMatchers.withText32import android.support.test.filters.LargeTest33import android.support.test.rule.ActivityTestRule34import android.support.test.runner.AndroidJUnit435import android.view.View36import com.google.samples.apps.topeka.base.R37import com.google.samples.apps.topeka.TestLogin38import com.google.samples.apps.topeka.helper.login39import com.google.samples.apps.topeka.helper.logout40import com.google.samples.apps.topeka.model.Avatar41import com.google.samples.apps.topeka.model.TEST_AVATAR42import com.google.samples.apps.topeka.model.TEST_FIRST_NAME43import com.google.samples.apps.topeka.model.TEST_LAST_INITIAL44import org.hamcrest.Matcher45import org.hamcrest.Matchers.equalTo46import org.hamcrest.Matchers.isEmptyOrNullString47import org.hamcrest.Matchers.not48import org.junit.Before49import org.junit.Rule50import org.junit.Test51import org.junit.runner.RunWith52@RunWith(AndroidJUnit4::class)53@LargeTest54class SignInActivityTest {55 @Suppress("unused") // actually used by Espresso56 val rule57 @Rule get() = object :58 ActivityTestRule<SignInActivity>(SignInActivity::class.java) {59 override fun beforeActivityLaunched() {60 InstrumentationRegistry.getTargetContext().logout()61 login = TestLogin62 }63 override fun getActivityIntent(): Intent {64 val targetContext = InstrumentationRegistry.getTargetContext()65 return Intent(targetContext, SignInActivity::class.java).putExtra("EDIT", true)66 }67 }68 @Before fun clearPreferences() {69 InstrumentationRegistry.getTargetContext().logout()70 }71 @Test fun checkFab_initiallyNotDisplayed() {72 onView(withId(R.id.done)).check(matches(not(isDisplayed())))73 }74 @Test fun signIn_withoutFirstNameFailed() {75 inputData(null, TEST_LAST_INITIAL, TEST_AVATAR)76 onDoneView().check(matches(not(isDisplayed())))77 }78 @Test fun signIn_withoutLastInitialFailed() {79 inputData(TEST_FIRST_NAME, null, TEST_AVATAR)80 onDoneView().check(matches(not(isDisplayed())))81 }82 @Test fun signIn_withoutAvatarFailed() {83 inputData(TEST_FIRST_NAME, TEST_LAST_INITIAL, null)84 onDoneView().check(matches(not(isDisplayed())))85 }86 @Test fun signIn_withAllPlayerPreferencesSuccessfully() {87 inputData(TEST_FIRST_NAME, TEST_LAST_INITIAL, TEST_AVATAR)88 onDoneView().check(matches(isDisplayed()))89 }90 /* TODO Debug: Espresso does currently not continue after this test. Commenting to keep pace.91 @Test fun signIn_performSignIn() {92 inputData(TEST_FIRST_NAME, TEST_LAST_INITIAL, TEST_AVATAR)93 onDoneView().perform(click())94 assertThat(InstrumentationRegistry.getTargetContext().isLoggedIn(), `is`(true))95 }96 */97 private fun onDoneView() = onView(withId(R.id.done))98 @Test fun signIn_withLongLastName() {99 typeAndHideKeyboard(R.id.last_initial, TEST_FIRST_NAME)100 val expectedValue = TEST_FIRST_NAME[0].toString()101 onView(withId(R.id.last_initial)).check(matches(withText(expectedValue)))102 }103 private fun inputData(firstName: String?, lastInitial: String?, avatar: Avatar?) {104 if (firstName != null) typeAndHideKeyboard(R.id.first_name, firstName)105 if (lastInitial != null) typeAndHideKeyboard(R.id.last_initial, lastInitial)106 if (avatar != null) clickAvatar(avatar)107 }108 private fun typeAndHideKeyboard(targetViewId: Int, text: String) {109 onView(withId(targetViewId)).perform(typeText(text), closeSoftKeyboard())110 }111 private fun clickAvatar(avatar: Avatar) {112 onData(equalTo(avatar))113 .inAdapterView(withId(R.id.avatars))114 .perform(click())115 }116 @Test fun firstName_isInitiallyEmpty() = editTextIsEmpty(R.id.first_name)117 @Test fun lastInitial_isInitiallyEmpty() = editTextIsEmpty(R.id.last_initial)118 private fun editTextIsEmpty(id: Int) {119 onView(withId(id)).check(matches(withText(isEmptyOrNullString())))120 }121 @Test fun avatar_allDisplayed() = checkOnAvatar(isDisplayed())122 @Test fun avatar_isEnabled() = checkOnAvatar(isEnabled())123 @Test fun avatar_notFocusable() = checkOnAvatar(not(isFocusable()))124 @Test fun avatar_notClickable() = checkOnAvatar(not(isClickable()))125 @Test fun avatar_noneChecked() = checkOnAvatar(not(isChecked()))126 private fun checkOnAvatar(matcher: Matcher<View>) {127 (0 until Avatar.values().size).forEach {128 onData(equalTo(Avatar.values()[it]))129 .inAdapterView(withId(R.id.avatars))130 .check(matches(matcher))131 }132 }133}...
MainActivityTest.kt
Source:MainActivityTest.kt
...97 onView(withId(R.id.saveWord)).perform(click())98 addWordActivity.activity.finish()99 mainActivity.launchActivity(null)100 onData(withRowString(1, "sun"))101 .inAdapterView(allOf(withId(R.id.list_view_words), isFocusable()))102 .perform(click())103 onView(withText("ÐзÑÑено")).perform(click())104 onView(withText("ÐзÑÑеннÑе")).perform(click())105 onData(withRowString(1, "sun"))106 .inAdapterView(withId(R.id.pager))107 .inAdapterView(allOf(withId(R.id.list_view_words), isFocusable()))108 .check(matches(isDisplayed()))109 }110}...
ViewMatchersTest.kt
Source:ViewMatchersTest.kt
...25import android.support.test.espresso.matcher.ViewMatchers.isChecked26import android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA27import android.support.test.espresso.matcher.ViewMatchers.isDisplayed28import android.support.test.espresso.matcher.ViewMatchers.isEnabled29import android.support.test.espresso.matcher.ViewMatchers.isFocusable30import android.support.test.espresso.matcher.ViewMatchers.isSelected31import android.support.test.espresso.matcher.ViewMatchers.supportsInputMethods32import android.support.test.espresso.matcher.ViewMatchers.withChild33import android.support.test.espresso.matcher.ViewMatchers.withClassName34import android.support.test.espresso.matcher.ViewMatchers.withContentDescription35import android.support.test.espresso.matcher.ViewMatchers.withHint36import android.support.test.espresso.matcher.ViewMatchers.withId37import android.support.test.espresso.matcher.ViewMatchers.withParent38import android.support.test.espresso.matcher.ViewMatchers.withText39import org.hamcrest.CoreMatchers.allOf40import org.hamcrest.CoreMatchers.`is`41import org.hamcrest.CoreMatchers.not42/**43 * Lists all ViewMatchers. ViewMatchers here are without functional load.44 * This is done for demonstration purposes.45 */46@RunWith(AndroidJUnit4::class)47class ViewMatchersTest {48 @Test49 fun userProperties() {50 onView(withId(R.id.fab_add_task))51 onView(withText("All TO-DOs"))52 onView(withContentDescription(R.string.menu_filter))53 onView(hasContentDescription())54 onView(withHint(R.string.name_hint))55 }56 @Test57 fun uiProperties() {58 onView(isDisplayed())59 onView(isEnabled())60 onView(isChecked())61 onView(isSelected())62 }63 @Test64 fun objectMatcher() {65 onView(not<View>(isChecked()))66 onView(allOf<View>(withText("item 1"), isChecked()))67 }68 @Test69 fun hierarchy() {70 onView(withParent(withId(R.id.todo_item)))71 onView(withChild(withText("item 2")))72 onView(isDescendantOfA(withId(R.id.todo_item)))73 onView(hasDescendant(isChecked()))74 .check(matches(isDisplayed()))75 .check(matches(isFocusable()))76 onView(hasSibling(withContentDescription(R.string.menu_filter)))77 }78 @Test79 fun input() {80 onView(supportsInputMethods())81 onView(hasImeAction(EditorInfo.IME_ACTION_SEND))82 }83 @Test84 fun classMatchers() {85 onView(isAssignableFrom(CheckBox::class.java))86 onView(withClassName(`is`(FloatingActionButton::class.java.canonicalName)))87 }88 @Test89 fun rootMatchers() {90 onView(isFocusable())91 onView(withText(R.string.name_hint)).inRoot(isTouchable())92 onView(withText(R.string.name_hint)).inRoot(isDialog())93 onView(withText(R.string.name_hint)).inRoot(isPlatformPopup())94 }95 @Test96 fun preferenceMatchers() {97 onData(withSummaryText("3 days"))98 onData(withTitle(R.string.pref_title_send_notifications))99 onData(withKey("example_switch"))100 onView(isEnabled())101 }102 @Test103 fun layoutMatchers() {104 onView(hasEllipsizedText())...
NewsActivityTest.kt
Source:NewsActivityTest.kt
...47 }48 @Test49 fun activityNewsToolBar() {50 onView(withId(R.id.toolbar))51 .check(matches(allOf(isDisplayed(), not(isFocusable()), isEnabled())))52 onView(withId(R.id.toolbar))53 .check(matches(withToolbarTitle("News Application")))54 }55 @Test56 fun newsActivityNavBarDisplaysProperly() {57 onView(withId(R.id.bottomNavigationBar))58 .check(matches(allOf(isCompletelyDisplayed(),59 instanceOf(BottomNavigationView::class.java),60 not(isFocusable()), isEnabled())))61 }62 @Test63 fun newsFragment_shouldBeDisplayedProperly() {64 goToFragment(NewsFragment())65 onView(withId(R.id.newsSwipeRefresh))66 .check(matches(allOf(not(isClickable()), isDisplayed(), not(isFocusable()))))67 assert(R.id.progressBar != null)68 onView(withId(R.id.newsRecyclerView))69 .check(matches(allOf(isDisplayed(), not(isClickable()))))70 onView(withId(R.id.bottomNavigationBar))71 .check(matches(allOf(isCompletelyDisplayed(),72 instanceOf(BottomNavigationView::class.java),73 not(isFocusable()), isEnabled())))74 }75 @Test76 fun newsFragment_shouldBeLaunchedWhenClickedInTheBottomNavigation() {77 goToFragment(SportsFragment())78 onView(withId(R.id.news))79 .perform(click())80 onView(withId(R.id.newsSwipeRefresh))81 .check(matches(allOf(not(isClickable()), isDisplayed(), not(isFocusable()))))82 assertTrue(getActivity().supportFragmentManager.findFragmentById(R.id.fragmentContainer) is NewsFragment)83 }84 @Test85 fun sportsFragment_shouldBeLaunchedWhenClickedInTheBottomNavigation() {86 goToFragment(FoodFragment())87 onView(withId(R.id.sports))88 .perform(click())89 onView(withId(R.id.sportsSwipeRefresh))90 .check(matches(allOf(not(isClickable()), isDisplayed(), not(isFocusable()))))91 assertTrue(getActivity().supportFragmentManager.findFragmentById(R.id.fragmentContainer) is SportsFragment)92 }93 @Test94 fun foodFragment_shouldBeLaunchedWhenClickedInTheBottomNavigation() {95 goToFragment(SportsFragment())96 onView(withId(R.id.food))97 .perform(click())98 onView(withId(R.id.foodSwipeRefresh))99 .check(matches(allOf(not(isClickable()), isDisplayed(), not(isFocusable()))))100 assertTrue(getActivity().supportFragmentManager.findFragmentById(R.id.fragmentContainer) is FoodFragment)101 }102}...
SignUpActivityTest.kt
Source:SignUpActivityTest.kt
...32 Espresso.onView(ViewMatchers.withId(R.id.signUpBtn)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))33 }34 @Test35 fun loginButtonPressedTest() {36 Espresso.onView(ViewMatchers.withId(R.id.userNameET)).check(ViewAssertions.matches(ViewMatchers.isFocusable()))37 Espresso.onView(ViewMatchers.withId(R.id.userNameET)).perform(ViewActions.typeText(userName), ViewActions.closeSoftKeyboard())38 Espresso.onView(ViewMatchers.withId(R.id.emailET)).check(ViewAssertions.matches(ViewMatchers.isFocusable()))39 Espresso.onView(ViewMatchers.withId(R.id.emailET)).perform(ViewActions.typeText(email), ViewActions.closeSoftKeyboard())40 Espresso.onView(ViewMatchers.withId(R.id.passwordET)).perform(ViewActions.typeText(password), ViewActions.closeSoftKeyboard())41 Espresso.onView(ViewMatchers.withId(R.id.passwordET)).check(ViewAssertions.matches(isPasswordHidden()))42 Espresso.onView(ViewMatchers.withId(R.id.confirmPasswordEt)).perform(ViewActions.typeText(password), ViewActions.closeSoftKeyboard())43 Espresso.onView(ViewMatchers.withId(R.id.confirmPasswordEt)).check(ViewAssertions.matches(isPasswordHidden()))44 val confirmEt: EditText? = rule.activity.findViewById<EditText>(R.id.confirmPasswordEt)45 Espresso.onView(ViewMatchers.withId(R.id.passwordET)).check(ViewAssertions.matches(ViewMatchers.withText(confirmEt!!.text.toString())))46 Espresso.onView(ViewMatchers.withId(R.id.signUpBtn)).perform(ViewActions.click())47 }48 private fun isPasswordHidden(): Matcher<View> {49 return object : BoundedMatcher<View, EditText>(EditText::class.java) {50 override fun describeTo(description: Description) {51 description.appendText("Password is hidden")52 }...
isFocusable
Using AI Code Generation
1public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(2MainActivity.class);3public void testIsFocusable() {4onView(withId(R.id.editText))5.check(matches(isFocusable()));6}7public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(8MainActivity.class);9public void testIsClickable() {10onView(withId(R.id.button))11.check(matches(isClickable()));12}13public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(14MainActivity.class);15public void testIsDescendantOfA() {16onView(withId(R.id.button))17.check(matches(isDescendantOfA(withId(R.id.layout))));18}19public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(20MainActivity.class);21public void testIsDisplayed() {22onView(withId(R.id.textview))23.check(matches(isDisplayed()));24}25public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(26MainActivity.class);27public void testIsEnabled() {28onView(withId(R.id.button))29.check(matches(isEnabled()));30}31public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(32MainActivity.class);33public void testWithEffectiveVisibility() {34onView(withId(R.id.textview))35.check(matches(withEffectiveVisibility(Visibility.VISIBLE)));36}37public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(38MainActivity.class);39public void testWithSpinnerText() {40onView(withId(R.id.spinner))41.check(matches(withSpinnerText(containsString("one"))));42}43public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(44MainActivity.class);45public void testWithSpinnerText() {46onView(withId(R.id
isFocusable
Using AI Code Generation
1Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isChecked()));2Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isClickable()));3Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isSelected()));4Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isEnabled()));5Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isDisplayed()));6Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isNotDisplayed()));7Espresso.onView(ViewMatchers.withId(R.id.yourId)).perform(ViewActions.click()).check(ViewAssertions.matches(ViewMatchers.isInvisible()));
isFocusable
Using AI Code Generation
1ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isFocusable() ) );2ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isFocusableInTouchMode() ) );3ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isClickable() ) );4ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isLongClickable() ) );5ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isScrollable() ) );6ViewInteraction appCompatEditText = onView( allOf( withId( R.id.editText ), isRoot() ) );
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!