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

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

PageExtensions.kt

Source:PageExtensions.kt Github

copy

Full Screen

...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)92fun BasePage.scrollTo(viewId: Int) = BaristaScrollInteractions.safelyScrollTo(viewId)93fun BasePage.scrollTo(text: String) = BaristaScrollInteractions.safelyScrollTo(text)94fun BasePage.waitScrollClick(viewId: Int) {95 val view = waitForViewWithId(viewId)96 scrollTo(viewId)97 view.click()98}99fun BasePage.pause(milli: Long = 100) = BaristaSleepInteractions.sleep(milli)...

Full Screen

Full Screen

CreateVehicleActivityRobot.kt

Source:CreateVehicleActivityRobot.kt Github

copy

Full Screen

...4import android.support.test.espresso.Espresso.onView5import android.support.test.espresso.action.ViewActions6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.matcher.ViewMatchers.withId8import android.support.test.espresso.matcher.ViewMatchers.withSpinnerText9import android.support.test.rule.ActivityTestRule10import br.com.concretesolutions.kappuccino.actions.ClickActions.click11import br.com.concretesolutions.kappuccino.actions.TextActions.typeText12import br.com.concretesolutions.kappuccino.assertions.VisibilityAssertions.displayed13import br.com.concretesolutions.kappuccino.custom.intent.IntentMatcherInteractions.sentIntent14import br.com.concretesolutions.kappuccino.custom.menu.menu15import com.braincorp.petrolwatcher.R16import com.braincorp.petrolwatcher.feature.vehicles.CreateVehicleActivity17import com.braincorp.petrolwatcher.feature.vehicles.CreateVehicleActivityTest18import com.braincorp.petrolwatcher.feature.vehicles.VehicleListActivity19import com.braincorp.petrolwatcher.feature.vehicles.model.Vehicle20import org.hamcrest.CoreMatchers.*21fun CreateVehicleActivityTest.createVehicle(func: CreateVehicleActivityRobot.() -> Unit):22 CreateVehicleActivityRobot {23 return CreateVehicleActivityRobot(rule).apply(func)24}25class CreateVehicleActivityRobot(private val rule: ActivityTestRule<CreateVehicleActivity>) {26 private var yearPosition = 027 private var manufacturerPosition = 028 private var modelPosition = 029 private var detailsPosition = 030 fun autoInputViewsAreVisible() {31 CreateVehicleResult().autoInputViewsAreVisible()32 }33 fun clickManualInputMenuItem() {34 menu {35 onItem(R.string.manual_input) {36 click()37 }38 }39 }40 fun yearPositionIs(position: Int) {41 yearPosition = position42 }43 fun manufacturerPositionIs(position: Int) {44 manufacturerPosition = position45 }46 fun modelPositionIs(position: Int) {47 modelPosition = position48 }49 fun detailsPositionIs(position: Int) {50 detailsPosition = position51 }52 fun selectYear(position: Int) {53 click {54 id(R.id.spn_year)55 }56 onData(allOf(`is`(instanceOf(Int::class.java))))57 .atPosition(position)58 .perform(ViewActions.click())59 }60 fun selectManufacturer(position: Int) {61 click {62 id(R.id.spn_manufacturer)63 }64 onData(allOf(`is`(instanceOf(String::class.java))))65 .atPosition(position)66 .perform(ViewActions.click())67 }68 fun selectModel(position: Int) {69 click {70 id(R.id.spn_model)71 }72 onData(allOf(`is`(instanceOf(String::class.java))))73 .atPosition(position)74 .perform(ViewActions.click())75 }76 fun selectDetails(position: Int) {77 click {78 id(R.id.spn_details)79 }80 onData(allOf(`is`(instanceOf(Vehicle.Details::class.java))))81 .atPosition(position)82 .perform(ViewActions.click())83 }84 fun typeYear(year: Int) {85 typeText(year.toString()) {86 id(R.id.edt_year)87 }88 }89 fun typeManufacturer(manufacturer: String) {90 typeText(manufacturer) {91 id(R.id.edt_manufacturer)92 }93 }94 fun typeModel(model: String) {95 typeText(model) {96 id(R.id.edt_model)97 }98 }99 fun typeTrimLevel(trimLevel: String) {100 typeText(trimLevel) {101 id(R.id.edt_trim_level)102 }103 }104 fun typeFuelCapacity(capacity: Int) {105 typeText(capacity.toString()) {106 id(R.id.edt_capacity)107 }108 }109 fun typeAvgConsumptionCity(avgConsumptionCity: Float) {110 typeText(avgConsumptionCity.toString()) {111 id(R.id.edt_avg_consumption_city)112 }113 }114 fun typeAvgConsumptionMotorway(avgConsumptionMotorway: Float) {115 typeText(avgConsumptionMotorway.toString()) {116 id(R.id.edt_avg_consumption_motorway)117 }118 }119 infix fun selectYear(func: CreateVehicleResult.() -> Unit) {120 selectYear(yearPosition)121 applyResult(func)122 }123 infix fun selectManufacturer(func: CreateVehicleResult.() -> Unit) {124 selectManufacturer(manufacturerPosition)125 applyResult(func)126 }127 infix fun selectModel(func: CreateVehicleResult.() -> Unit) {128 selectModel(modelPosition)129 applyResult(func)130 }131 infix fun selectDetails(func: CreateVehicleResult.() -> Unit) {132 selectDetails(detailsPosition)133 applyResult(func)134 }135 infix fun clickManualInputMenuItem(func: CreateVehicleResult.() -> Unit) {136 clickManualInputMenuItem()137 applyResult(func)138 }139 infix fun clickAutoInputMenuItem(func: CreateVehicleResult.() -> Unit) {140 menu {141 onItem(R.string.automatic_input) {142 click()143 }144 }145 applyResult(func)146 }147 infix fun rotateDevice(func: CreateVehicleResult.() -> Unit) {148 rule.activity.requestedOrientation = SCREEN_ORIENTATION_LANDSCAPE149 applyResult(func)150 }151 infix fun clickSave(func: CreateVehicleResult.() -> Unit) {152 click {153 id(R.id.fab)154 }155 applyResult(func)156 }157 private fun applyResult(func: CreateVehicleResult.() -> Unit) {158 CreateVehicleResult().apply(func)159 }160}161class CreateVehicleResult {162 fun autoInputViewsAreVisible() {163 displayed {164 id(R.id.label_spn_year)165 id(R.id.spn_year)166 id(R.id.label_spn_manufacturer)167 id(R.id.spn_manufacturer)168 id(R.id.label_spn_model)169 id(R.id.spn_model)170 id(R.id.label_spn_details)171 id(R.id.spn_details)172 }173 }174 fun manualInputViewsAreVisible() {175 displayed {176 id(R.id.edt_year)177 id(R.id.edt_manufacturer)178 id(R.id.edt_model)179 id(R.id.edt_trim_level)180 id(R.id.edt_capacity)181 id(R.id.edt_avg_consumption_city)182 id(R.id.edt_avg_consumption_motorway)183 }184 }185 fun selectedYearIs(year: Int) {186 onView(withId(R.id.spn_year)).check(matches(withSpinnerText(year.toString())))187 }188 fun selectedManufacturerIs(manufacturer: String) {189 onView(withId(R.id.spn_manufacturer)).check(matches(withSpinnerText(manufacturer)))190 }191 fun selectedModelIs(model: String) {192 onView(withId(R.id.spn_model)).check(matches(withSpinnerText(model)))193 }194 fun selectedDetailsIs(details: String) {195 onView(withId(R.id.spn_details)).check(matches(withSpinnerText(containsString(details))))196 }197 fun yearIs(year: Int) {198 displayed {199 allOf {200 id(R.id.edt_year)201 text(year.toString())202 }203 }204 }205 fun manufacturerIs(manufacturer: String) {206 displayed {207 allOf {208 id(R.id.edt_manufacturer)209 text(manufacturer)...

Full Screen

Full Screen

ThemeSettingsTest.kt

Source:ThemeSettingsTest.kt Github

copy

Full Screen

...12import android.support.test.espresso.assertion.ViewAssertions13import android.support.test.espresso.assertion.ViewAssertions.matches14import android.support.test.espresso.matcher.ViewMatchers15import android.support.test.espresso.matcher.ViewMatchers.withId16import android.support.test.espresso.matcher.ViewMatchers.withSpinnerText17import android.support.test.rule.ActivityTestRule18import android.support.test.runner.AndroidJUnit419import android.util.Log20import android.view.View21import android.widget.TextView22import org.hamcrest.CoreMatchers.anything23import org.hamcrest.CoreMatchers.containsString24import org.hamcrest.Matcher25import org.junit.Before26import org.junit.Rule27import org.junit.Test28import org.junit.runner.RunWith29@RunWith(AndroidJUnit4::class)30class ThemeSettingsTest {31 @Rule32 @JvmField33 var activityRule: ActivityTestRule<MainActivity> =34 ActivityTestRule(MainActivity::class.java)35 private lateinit var startValue: String36 private lateinit var nextValue: String37 @Before38 fun setBotClockStatValues() {39 startValue = getText(onView(withId(R.id.bot_clock)))40 val parts = startValue.split(":")41 var min = parts[0].toInt()42 var sec = parts[1].toInt()43 Log.d(min.toString(), sec.toString())44 val timeInSec = (min*60 + sec)-145 min = timeInSec/6046 sec = timeInSec%6047 var minutes = min.toString()48 val seconds = sec.toString()49 if (minutes.length == 1){50 minutes = "0$minutes"51 }52 nextValue = "$minutes:$seconds"53 }54 private fun getText(matcher: ViewInteraction): String {55 var text = String()56 matcher.perform(object : ViewAction {57 override fun getConstraints(): Matcher<View> {58 return ViewMatchers.isAssignableFrom(TextView::class.java)59 }60 override fun getDescription(): String {61 return "Text of the view"62 }63 override fun perform(uiController: UiController, view: View) {64 val tv = view as TextView65 text = tv.text.toString()66 }67 })68 return text69 }70 // How to get string resources71 private fun getResourceString(id: Int): String? {72 val targetContext: Context = InstrumentationRegistry.getTargetContext()73 return targetContext.getResources().getString(id)74 }75 @Test76 fun test_selfStart_option_onTop() {77 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())78 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))79 .perform(click())80 Espresso.onView(ViewMatchers.withId(R.id.self_start_check)).perform(click())81 Espresso.pressBack()82 Espresso.onView(ViewMatchers.withId(R.id.top_sq)).perform(click())83 Espresso.onView(ViewMatchers.withId(R.id.top_clock))84 .check(ViewAssertions.matches(ViewMatchers.withText(nextValue)))85 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())86 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))87 .perform(click())88 Espresso.onView(ViewMatchers.withId(R.id.self_start_check)).perform(click())89 }90 @Test91 fun test_selfStart_option_onBot() {92 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())93 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))94 .perform(click())95 Espresso.onView(ViewMatchers.withId(R.id.self_start_check)).perform(click())96 Espresso.pressBack()97 Espresso.onView(ViewMatchers.withId(R.id.bot_sq)).perform(click())98 Espresso.onView(ViewMatchers.withId(R.id.bot_clock))99 .check(ViewAssertions.matches(ViewMatchers.withText(nextValue)))100 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())101 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))102 .perform(click())103 Espresso.onView(ViewMatchers.withId(R.id.self_start_check)).perform(click())104 }105 @Test106 fun test_dark_mode() {107 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())108 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))109 .perform(click())110 Espresso.onView(ViewMatchers.withId(R.id.action_theme)).perform(click())111 Espresso.onView(ViewMatchers.withId(R.id.action_theme)).perform(click())112 }113 @Test114 fun test_sound_selection() {115 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())116 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))117 .perform(click())118 Espresso.onView(ViewMatchers.withId(R.id.drop_down)).perform(click())119 onData(anything()).atPosition(1).perform(click());120 onView(withId(R.id.drop_down)).check(121 matches(122 withSpinnerText(123 containsString(124 getResourceString(R.string.clearTroatStr)125 )126 )127 )128 );129 Espresso.pressBack()130 Espresso.onView(ViewMatchers.withId(R.id.bot_sq)).perform(click())131 Espresso.onView(ViewMatchers.withId(R.id.settings_button)).perform(click())132 Espresso.onView(ViewMatchers.withText(getResourceString(R.string.themeStr)))133 .perform(click())134 Espresso.onView(ViewMatchers.withId(R.id.drop_down)).perform(click())135 onData(anything()).atPosition(2).perform(click());136 onView(withId(R.id.drop_down)).check(137 matches(138 withSpinnerText(139 containsString(140 getResourceString(R.string.mechClickStr)141 )142 )143 )144 );145 Espresso.pressBack()146 Espresso.onView(ViewMatchers.withId(R.id.top_sq)).perform(click())147 }148}...

Full Screen

Full Screen

AuthorizationFragmentTest.kt

Source:AuthorizationFragmentTest.kt Github

copy

Full Screen

...5import android.support.test.espresso.action.ViewActions.replaceText6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.matcher.ViewMatchers.isDisplayed8import android.support.test.espresso.matcher.ViewMatchers.withId9import android.support.test.espresso.matcher.ViewMatchers.withSpinnerText10import android.support.test.runner.AndroidJUnit411import com.riningan.wowmount.NAME12import com.riningan.wowmount.R13import com.riningan.wowmount.REALM14import com.riningan.wowmount.REGION15import com.riningan.wowmount.dispatcher.Error404Dispatcher16import com.riningan.wowmount.dispatcher.RequestDispatcher17import com.riningan.wowmount.presentation.ui.authorization.AuthorizationFragment18import okhttp3.mockwebserver.MockWebServer19import org.hamcrest.Matchers.`is`20import org.hamcrest.Matchers.allOf21import org.hamcrest.Matchers.containsString22import org.hamcrest.Matchers.instanceOf23import org.hamcrest.Matchers.not24import org.junit.After25import org.junit.Before26import org.junit.Test27import org.junit.runner.RunWith28@RunWith(AndroidJUnit4::class)29class AuthorizationFragmentTest : BaseTest() {30 private lateinit var mWebServer: MockWebServer31 @Before32 fun setup() {33 mWebServer = MockWebServer()34 mWebServer.start(8080)35 }36 @After37 fun teardown() {38 mWebServer.shutdown()39 }40 @Test41 fun checkLayout() {42 mAppRule.launch(AuthorizationFragment::class.java)43 waitCheckFragmentIsDisplayed(R.id.cnslAuthorization)44 }45 @Test46 fun noRealm() {47 mAppRule.launch(AuthorizationFragment::class.java)48 waitCheckFragmentIsDisplayed(R.id.cnslAuthorization)49 onView(withId(R.id.btnAuthorizationShow)).perform(click())50 waitCheckSnackbarText(mAppRule.getActivity().getString(R.string.authorization_error_empty_realm))51 }52 @Test53 fun noCharacter() {54 mAppRule.launch(AuthorizationFragment::class.java)55 waitCheckFragmentIsDisplayed(R.id.cnslAuthorization)56 onView(withId(R.id.etAuthorizationRealm)).perform(replaceText(REALM))57 Thread.sleep(1000)58 onView(withId(R.id.btnAuthorizationShow)).perform(click())59 waitCheckSnackbarText(mAppRule.getActivity().getString(R.string.authorization_error_empty_character_name))60 }61 @Test62 fun authorization() {63 mWebServer.setDispatcher(RequestDispatcher())64 mAppRule.launch(AuthorizationFragment::class.java)65 waitCheckFragmentIsDisplayed(R.id.cnslAuthorization)66 onView(withId(R.id.cmbAuthorizationRegion)).perform(click())67 onData(allOf(`is`(instanceOf(String::class.java)), `is`(REGION))).perform(click())68 onView(withId(R.id.cmbAuthorizationRegion)).check(matches(withSpinnerText(containsString(REGION))))69 Thread.sleep(1000)70 onView(withId(R.id.etAuthorizationRealm)).perform(replaceText(REALM))71 Thread.sleep(1000)72 onView(withId(R.id.etAuthorizationCharacter)).perform(replaceText(NAME))73 Thread.sleep(1000)74 onView(withId(R.id.btnAuthorizationShow)).perform(click())75 onView(withId(R.id.pbAuthorization)).check(matches(isDisplayed()))76 onView(withId(R.id.btnAuthorizationShow)).check(matches(not(isDisplayed())))77 waitCheckFragmentIsDisplayed(R.id.crdlMounts)78 }79 @Test80 fun wrongAuthorisation() {81 mWebServer.setDispatcher(Error404Dispatcher())82 mAppRule.launch(AuthorizationFragment::class.java)83 waitCheckFragmentIsDisplayed(R.id.cnslAuthorization)84 onView(withId(R.id.cmbAuthorizationRegion)).perform(click())85 onData(allOf(`is`(instanceOf(String::class.java)), `is`(REGION))).perform(click())86 onView(withId(R.id.cmbAuthorizationRegion)).check(matches(withSpinnerText(containsString(REGION))))87 Thread.sleep(1000)88 onView(withId(R.id.etAuthorizationRealm)).perform(replaceText(REALM))89 Thread.sleep(1000)90 onView(withId(R.id.etAuthorizationCharacter)).perform(replaceText("Wrong Name"))91 Thread.sleep(1000)92 onView(withId(R.id.btnAuthorizationShow)).perform(click())93 onView(withId(R.id.pbAuthorization)).check(matches(isDisplayed()))94 onView(withId(R.id.btnAuthorizationShow)).check(matches(not(isDisplayed())))95 waitCheckSnackbarIsDisplayed()96 onView(withId(R.id.cnslAuthorization)).check(matches(isDisplayed()))97 }98}...

Full Screen

Full Screen

NoteCreationTests.kt

Source:NoteCreationTests.kt Github

copy

Full Screen

...53 Matchers.equalTo(course)))54 .perform(ViewActions.click())55 Espresso.onView(ViewMatchers.withId(R.id.spinner_courses))56 .check(ViewAssertions.matches(57 ViewMatchers.withSpinnerText(Matchers.containsString(course.courseTitle))))58 Espresso.pressBack()59 }60}...

Full Screen

Full Screen

TestFilters.kt

Source:TestFilters.kt Github

copy

Full Screen

...41 onView(withId(R.id.endBudget)).check(matches(isDisplayed()))42 }43 @Test44 fun testAges() {45 onView(withId(R.id.startAge)).check(matches(withSpinnerText("0"))).perform(click())46 onData(allOf(`is`(instanceOf(String::class.java)), `is`("12"))).perform(click())47 onView(withId(R.id.startAge)).check(matches(withSpinnerText(containsString("12"))))48 onView(withId(R.id.endAge)).check(matches(withSpinnerText(containsString("80")))).perform(click())49 onData(allOf(`is`(instanceOf(String::class.java)), `is`("80"))).perform(click())50 onView(withId(R.id.endAge)).check(matches(withSpinnerText(containsString("80"))))51 }52 @Test53 fun testSex() {54 onView(withId(R.id.sexAny)).check(matches(isChecked()))55 }56 @Test57 fun testCities() {58 onView(withId(R.id.startCity)).check(matches(withText("")))59 onView(withId(R.id.endCity)).check(matches(withText("")))60 }61}...

Full Screen

Full Screen

NextThroughNotesTest.kt

Source:NextThroughNotesTest.kt Github

copy

Full Screen

...27 )28 for (index in 0..DataManager.notes.lastIndex) {29 val note = DataManager.notes[index]30 onView(withId(R.id.spinnerCourses)).check(31 matches(withSpinnerText(note.course?.title))32 )33 onView(withId(R.id.textNoteTitle)).check(34 matches(withText(note.title))35 )36 onView(withId(R.id.textNoteText)).check(37 matches(withText(note.text))38 )39 if(index != DataManager.notes.lastIndex)40 onView(allOf(withId(R.id.action_next), isEnabled())).perform(click())41 }42 onView(withId(R.id.action_next)).check(matches(not(isEnabled())))43 }44}...

Full Screen

Full Screen

EspressoAssertion.kt

Source:EspressoAssertion.kt Github

copy

Full Screen

...11class EspressoAssertion(init: EspressoAssertion.() -> Unit, private val viewInteraction: ViewInteraction?) {12 var visibility: ViewMatchers.Visibility by Delegator(::withEffectiveVisibility)13 var text: String by Delegator(::withText)14 var textResId: Int by Delegator(::withText)15 var spinnerText: String by Delegator(::withSpinnerText)16 var enabled: Boolean by Delegator(::withEnabled)17 var checked: Boolean by Delegator { if (it) isChecked() else isNotChecked() }18 var color: Int by Delegator(::withTextColor)19 var displayed: Boolean by Delegator { if(it) isDisplayed() else not(isDisplayed())}20 var backgroundResId: Int by Delegator(::withBackground)21 inner class Delegator<K, T>(val block: (T) -> Matcher<View>) : ReadWriteProperty<K, T> {22 override fun getValue(thisRef: K, property: KProperty<*>): T {23 throw UnsupportedOperationException("not implemented")24 }25 override fun setValue(thisRef: K, property: KProperty<*>, value: T) {26 checkNotNull(viewInteraction, { "Missing 'on { }' block before 'assert { }'" })27 viewInteraction?.check(ViewAssertions.matches(block(value)))28 }29 }...

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1public ActivityTestRule<MainActivity> mActivityTestRule = new ActivityTestRule<>(MainActivity.class);2public void useAppContext() {3Context appContext = InstrumentationRegistry.getTargetContext();4assertEquals("com.example.saurabh.test", appContext.getPackageName());5}6public void testHelloWorld() {7onView(withId(R.id.btn_hello)).perform(click());8onView(withText(R.string.hello_world)).check(matches(isDisplayed()));9}10public void testSpinner() {11onView(withId(R.id.spinner)).perform(click());12onData(allOf(is(instanceOf(String.class)), is("Option 1"))).perform(click());13}14public void testSpinnerWithText() {15onView(withId(R.id.spinner)).perform(click());16onData(allOf(is(instanceOf(String.class)), is("Option 1"))).perform(click());17onView(withId(R.id.spinner)).check(matches(withSpinnerText(containsString("Option 1"))));18}19}

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1import android.support.test.espresso.matcher.ViewMatchers.withSpinnerText;2import android.support.test.espresso.matcher.ViewMatchers.withText;3import android.support.test.espresso.matcher.ViewMatchers.withTagValue;4import android.support.test.espresso.matcher.ViewMatchers.withId;5import android.support.test.espresso.matcher.ViewMatchers.withClassName;6import android.support.test.espresso.matcher.ViewMatchers.withContentDescription;7import android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;8import android.support.test.espresso.matcher.ViewMatchers.withHint;9import android.support.test.espresso.matcher.ViewMatchers.withInputType;10import android.support.test.espresso.matcher.ViewMatchers.withParent;11import android.support.test.espresso.matcher.ViewMatchers.withParentIndex;12import android.support.test.espresso.matcher.ViewMatchers.withParentMatcher;13import android.support.test.espresso.matcher.ViewMatchers.withResourceName;14import android.support.test.espresso.matcher.ViewMatchers.withText;15import android.support.test.espresso.matcher.ViewMatchers.withContentDescription;16import android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;17import android.support.test.espresso.matcher.ViewMatchers.withHint;18import android

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1ViewInteraction appCompatButton = onView(2allOf(withId(R.id.button), withText("Click Me"),3childAtPosition(4childAtPosition(5withClassName(is("android.widget.LinearLayout")),6isDisplayed()));7appCompatButton.perform(click());8ViewInteraction appCompatSpinner = onView(9allOf(withId(R.id.spinner),10childAtPosition(11childAtPosition(12withClassName(is("android.widget.LinearLayout")),13isDisplayed()));14appCompatSpinner.perform(click());15DataInteraction appCompatCheckedTextView = onData(anything())16.inAdapterView(childAtPosition(17withClassName(is("android.widget.PopupWindow$PopupBackgroundView")),18.atPosition(1);19appCompatCheckedTextView.perform(click());20ViewInteraction appCompatButton2 = onView(21allOf(withId(R.id.button), withText("Click Me"),22childAtPosition(23childAtPosition(24withClassName(is("android.widget.LinearLayout")),25isDisplayed()));26appCompatButton2.perform(click());27ViewInteraction textView = onView(28allOf(withId(R.id.textView), withText("You selected: Option 2"),29withParent(withParent(IsInstanceOf.<View>instanceOf(android.widget.LinearLayout.class))),30isDisplayed()));31textView.check(matches(withText("You selected: Option 2")));32}33private static Matcher<View> childAtPosition(34final Matcher<View> parentMatcher, final int position) {35return new TypeSafeMatcher<View>() {36@Override public void describeTo(Description description) {37description.appendText("Child at position " + position + " in parent ");38parentMatcher.describeTo(description);39}40@Override public boolean matchesSafely(View view) {41ViewGroup parent = (ViewGroup) view.getParent();42return parent != null && parentMatcher.matches(parent)43&& view.equals(parent.getChildAt(position));44}45};46}47}48}

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1import android.support.test.espresso.Espresso;2import android.support.test.espresso.matcher.ViewMatchers;3import android.support.test.espresso.IdlingResource;4import android.support.test.espresso.IdlingRegistry;5import android.support.test.espresso.IdlingPolicies;6import android.support.test.espresso.IdlingPolicy;7import andr

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1ViewInteraction appCompatButton = onView(2allOf(withId(R.id.btn), withText("Click Me"),3childAtPosition(4childAtPosition(5withId(android.R.id.content),6isDisplayed()));7appCompatButton.perform(click());8ViewInteraction appCompatButton2 = onView(9allOf(withId(R.id.btn), withText("Click Me"),10childAtPosition(11childAtPosition(12withId(android.R.id.content),13isDisplayed()));14appCompatButton2.perform(click());15ViewInteraction appCompatButton3 = onView(16allOf(withId(R.id.btn), withText("Click Me"),17childAtPosition(18childAtPosition(19withId(android.R.id.content),20isDisplayed()));21appCompatButton3.perform(click());22ViewInteraction appCompatButton4 = onView(23allOf(withId(R.id.btn), withText("Click Me"),24childAtPosition(25childAtPosition(26withId(android.R.id.content),27isDisplayed()));28appCompatButton4.perform(click());29ViewInteraction appCompatButton5 = onView(30allOf(withId(R.id.btn), withText("Click Me"),31childAtPosition(32childAtPosition(33withId(android.R.id.content),34isDisplayed()));35appCompatButton5.perform(click());36ViewInteraction appCompatButton6 = onView(37allOf(withId(R.id.btn), withText("Click Me"),38childAtPosition(39childAtPosition(40withId(android.R.id.content),41isDisplayed()));42appCompatButton6.perform(click());43ViewInteraction appCompatButton7 = onView(44allOf(withId(R.id.btn), withText("Click Me"),45childAtPosition(46childAtPosition(47withId(android.R.id.content),48isDisplayed()));49appCompatButton7.perform(click());50ViewInteraction appCompatButton8 = onView(51allOf(withId(R.id.btn), with

Full Screen

Full Screen

withSpinnerText

Using AI Code Generation

copy

Full Screen

1public ActivityTestRule<MainActivity> mainActivityActivityTestRule = new ActivityTestRule<>(MainActivity.class);2public void testWithSpinnerText() {3onView(withId(R.id.spinner)).perform(click());4onData(allOf(is(instanceOf(String.class)), is("Item 1"))).perform(click());5onView(withId(R.id.spinner)).check(matches(withSpinnerText(containsString("Item 1"))));6}7}

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