How to use closeSoftKeyboard method of android.support.test.espresso.Espresso class

Best Appium-espresso-driver code snippet using android.support.test.espresso.Espresso.closeSoftKeyboard

BackupActivityFullHappyPathTest.kt

Source:BackupActivityFullHappyPathTest.kt Github

copy

Full Screen

1package kin.backup.and.restore.ui.tests2import android.support.test.InstrumentationRegistry3import android.support.test.espresso.Espresso.onView4import android.support.test.espresso.action.ViewActions.click5import android.support.test.espresso.action.ViewActions.closeSoftKeyboard6import android.support.test.espresso.action.ViewActions.replaceText7import android.support.test.espresso.assertion.ViewAssertions.matches8import android.support.test.espresso.matcher.ViewMatchers.isDisplayed9import android.support.test.espresso.matcher.ViewMatchers.withClassName10import android.support.test.espresso.matcher.ViewMatchers.withId11import android.support.test.espresso.matcher.ViewMatchers.withText12import android.support.test.filters.LargeTest13import android.support.test.rule.ActivityTestRule14import android.support.test.runner.AndroidJUnit415import android.support.test.uiautomator.UiDevice16import kin.backup.and.restore.ui.tests.UiTestUtils.childAtPosition17import org.hamcrest.Matchers.`is`18import org.hamcrest.Matchers.allOf19import org.junit.Rule20import org.junit.Test21import org.junit.runner.RunWith22@LargeTest23@RunWith(AndroidJUnit4::class)24class BackupActivityFullHappyPathTest {25 @Rule26 @JvmField27 var activityTestRule = ActivityTestRule(BackupAndRestoreDummyActivityForUITest::class.java)28 @Test29 fun backupActivityFullHappyPathTest() {30 val appCompatButton = onView(31 allOf(withId(R.id.create_new_account), withText(R.string.create_new_account),32 childAtPosition(33 childAtPosition(34 withId(android.R.id.content),35 0),36 5),37 isDisplayed()))38 appCompatButton.perform(click())39 val appCompatButton2 = onView(40 allOf(withId(R.id.backup_current_account), withText(R.string.backup_current_account),41 childAtPosition(42 childAtPosition(43 withId(android.R.id.content),44 0),45 6),46 isDisplayed()))47 appCompatButton2.perform(click())48 val appCompatButton3 = onView(49 allOf(withId(R.id.lets_go_button), withText(R.string.backup_and_restore_lets_go),50 childAtPosition(51 childAtPosition(52 withId(R.id.fragment_frame),53 0),54 3),55 isDisplayed()))56 appCompatButton3.perform(click())57 closeSoftKeyboard()58 val editText2 = onView(59 allOf(childAtPosition(60 allOf(withId(R.id.enter_pass_edittext),61 childAtPosition(62 withClassName(`is`("android.support.constraint.ConstraintLayout")),63 2)),64 0),65 isDisplayed()))66 editText2.perform(replaceText("q"), closeSoftKeyboard())67 val editText3 = onView(68 allOf(withText("q"),69 isDisplayed()))70 editText3.perform(replaceText("qw"))71 val editText4 = onView(72 allOf(withText("qw"),73 isDisplayed()))74 editText4.perform(replaceText("qwe"))75 val editText7 = onView(76 allOf(withText("qwe"),77 isDisplayed()))78 editText7.perform(replaceText("qwer"))79 val editText9 = onView(80 allOf(withText("qwer"),81 isDisplayed()))82 editText9.perform(replaceText("qwert"))83 val editText10 = onView(84 allOf(withText("qwert"),85 isDisplayed()))86 editText10.perform(closeSoftKeyboard())87 val editText11 = onView(88 allOf(withText("qwert"),89 isDisplayed()))90 editText11.perform(replaceText("qwerty"))91 val editText12 = onView(92 allOf(withText("qwerty"),93 isDisplayed()))94 editText12.perform(closeSoftKeyboard())95 editText12.perform(replaceText("qwertyU"))96 val editText14 = onView(97 allOf(withText("qwertyU"),98 isDisplayed()))99 editText14.perform(closeSoftKeyboard())100 editText14.perform(replaceText("qwertyU1"))101 val editText16 = onView(102 allOf(withText("qwertyU1"),103 isDisplayed()))104 editText16.perform(closeSoftKeyboard())105 editText16.perform(replaceText("qwertyU1!"))106 val editText18 = onView(107 allOf(withText("qwertyU1!"),108 isDisplayed()))109 editText18.perform(closeSoftKeyboard())110 val editText19 = onView(111 allOf(childAtPosition(112 allOf(withId(R.id.confirm_pass_edittext),113 childAtPosition(114 withClassName(`is`("android.support.constraint.ConstraintLayout")),115 3)),116 0),117 isDisplayed()))118 editText19.perform(replaceText("q"), closeSoftKeyboard())119 val editText20 = onView(120 allOf(withText("q"),121 isDisplayed()))122 editText20.perform(replaceText("qw"))123 val editText21 = onView(124 allOf(withText("qw"),125 isDisplayed()))126 editText21.perform(closeSoftKeyboard())127 editText21.perform(replaceText("qwe"))128 val editText23 = onView(129 allOf(withText("qwe"),130 isDisplayed()))131 editText23.perform(closeSoftKeyboard())132 editText23.perform(replaceText("qwer"))133 val editText25 = onView(134 allOf(withText("qwer"),135 isDisplayed()))136 editText25.perform(closeSoftKeyboard())137 editText25.perform(replaceText("qwert"))138 val editText27 = onView(139 allOf(withText("qwert"),140 isDisplayed()))141 editText27.perform(closeSoftKeyboard())142 editText27.perform(replaceText("qwerty"))143 val editText29 = onView(144 allOf(withText("qwerty"),145 isDisplayed()))146 editText29.perform(closeSoftKeyboard())147 editText29.perform(replaceText("qwertyU"))148 val editText31 = onView(149 allOf(withText("qwertyU"),150 isDisplayed()))151 editText31.perform(closeSoftKeyboard())152 editText31.perform(replaceText("qwertyU1"))153 val editText33 = onView(154 allOf(withText("qwertyU1"),155 isDisplayed()))156 editText33.perform(replaceText("qwertyU1!"))157 onView(allOf(withText("qwertyU1!"),158 isDisplayed()))159 closeSoftKeyboard()160 val appCompatCheckBox = onView(161 allOf(withId(R.id.understand_checkbox),162 childAtPosition(163 childAtPosition(164 withId(R.id.fragment_frame),165 0),166 4),167 isDisplayed()))168 appCompatCheckBox.perform(click())169 val appCompatButton4 = onView(170 allOf(withId(R.id.next_button), withText(R.string.backup_and_restore_next),171 childAtPosition(172 childAtPosition(173 withId(R.id.fragment_frame),...

Full Screen

Full Screen

UIRegisterTest.kt

Source:UIRegisterTest.kt Github

copy

Full Screen

...73 @Test74 fun register_someFieldsEmpty_showToastEmptyFields() {75 //vul email in76 onView(withId(R.id.text_register_email)).perform(ViewActions.typeText(email))77 android.support.test.espresso.Espresso.closeSoftKeyboard()78 //vul username in79 onView(withId(R.id.text_register_username)).perform(ViewActions.typeText(username))80 android.support.test.espresso.Espresso.closeSoftKeyboard()81 //druk op registreer82 onView(withId(R.id.button_register_confirm)).perform(click())83 //kijk empty fields toast84 onView(withText(R.string.warning_empty_fields)).inRoot(85 RootMatchers.withDecorView(86 CoreMatchers.not(87 CoreMatchers.`is`(88 mActivityTestRule.activity.window.decorView89 )90 )91 )92 ).check(matches(isDisplayed()))93 }94 @Test95 fun register_passwordsDoNotMatch_showToastPasswordsNotEqual() {96 //vul email in97 onView(withId(R.id.text_register_email)).perform(ViewActions.typeText(email))98 android.support.test.espresso.Espresso.closeSoftKeyboard()99 //vul username in100 onView(withId(R.id.text_register_username)).perform(ViewActions.typeText(username))101 android.support.test.espresso.Espresso.closeSoftKeyboard()102 //vul ww in103 onView(withId(R.id.text_register_password)).perform(ViewActions.typeText(password))104 android.support.test.espresso.Espresso.closeSoftKeyboard()105 //vul confirm ww in106 onView(withId(R.id.text_register_confirm_password)).perform(ViewActions.typeText(password + "notEqual"))107 android.support.test.espresso.Espresso.closeSoftKeyboard()108 //druk op registreer109 onView(withId(R.id.button_register_confirm)).perform(click())110 //kijk password not equal toast111 onView(withText(R.string.warning_passwords_not_equal)).inRoot(112 RootMatchers.withDecorView(113 CoreMatchers.not(114 CoreMatchers.`is`(115 mActivityTestRule.activity.window.decorView116 )117 )118 )119 ).check(matches(isDisplayed()))120 }121 @Test122 fun register_existingUsername_doesNotRegister() {123 //vul email in124 onView(withId(R.id.text_register_email)).perform(ViewActions.typeText(email))125 android.support.test.espresso.Espresso.closeSoftKeyboard()126 //vul username in127 onView(withId(R.id.text_register_username)).perform(ViewActions.typeText(tokenUsername))128 android.support.test.espresso.Espresso.closeSoftKeyboard()129 //vul ww in130 onView(withId(R.id.text_register_password)).perform(ViewActions.typeText(password))131 android.support.test.espresso.Espresso.closeSoftKeyboard()132 //vul confirm ww in133 onView(withId(R.id.text_register_confirm_password)).perform(ViewActions.typeText(password))134 android.support.test.espresso.Espresso.closeSoftKeyboard()135 //druk op registreer136 onView(withId(R.id.button_register_confirm)).perform(click())137 //kijk register fragment zichtbaar (toast komt van server)138 onView(withId(R.id.fragment_register)).check(matches(isDisplayed()))139 }140 @Test141 fun register_existingEmail_doesNotRegister() {142 //vul email in143 onView(withId(R.id.text_register_email)).perform(ViewActions.typeText(tokenEmail))144 android.support.test.espresso.Espresso.closeSoftKeyboard()145 //vul username in146 onView(withId(R.id.text_register_username)).perform(ViewActions.typeText(username))147 android.support.test.espresso.Espresso.closeSoftKeyboard()148 //vul ww in149 onView(withId(R.id.text_register_password)).perform(ViewActions.typeText(password))150 android.support.test.espresso.Espresso.closeSoftKeyboard()151 //vul confirm ww in152 onView(withId(R.id.text_register_confirm_password)).perform(ViewActions.typeText(password))153 android.support.test.espresso.Espresso.closeSoftKeyboard()154 //druk op registreer155 onView(withId(R.id.button_register_confirm)).perform(click())156 //kijk register fragment zichtbaar (toast komt van server)157 onView(withId(R.id.fragment_register)).check(matches(isDisplayed()))158 }159 @Test160 fun register_correctInfo_registerAndCorrectUsername() {161 //vul email in162 onView(withId(R.id.text_register_email)).perform(ViewActions.typeText(email))163 android.support.test.espresso.Espresso.closeSoftKeyboard()164 //vul username in165 onView(withId(R.id.text_register_username)).perform(ViewActions.typeText(username))166 android.support.test.espresso.Espresso.closeSoftKeyboard()167 //vul ww in168 onView(withId(R.id.text_register_password)).perform(ViewActions.typeText(password))169 android.support.test.espresso.Espresso.closeSoftKeyboard()170 //vul confirm ww in171 onView(withId(R.id.text_register_confirm_password)).perform(ViewActions.typeText(password))172 android.support.test.espresso.Espresso.closeSoftKeyboard()173 //druk op registreer174 onView(withId(R.id.button_register_confirm)).perform(click())175 //wacht even voor server176 SystemClock.sleep(1000)177 //username op account pagina178 onView(withId(R.id.text_account_username)).check(matches(withText(username)))179 }180}...

Full Screen

Full Screen

LoginSteps.kt

Source:LoginSteps.kt Github

copy

Full Screen

1package com.transporter.streetglide.test.ui.loginfeature2import android.app.Activity3import android.content.ComponentName4import android.support.test.InstrumentationRegistry5import android.support.test.espresso.Espresso.closeSoftKeyboard6import android.support.test.espresso.Espresso.onView7import android.support.test.espresso.action.ViewActions.click8import android.support.test.espresso.action.ViewActions.typeText9import android.support.test.espresso.assertion.ViewAssertions.matches10import android.support.test.espresso.intent.Intents11import android.support.test.espresso.intent.matcher.IntentMatchers12import android.support.test.espresso.matcher.ViewMatchers.*13import android.support.test.rule.ActivityTestRule14import com.transporter.streetglide.ui.nocurrentsheet.NoCurrentSheetActivity15import com.transporter.streetglide.ui.runnerlogin.LoginActivity16import cucumber.api.java.After17import cucumber.api.java.Before18import cucumber.api.java.en.Given19import cucumber.api.java.en.Then20import cucumber.api.java.en.When21import junit.framework.Assert.assertNotNull22import org.hamcrest.Matchers.allOf23import org.junit.Rule24class LoginSteps {25 @Rule26 val activityTestRule = ActivityTestRule(LoginActivity::class.java)27 private lateinit var activity: Activity28 @Before29 fun setup() {30 activityTestRule.launchActivity(null)31 activity = activityTestRule.activity32 }33 @After34 fun tearDown() {35 activityTestRule.finishActivity()36 }37 @Given("^Runner at the login page$")38 @Throws(Throwable::class)39 fun runnerAtLoginPage() {40 assertNotNull(activity)41 }42 @When("^He inserts his credentials successfully$")43 @Throws(Throwable::class)44 fun iInsertAsUsername() {45 onView(withHint("اسم المستخدم")).perform(typeText("omar"))46 closeSoftKeyboard()47 onView(withHint("الرقم السري")).perform(typeText("adel1234"))48 closeSoftKeyboard()49 onView(withText("دخول")).perform(click())50 }51 @Then("^He will be logged to the app successfully$")52 @Throws(Throwable::class)53 fun loggedSuccessfully() {54// onView(allOf(withId(android.support.design.R.id.snackbar_text), withText("لديك شيت اليوم")))55// .check(matches(isDisplayed()))56 Intents.intended(IntentMatchers.hasComponent(ComponentName(InstrumentationRegistry.getTargetContext(), NoCurrentSheetActivity::class.java)))57 }58 @When("^Runner login in using ([^/*]*)$")59 @Throws(Throwable::class)60 fun loggedUnSuccessfully(credential: String) {61 when (credential) {62 "wrong credentials" -> {63 onView(withHint("اسم المستخدم")).perform(typeText("invalidUser"))64 closeSoftKeyboard()65 onView(withHint("الرقم السري")).perform(typeText("invalidPassword"))66 closeSoftKeyboard()67 onView(withText("دخول")).perform(click())68 }69 "deleted user credentials" -> {70 onView(withHint("اسم المستخدم")).perform(typeText("farghaly"))71 closeSoftKeyboard()72 onView(withHint("الرقم السري")).perform(typeText("adel1234"))73 closeSoftKeyboard()74 onView(withText("دخول")).perform(click())75 }76 "missing credentials" -> {77 onView(withHint("اسم المستخدم")).perform(typeText(""))78 closeSoftKeyboard()79 onView(withHint("الرقم السري")).perform(typeText("adel1234"))80 closeSoftKeyboard()81 onView(withText("دخول")).perform(click())82 }83 "inactive user credentials" -> {84 onView(withHint("اسم المستخدم")).perform(typeText("khaled"))85 closeSoftKeyboard()86 onView(withHint("الرقم السري")).perform(typeText("adel1234"))87 closeSoftKeyboard()88 onView(withText("دخول")).perform(click())89 }90 }91 }92 @Then("^This ([^/*]*) is displayed$")93 @Throws(Throwable::class)94 fun showErrorMessage(msg: String) {95 onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(msg)))96 .check(matches(isDisplayed()))97 }98}...

Full Screen

Full Screen

LogInActivityTest.kt

Source:LogInActivityTest.kt Github

copy

Full Screen

1package com.applikey.mattermost.activities2import android.support.test.InstrumentationRegistry3import android.support.test.espresso.Espresso.closeSoftKeyboard4import android.support.test.espresso.Espresso.onView5import android.support.test.espresso.action.ViewActions.*6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.matcher.ViewMatchers.*8import android.support.test.rule.ActivityTestRule9import android.support.test.runner.AndroidJUnit410import com.applikey.mattermost.R11import org.hamcrest.Matchers.any12import org.hamcrest.Matchers.not13import org.junit.Before14import org.junit.Rule15import org.junit.Test16import org.junit.runner.RunWith17@RunWith(AndroidJUnit4::class)18class LogInActivityTest {19 companion object {20 const val serverName = "http://mattermost-nutscracker53.herokuapp.com/"21 const val userName = "test5@gmail.com"22 const val password = "11111"23 }24 @JvmField @Rule25 val activity: ActivityTestRule<ChooseServerActivity> = ActivityTestRule<ChooseServerActivity>(ChooseServerActivity::class.java)26 @Before27 fun before() {28 onView(withId(R.id.et_server)).perform(clearText())29 }30 @Test31 fun testThatCorrectServerAllowsToSignIn() {32 onView(withId(R.id.et_server)).perform(typeText(serverName))33 closeSoftKeyboard()34 onView(withId(R.id.b_proceed)).perform(click())35 onView(withId(R.id.et_login)).check(matches(isDisplayed()))36 }37 @Test38 fun testThatProceedButtonIsDisabledWhenServerIsNotConfigure() {39 onView(withId(R.id.et_server)).perform(typeText(""))40 closeSoftKeyboard()41 onView(withId(R.id.b_proceed)).check(matches(not(isEnabled())))42 }43 @Test44 fun testThatIncorrectServerAddressShowsError() {45 onView(withId(R.id.et_server)).perform(typeText("sdgaqweaqwdasdf"))46 closeSoftKeyboard()47 onView(withId(R.id.b_proceed)).perform(click())48 onView(withId(R.id.et_server)).check(matches(hasErrorText(getStringRes(R.string.invalid_server_url))))49 }50 @Test51 fun testThatProceedButtonEnabledWhenServerFilled() {52 onView(withId(R.id.et_server)).perform(typeText("idud"))53 closeSoftKeyboard()54 onView(withId(R.id.b_proceed)).check(matches(isDisplayed()))55 }56 @Test57 fun testThatUserCanLoginAfterSuccessfullyEnteredServerAddress() {58 onView(withId(R.id.et_server)).perform(typeText(serverName))59 closeSoftKeyboard()60 onView(withId(R.id.b_proceed)).perform(click())61 onView(withId(R.id.et_login)).perform(typeText(userName))62 onView(withId(R.id.et_password)).perform(typeText(password))63 closeSoftKeyboard()64 onView(withId(R.id.b_authorize)).perform(click())65 Thread.sleep(3000)66 onView(withId(R.id.tv_password)).check(matches(isDisplayed()))67 }68 @Test69 fun testThatErrorWillShowIfPasswordNotEntered() {70 onView(withId(R.id.et_server)).perform(typeText(serverName))71 closeSoftKeyboard()72 onView(withId(R.id.b_proceed)).perform(click())73 onView(withId(R.id.et_login)).perform(typeText(userName))74 onView(withId(R.id.et_password)).perform(typeText(""))75 closeSoftKeyboard()76 onView(withId(R.id.b_authorize)).perform(click())77 onView(withId(R.id.et_password)).check(matches(hasErrorText(any(String::class.java))))78 }79 @Test80 fun testThatIncorrectLoginWillProduceNotFoundError() {81 onView(withId(R.id.et_server)).perform(typeText(serverName))82 closeSoftKeyboard()83 onView(withId(R.id.b_proceed)).perform(click())84 onView(withId(R.id.et_login)).perform(typeText("asdasd"))85 onView(withId(R.id.et_password)).perform(typeText("asdas"))86 closeSoftKeyboard()87 onView(withId(R.id.b_authorize)).perform(click())88 onView(withId(R.id.et_password)).check(matches(hasErrorText(any(String::class.java))))89 }90 private fun getStringRes(res: Int): String {91 val targetContext = InstrumentationRegistry.getTargetContext()92 return targetContext.getString(res)93 }94}...

Full Screen

Full Screen

IntentTest.kt

Source:IntentTest.kt Github

copy

Full Screen

...31 @Test32 fun activityLaunch() {33 val message = "Good Morning Luis alonso"34 //Login prueba de ingreso correcto35 onView(withId(R.id.etUsername)).perform(typeText("diego"), ViewActions.closeSoftKeyboard())36 onView(withId(R.id.etPassword)).perform(typeText("123456"), ViewActions.closeSoftKeyboard())37 onView(withId(R.id.btnIngresar)).perform(click())38 //Ingreso segunda actividad39 onView(withId(R.id.btnTestAFR)).perform(click())40 //verifica que se envie la intencion al activity siguiente41 intended(hasComponent(SecondActivity::class.java.name))42 onView(withId(R.id.edtMessage)).perform(typeText(message), ViewActions.closeSoftKeyboard())43 val resultData = Intent()44 resultData.putExtra("message", message)45 var result: Instrumentation.ActivityResult = Instrumentation.ActivityResult(Activity.RESULT_OK, resultData)46 //actividad que va gestionar el envio del resultado47 onView(withId(R.id.btnSendMessage)).perform(click())48 intending(toPackage(SecondActivity::class.java.name)).respondWith(result)49// intended(toPackage("com.example.interfacestaxi.SecondActivity"))50// intended(toPackage("com.example.interfacestaxi.SecondActivity.kt"))51 onView(withId(R.id.tvWelcome)).check(matches(withText(message)))52 }53 @Test54 fun testRegisterSucessfulAndTestRecyclerView() {55 onView(withId(R.id.tvRegister)).perform(click())56 onView(withId(R.id.etName)).perform(typeText("Diego"), closeSoftKeyboard())57 onView(withId(R.id.etLastName)).perform(typeText("Pacheco"), closeSoftKeyboard())58 onView(withId(R.id.etPassword)).perform(typeText("tismart"), closeSoftKeyboard())59 onView(withId(R.id.etPhone)).perform(typeText("948429548"), closeSoftKeyboard())60 onView(withId(R.id.etEmail)).perform(typeText("diego.pacheco@tismart.com"), closeSoftKeyboard())61 onView(withId(R.id.btnRegister)).perform(click())62 onView(withId(R.id.btnTestRV)).perform(click())63 onView(withId(R.id.rvJob))64 .perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(ITEM_FOR_MATCH, click()))65 val itemElementText = intentsTestRule.activity.applicationContext.resources.getString(R.string.company_microfost)66 onView(withText(itemElementText)).check(matches(isDisplayed()))67 }68}...

Full Screen

Full Screen

RegistrationActivityTest.kt

Source:RegistrationActivityTest.kt Github

copy

Full Screen

...26 @JvmField27 val rule = ActivityTestRule(RegistrationActivity::class.java)28 @Test29 fun repeat_password_empty_field() {30 Espresso.onView(withId(R.id.repeat_password_registration)).perform(ViewActions.closeSoftKeyboard())31 Espresso.onView(withId(R.id.button_registration))32 .perform(ViewActions.click())33 Espresso.onView(withId(R.id.repeat_password_registration))34 .check(matches(hasErrorText("Поле должно быть заполнено")))35 }36 @Test37 fun different_password() {38 val pass1 = "1234567890"39 val pass2 = "123456"40 Espresso.onView((withId(R.id.password_registration)))41 .perform(ViewActions.typeText(pass1), ViewActions.closeSoftKeyboard())42 Espresso.onView((withId(R.id.repeat_password_registration)))43 .perform(ViewActions.typeText(pass2), ViewActions.closeSoftKeyboard())44 Espresso.onView(withId(R.id.button_registration))45 .perform(ViewActions.click())46 Espresso.onView(withId(R.id.password_registration))47 .check(matches(hasErrorText("Пароли не совпадают")))48 }49 @Test50 fun success_registration() {51 Espresso.onView(withId(R.id.first_name_registration))52 .perform(ViewActions.typeText(fistName), ViewActions.closeSoftKeyboard())53 Espresso.onView(withId(R.id.last_name_registration))54 .perform(ViewActions.typeText(lastName), ViewActions.closeSoftKeyboard())55 Espresso.onView(withId(R.id.phone_number_registration))56 .perform(ViewActions.typeText(phoneNumber), ViewActions.closeSoftKeyboard())57 Espresso.onView((withId(R.id.email_registration)))58 .perform(ViewActions.typeText(login), ViewActions.closeSoftKeyboard())59 Espresso.onView(withId(R.id.password_registration))60 .perform(ViewActions.typeText(password), ViewActions.closeSoftKeyboard())61 Espresso.onView((withId(R.id.repeat_password_registration)))62 .perform(ViewActions.typeText(password), ViewActions.closeSoftKeyboard())63 Espresso.onView(withId(R.id.button_registration))64 .perform(ViewActions.click())65 Thread.sleep(2000)66 Espresso.onView(ViewMatchers.withText("Пользователь зарегистрирован"))67 .inRoot(RootMatchers.withDecorView(Matchers.not(rule.activity.window.decorView)))68 .check(ViewAssertions.doesNotExist())69 assertTrue(rule.activity.isFinishing)70 }71}...

Full Screen

Full Screen

FragmentInstrumentedTest.kt

Source:FragmentInstrumentedTest.kt Github

copy

Full Screen

...28 mActivityRule.activity.fragmentManager.beginTransaction()29 }30 @Test31 fun setEditText() {32// Espresso.onView(ViewMatchers.withId(R.id.edtTxt_fragment)).perform(ViewActions.clearText(), ViewActions.typeText("Hello Espresso Fragment"), ViewActions.closeSoftKeyboard())33// TODO WithText() is giving (No views in hierarchy found matching: with text: is) Not Working, find solution....34 Espresso.onView(ViewMatchers.withText("fragmentLabel_test")).perform(ViewActions.clearText(), ViewActions.typeText("Hello Espresso Fragment"), ViewActions.closeSoftKeyboard())35 Espresso.onView(ViewMatchers.withId(R.id.edtTxt_1)).perform(ViewActions.clearText(), ViewActions.typeText("Hello Espresso 1"), ViewActions.closeSoftKeyboard())36 Espresso.onView(ViewMatchers.withId(R.id.edtTxt_2)).perform(ViewActions.clearText(), ViewActions.typeText("Hello Espresso 2"), ViewActions.closeSoftKeyboard())37 Espresso.onView(ViewMatchers.withId(R.id.edtTxt_3)).perform(ViewActions.clearText(), ViewActions.typeText("Hello Espresso 3"), ViewActions.closeSoftKeyboard())38 }39 @Test40 fun isToastDisplayed() {41 Espresso.onView(ViewMatchers.withId(R.id.btn_showToast)).perform(ViewActions.click())42 Espresso.onView(ViewMatchers.withText(context?.getString(R.string.toast))).inRoot(RootMatchers.withDecorView(Matchers.not(Matchers.`is`(mActivityRule.activity.window.decorView)))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))43 }44 @After45 fun afterTest() {46 Thread.sleep(1000)47 }48}...

Full Screen

Full Screen

TheImportAccountActivity.kt

Source:TheImportAccountActivity.kt Github

copy

Full Screen

1package org.walleth.tests2import android.support.test.espresso.Espresso.closeSoftKeyboard3import android.support.test.espresso.Espresso.onView4import android.support.test.espresso.action.ViewActions.click5import android.support.test.espresso.action.ViewActions.typeText6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.matcher.ViewMatchers.*8import com.google.common.truth.Truth.assertThat9import org.junit.Rule10import org.junit.Test11import org.ligi.trulesk.TruleskActivityRule12import org.walleth.R13import org.walleth.activities.ImportActivity14import org.walleth.infrastructure.TestApp15class TheImportAccountActivity {16 @get:Rule17 var rule = TruleskActivityRule(ImportActivity::class.java) {18 TestApp.testDatabase.balances.deleteAll()19 TestApp.testDatabase.addressBook.deleteAll()20 }21 @Test22 fun importShows() {23 onView(withId(R.id.password)).check(matches(isDisplayed()))24 onView(withId(R.id.account_name)).check(matches(isDisplayed()))25 onView(withId(R.id.key_content)).check(matches(isDisplayed()))26 rule.screenShot("import")27 }28 @Test29 fun happyPathWorks() {30 closeSoftKeyboard()31 onView(withId(R.id.fab)).perform(click())32 onView(withText(R.string.dialog_title_success)).check(matches(isDisplayed()))33 rule.screenShot("import_success")34 }35 @Test36 fun badPasswordIsRejected() {37 onView(withId(R.id.password)).perform(typeText("bad password"))38 closeSoftKeyboard()39 onView(withId(R.id.fab)).perform(click())40 onView(withText(R.string.dialog_title_error)).check(matches(isDisplayed()))41 rule.screenShot("import_bad_password")42 }43 @Test44 fun whenNoNameWasEnteredItDefaultsToImported() {45 closeSoftKeyboard()46 onView(withId(R.id.fab)).perform(click())47 val accountName = TestApp.testDatabase.addressBook.byAddress(TestApp.keyStore.import_result_address)?.name48 assertThat(accountName).isEqualTo("Imported")49 }50 @Test51 fun weCanChangeTheName() {52 onView(withId(R.id.account_name)).perform(typeText("new name"))53 closeSoftKeyboard()54 onView(withId(R.id.fab)).perform(click())55 val accountName = TestApp.testDatabase.addressBook.byAddress(TestApp.keyStore.import_result_address)?.name56 assertThat(accountName).isEqualTo("new name")57 }58}...

Full Screen

Full Screen

closeSoftKeyboard

Using AI Code Generation

copy

Full Screen

1closeSoftKeyboard();2openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());3openContextualActionModeOverflowMenu();4pressBack();5pressBackUnconditionally();6pressKey();7pressMenuKey();8pressMenuItemId();9pressBack();10pressBackUnconditionally();11pressKey();12pressMenuKey();13pressMenuItemId();14pressBack();15pressBackUnconditionally();16pressKey();17pressMenuKey();18pressMenuItemId();19pressBack();20pressBackUnconditionally();21pressKey();22pressMenuKey();

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.

Run Appium-espresso-driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful