How to use withDecorView method of android.support.test.espresso.matcher.RootMatchers class

Best Appium-espresso-driver code snippet using android.support.test.espresso.matcher.RootMatchers.withDecorView

PendingDialogTest.kt

Source:PendingDialogTest.kt Github

copy

Full Screen

...26 it.showAlertDialog(message = "dialog1_3", priority = 1)27 }28 activityRule.scenario.onActivity {29 Espresso.onView(ViewMatchers.withId(android.R.id.message))30 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))31 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_3")))32 it.showAlertDialog(message = "dialog3_1", priority = 3)33 it.showAlertDialog(message = "dialog3_2", priority = 3)34 it.showAlertDialog(message = "dialog2_1", priority = 2)35 it.showAlertDialog(message = "dialog2_2", priority = 2)36 }37 activityRule.scenario.onActivity {38 Espresso.onView(ViewMatchers.withId(android.R.id.message))39 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))40 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_2")))41 Espresso.onView(ViewMatchers.withId(android.R.id.button1))42 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))43 .perform(ViewActions.click())44 }45 activityRule.scenario.onActivity {46 Espresso.onView(ViewMatchers.withId(android.R.id.message))47 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))48 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))49 Espresso.onView(ViewMatchers.withId(android.R.id.button1))50 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))51 .perform(ViewActions.click())52 }53 activityRule.scenario.onActivity {54 Espresso.onView(ViewMatchers.withId(android.R.id.message))55 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))56 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_2")))57 Espresso.onView(ViewMatchers.withId(android.R.id.button1))58 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))59 .perform(ViewActions.click())60 }61 activityRule.scenario.onActivity {62 Espresso.onView(ViewMatchers.withId(android.R.id.message))63 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))64 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_1")))65 Espresso.onView(ViewMatchers.withId(android.R.id.button1))66 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))67 .perform(ViewActions.click())68 }69 activityRule.scenario.onActivity {70 Espresso.onView(ViewMatchers.withId(android.R.id.message))71 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))72 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_3")))73 Espresso.onView(ViewMatchers.withId(android.R.id.button1))74 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))75 .perform(ViewActions.click())76 }77 activityRule.scenario.onActivity {78 Espresso.onView(ViewMatchers.withId(android.R.id.message))79 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))80 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_2")))81 Espresso.onView(ViewMatchers.withId(android.R.id.button1))82 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))83 .perform(ViewActions.click())84 }85 activityRule.scenario.onActivity {86 Espresso.onView(ViewMatchers.withId(android.R.id.message))87 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))88 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_1")))89 Espresso.onView(ViewMatchers.withId(android.R.id.button1))90 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))91 .perform(ViewActions.click())92 }93 activityRule.scenario.onActivity {94 assert(it.currentDialog == null)95 }96 }97 @Test98 fun multiPending_recreate() {99 activityRule.scenario.onActivity {100 assert(it.currentDialog == null)101 it.showAlertDialog(message = "dialog1_1", priority = 1)102 it.showAlertDialog(message = "dialog1_2", priority = 1)103 it.showAlertDialog(message = "dialog1_3", priority = 1)104 }105 activityRule.scenario.onActivity {106 Espresso.onView(ViewMatchers.withId(android.R.id.message))107 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))108 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_3")))109 it.showAlertDialog(message = "dialog3_1", priority = 3)110 it.showAlertDialog(message = "dialog3_2", priority = 3)111 it.showAlertDialog(message = "dialog2_1", priority = 2)112 it.showAlertDialog(message = "dialog2_2", priority = 2)113 }114 activityRule.scenario.onActivity {115 Espresso.onView(ViewMatchers.withId(android.R.id.message))116 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))117 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_2")))118 }119 activityRule.scenario.recreate()120 activityRule.scenario.onActivity {121 Espresso.onView(ViewMatchers.withId(android.R.id.message))122 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))123 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_2")))124 Espresso.onView(ViewMatchers.withId(android.R.id.button1))125 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))126 .perform(ViewActions.click())127 }128 activityRule.scenario.onActivity {129 Espresso.onView(ViewMatchers.withId(android.R.id.message))130 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))131 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))132 Espresso.onView(ViewMatchers.withId(android.R.id.button1))133 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))134 .perform(ViewActions.click())135 }136 activityRule.scenario.onActivity {137 Espresso.onView(ViewMatchers.withId(android.R.id.message))138 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))139 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_2")))140 Espresso.onView(ViewMatchers.withId(android.R.id.button1))141 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))142 .perform(ViewActions.click())143 }144 activityRule.scenario.onActivity {145 Espresso.onView(ViewMatchers.withId(android.R.id.message))146 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))147 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_1")))148 Espresso.onView(ViewMatchers.withId(android.R.id.button1))149 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))150 .perform(ViewActions.click())151 }152 activityRule.scenario.onActivity {153 Espresso.onView(ViewMatchers.withId(android.R.id.message))154 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))155 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_3")))156 Espresso.onView(ViewMatchers.withId(android.R.id.button1))157 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))158 .perform(ViewActions.click())159 }160 activityRule.scenario.onActivity {161 Espresso.onView(ViewMatchers.withId(android.R.id.message))162 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))163 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_2")))164 Espresso.onView(ViewMatchers.withId(android.R.id.button1))165 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))166 .perform(ViewActions.click())167 }168 activityRule.scenario.onActivity {169 Espresso.onView(ViewMatchers.withId(android.R.id.message))170 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))171 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_1")))172 Espresso.onView(ViewMatchers.withId(android.R.id.button1))173 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))174 .perform(ViewActions.click())175 }176 activityRule.scenario.onActivity {177 assert(it.currentDialog == null)178 }179 }180 @Test181 fun dropPendingDialogWhenDestroy() {182 activityRule.scenario.onActivity {183 it.showAlertDialog(message = "dialog1_1", priority = 1)184 it.showAlertDialog(message = "dialog2_1", priority = 2)185 it.showAlertDialog(message = "dialog3_1", priority = 3)186 }187 activityRule.scenario.onActivity {188 assert(getCurrentFragment(it)?.javaClass?.simpleName == TestFragment::class.java.simpleName)189 Espresso.onView(ViewMatchers.withId(android.R.id.message))190 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))191 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))192 it.supportFragmentManager.beginTransaction().add(R.id.container, TestFragment()).commit()193 }194 activityRule.scenario.onActivity {195 Espresso.onView(ViewMatchers.withId(android.R.id.message))196 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))197 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))198 it.supportFragmentManager.beginTransaction().add(R.id.container, SecondFragment()).addToBackStack(null).commit()199 }200 activityRule.scenario.onActivity {201 assert(getCurrentFragment(it)?.javaClass?.simpleName == SecondFragment::class.java.simpleName)202 Espresso.onView(ViewMatchers.withId(android.R.id.message))203 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))204 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))205 getCurrentFragment(it)?.run {206 showAlertDialog(message = "dialog2_1", priority = 1)207 showAlertDialog(message = "dialog2_2", priority = 2)208 showAlertDialog(message = "dialog2_3", priority = 3)209 }210 }211 activityRule.scenario.onActivity {212 Espresso.onView(ViewMatchers.withId(android.R.id.message))213 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))214 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_3")))215 it.supportFragmentManager.popBackStack()216 }217 activityRule.scenario.onActivity {218 assert(getCurrentFragment(it)?.javaClass?.simpleName == TestFragment::class.java.simpleName)219 assert(it.currentDialog != null)220 Espresso.onView(ViewMatchers.withId(android.R.id.message))221 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))222 .check(ViewAssertions.matches(ViewMatchers.withText("dialog3_1")))223 Espresso.onView(ViewMatchers.withId(android.R.id.button1))224 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))225 .perform(ViewActions.click())226 }227 activityRule.scenario.onActivity {228 Espresso.onView(ViewMatchers.withId(android.R.id.message))229 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))230 .check(ViewAssertions.matches(ViewMatchers.withText("dialog2_1")))231 Espresso.onView(ViewMatchers.withId(android.R.id.button1))232 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))233 .perform(ViewActions.click())234 }235 activityRule.scenario.onActivity {236 Espresso.onView(ViewMatchers.withId(android.R.id.message))237 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))238 .check(ViewAssertions.matches(ViewMatchers.withText("dialog1_1")))239 Espresso.onView(ViewMatchers.withId(android.R.id.button1))240 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))241 .perform(ViewActions.click())242 assert(it.currentDialog == null)243 }244 }245}...

Full Screen

Full Screen

SignUpTests.kt

Source:SignUpTests.kt Github

copy

Full Screen

...51 sleep(1000)52 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.click())53 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.typeText(password))54 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())55 Espresso.onView(ViewMatchers.withText("Enter email address!")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))56 }57 @Test58 fun blank_password() {59 val email = "newemail@gmail.com"60 val password = ""61 sleep(1000)62 mdevice.findObject(By.res("cs408.incubator","btn_signup")).click()63 sleep(1000)64 mdevice.findObject(By.res("cs408.incubator","email")).text = email65 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())66 Espresso.onView(ViewMatchers.withText("Enter password!")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))67 }68 @Test69 fun check_existing_user() {70 val email = "abca@abca.com"71 val password = "123456"72 sleep(1000)73 mdevice.findObject(By.res("cs408.incubator","btn_signup")).click()74 sleep(1000)75 mdevice.findObject(By.res("cs408.incubator","email")).text = email76 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.typeText(password))77 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())78 sleep(200)79 Espresso.onView(ViewMatchers.withText("Authentication failed. User Already Exists")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))80 }81 @Test82 fun invalid_email() {83 val email = "ab"84 val password = "123456"85 sleep(1000)86 mdevice.findObject(By.res("cs408.incubator","btn_signup")).click()87 sleep(1000)88 mdevice.findObject(By.res("cs408.incubator","email")).text = email89 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.typeText(password))90 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())91 Espresso.onView(ViewMatchers.withText("Authentication failed. Invalid Email Format")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))92 }93 @Test94 fun invalid_password() {95 val email = "abca@abca.com"96 val password = "12345"97 val errMsg = "Password too short, enter minimum 6 characters!"98 sleep(1000)99 mdevice.findObject(By.res("cs408.incubator","btn_signup")).click()100 sleep(1000)101 mdevice.findObject(By.res("cs408.incubator","email")).text = email102 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.typeText(password))103 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())104 Espresso.onView(ViewMatchers.withText(errMsg)).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))105 }106 @Test107 fun profile_creation() {108 val name = "@az"109 val email = "abcza"+nextInt()+"@gmail.com"110 val password = "123456"111 val errmsg = "Invalid Characters in Name"112 val errmsg2 = "Name cannot be empty!"113 sleep(1000)114 mdevice.findObject(By.res("cs408.incubator","btn_signup")).click()115 sleep(1000)116 mdevice.findObject(By.res("cs408.incubator","email")).text = email117 Espresso.onView(ViewMatchers.withId(R.id.password)).perform(ViewActions.typeText(password))118 Espresso.onView(ViewMatchers.withId(R.id.sign_up_button)).perform(ViewActions.click())119 sleep(1000)120 mdevice.findObject(By.res("cs408.incubator","dispName")).text = name121 mdevice.findObject(By.res("cs408.incubator","submitName")).click()122 Espresso.onView(ViewMatchers.withText(errmsg)).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))123 sleep(1000)124 mdevice.findObject(By.res("cs408.incubator","dispName")).text = "abcd"125 mdevice.findObject(By.res("cs408.incubator","submitName")).click()126 sleep(1000)127 Espresso.onView(withId(R.id.fab)).check(matches(isDisplayed()))128 Espresso.onView(ViewMatchers.withContentDescription("Navigate up")).perform(ViewActions.click())129 sleep(1000)130 Espresso.onView(ViewMatchers.withText("Profile")).perform(ViewActions.click())131 sleep(2000)132 Espresso.onView(withId(R.id.sign_out)).perform(ViewActions.click())133 }134}...

Full Screen

Full Screen

LockWindowFinishActivityTest.kt

Source:LockWindowFinishActivityTest.kt Github

copy

Full Screen

...26 }27 activityRule.scenario.onActivity {28 assert(it.currentDialog != null)29 Espresso.onView(ViewMatchers.withId(android.R.id.message))30 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))31 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))32 it.finish()33 assert(!it.isFinishing)34 Espresso.onView(ViewMatchers.withId(android.R.id.button1))35 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))36 .perform(ViewActions.click())37 assert(it.isFinishing)38 }39 }40 @Test41 fun activity_finishActivity_recreate() {42 activityRule.scenario.onActivity {43 assert(it.currentDialog == null)44 it.showAlertDialog(message = "first dialog", lockWindow = true)45 }46 activityRule.scenario.onActivity {47 assert(it.currentDialog != null)48 Espresso.onView(ViewMatchers.withId(android.R.id.message))49 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))50 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))51 it.finish()52 assert(!it.isFinishing)53 }54 activityRule.scenario.recreate()55 activityRule.scenario.onActivity {56 assert(it.currentDialog != null)57 Espresso.onView(ViewMatchers.withId(android.R.id.message))58 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))59 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))60 assert(!it.isFinishing)61 Espresso.onView(ViewMatchers.withId(android.R.id.button1))62 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))63 .perform(ViewActions.click())64 assert(it.isFinishing)65 }66 }67 @Test68 fun fragment_finishActivity() {69 activityRule.scenario.onActivity {70 assert(it.currentDialog == null)71 getCurrentFragment(it)?.run {72 showAlertDialog(message = "first dialog", lockWindow = true)73 }74 }75 activityRule.scenario.onActivity {76 assert(it.currentDialog != null)77 getCurrentFragment(it)?.run {78 Espresso.onView(ViewMatchers.withId(android.R.id.message))79 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))80 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))81 requireActivity().finish()82 assert(!it.isFinishing)83 Espresso.onView(ViewMatchers.withId(android.R.id.button1))84 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))85 .perform(ViewActions.click())86 assert(it.isFinishing)87 }88 }89 }90 @Test91 fun fragment_finishActivity_recreate() {92 activityRule.scenario.onActivity {93 assert(it.currentDialog == null)94 getCurrentFragment(it)?.run {95 showAlertDialog(message = "first dialog", lockWindow = true)96 }97 }98 activityRule.scenario.onActivity {99 assert(it.currentDialog != null)100 getCurrentFragment(it)?.run {101 Espresso.onView(ViewMatchers.withId(android.R.id.message))102 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))103 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))104 requireActivity().finish()105 assert(!it.isFinishing)106 }107 }108 activityRule.scenario.recreate()109 activityRule.scenario.onActivity {110 assert(it.currentDialog != null)111 getCurrentFragment(it)?.run {112 Espresso.onView(ViewMatchers.withId(android.R.id.message))113 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))114 .check(ViewAssertions.matches(ViewMatchers.withText("first dialog")))115 assert(!it.isFinishing)116 Espresso.onView(ViewMatchers.withId(android.R.id.button1))117 .inRoot(RootMatchers.withDecorView(Matchers.not(it.window.decorView)))118 .perform(ViewActions.click())119 assert(it.isFinishing)120 }121 }122 }123}...

Full Screen

Full Screen

CollaboratorTests.kt

Source:CollaboratorTests.kt Github

copy

Full Screen

...62 sleep(200)63 Espresso.onView(withText("abca@abca.com")).check(matches(isDisplayed()))64 Espresso.onView(withId(R.id.collabButton)).perform(click())65 Espresso.onView(withId(android.R.id.button1)).perform(click())66 Espresso.onView(withText("Collaborator email cannot be Empty!")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(matches(isDisplayed()))67 }68 @Test69 fun addInvalidEmail() {70 sleep(1000)71 Espresso.onView(withText(title)).perform(click())72 sleep(200)73 Espresso.onView(withText("abca@abca.com")).check(matches(isDisplayed()))74 Espresso.onView(withId(R.id.collabButton)).perform(click())75 mdevice.findObject(By.res("cs408.incubator","collabEmail")).text = "test"76 Espresso.onView(withId(android.R.id.button1)).perform(click())77 Espresso.onView(withText("Invalid Collaborator Email!")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(matches(isDisplayed()))78 }79 @Test80 fun addNonExistingUser() {81 sleep(1000)82 Espresso.onView(withText(title)).perform(click())83 sleep(200)84 Espresso.onView(withText("abca@abca.com")).check(matches(isDisplayed()))85 Espresso.onView(withId(R.id.collabButton)).perform(click())86 mdevice.findObject(By.res("cs408.incubator","collabEmail")).text = "xzyvzayv@abcd.com"87 Espresso.onView(withId(android.R.id.button1)).perform(click())88 Espresso.onView(withText("User Not Found")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(matches(isDisplayed()))89 }90 @Test91 fun removeCollaborator() {92 sleep(1000)93 Espresso.onView(withText(title)).perform(click())94 sleep(200)95 Espresso.onView(withId(R.id.collabButton)).perform(click())96 mdevice.findObject(By.res("cs408.incubator", "collabEmail")).text = "test@test.com"97 Espresso.onView(withId(android.R.id.button1)).perform(click())98 sleep(1000)99 Espresso.onView(withText("abca@abca.com")).check(matches(isDisplayed()))100 Espresso.onView(withText("test@test.com")).check(matches(isDisplayed())).perform(click())101 Espresso.onView(withId(android.R.id.button1)).perform(click())102 sleep(1000)103 Espresso.onView(withText("test@test.com")).check(doesNotExist())104 }105 @Test106 fun removeSelf() {107 sleep(1000)108 Espresso.onView(withText(title)).perform(click())109 sleep(200)110 Espresso.onView(withId(R.id.collabButton)).perform(click())111 mdevice.findObject(By.res("cs408.incubator", "collabEmail")).text = "test@test.com"112 Espresso.onView(withId(android.R.id.button1)).perform(click())113 sleep(1000)114 Espresso.onView(withText("abca@abca.com")).check(matches(isDisplayed())).perform(click())115 Espresso.onView(withText("Delete Idea to remove yourself as collaborator")).inRoot(RootMatchers.withDecorView(IsNot.not(rule.activity.window.decorView))).check(matches(isDisplayed()))116 }117}...

Full Screen

Full Screen

UILoginTest.kt

Source:UILoginTest.kt Github

copy

Full Screen

...50 //druk direct op aanmelden51 onView(withId(R.id.button_login_confirm)).perform(click())52 //kijk empty fields toast53 onView(withText(R.string.warning_empty_fields)).inRoot(54 RootMatchers.withDecorView(55 CoreMatchers.not(56 CoreMatchers.`is`(57 mActivityTestRule.activity.window.decorView58 )59 )60 )61 ).check(matches(isDisplayed()))62 }63 @Test64 fun login_usernameFieldsEmpty_showToastEmptyFields() {65 //vul password in66 onView(withId(R.id.text_login_password)).perform(ViewActions.typeText(password))67 android.support.test.espresso.Espresso.closeSoftKeyboard()68 //druk op aanmelden69 onView(withId(R.id.button_login_confirm)).perform(click())70 //kijk empty fields toast71 onView(withText(R.string.warning_empty_fields)).inRoot(72 RootMatchers.withDecorView(73 CoreMatchers.not(74 CoreMatchers.`is`(75 mActivityTestRule.activity.window.decorView76 )77 )78 )79 ).check(matches(isDisplayed()))80 }81 @Test82 fun login_passwordFieldsEmpty_showToastEmptyFields() {83 //vul username in84 onView(withId(R.id.text_login_username)).perform(ViewActions.typeText(username))85 android.support.test.espresso.Espresso.closeSoftKeyboard()86 //druk op aanmelden87 onView(withId(R.id.button_login_confirm)).perform(click())88 //kijk empty fields toast89 onView(withText(R.string.warning_empty_fields)).inRoot(90 RootMatchers.withDecorView(91 CoreMatchers.not(92 CoreMatchers.`is`(93 mActivityTestRule.activity.window.decorView94 )95 )96 )97 ).check(matches(isDisplayed()))98 }99 @Test100 fun login_correctInfo_logInWithUsername_userLogsIn() {101 //vul username in102 onView(withId(R.id.text_login_username)).perform(ViewActions.typeText(username))103 android.support.test.espresso.Espresso.closeSoftKeyboard()104 //vul password in...

Full Screen

Full Screen

TeamsTest.kt

Source:TeamsTest.kt Github

copy

Full Screen

...56 Thread.sleep(7000)57 onView(ViewMatchers.withId(add_to_favorite)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))58 onView(ViewMatchers.withId(add_to_favorite)).perform(ViewActions.click())59 onView(ViewMatchers.withText("Added to Favorite"))60 .inRoot(RootMatchers.withDecorView(Matchers.not(activityRule.activity.window.decorView)))61 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))62 Thread.sleep(4000)63 onView(ViewMatchers.withId(add_to_favorite)).perform(ViewActions.click())64 onView(ViewMatchers.withText("Removed to Favorite"))65 .inRoot(RootMatchers.withDecorView(Matchers.not(activityRule.activity.window.decorView)))66 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))67 Thread.sleep(4000)68 onView(ViewMatchers.withId(add_to_favorite)).perform(ViewActions.click())69 onView(ViewMatchers.withText("Added to Favorite"))70 .inRoot(RootMatchers.withDecorView(Matchers.not(activityRule.activity.window.decorView)))71 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))72 Thread.sleep(4000)73 onView(ViewMatchers.withContentDescription(R.string.abc_action_bar_up_description)).perform(ViewActions.click())74 onView(ViewMatchers.withId(bottom_navigation)).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))75 onView(ViewMatchers.withId(favorites)).perform(ViewActions.click())76 Thread.sleep(2000)77 onView(ViewMatchers.withText("TEAMS")).perform(ViewActions.click())78 onView(Matchers.allOf(ViewMatchers.withId(rv_favorite), ViewMatchers.isDisplayed())).check(ViewAssertions.matches(ViewMatchers.isDisplayed()))79 onView(Matchers.allOf(ViewMatchers.withId(rv_favorite), ViewMatchers.isDisplayed())).perform(RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(0, ViewActions.click()))80 Thread.sleep(6000)81 onView(ViewMatchers.withId(add_to_favorite)).perform(ViewActions.click())82 onView(ViewMatchers.withText("Removed to Favorite"))83 .inRoot(RootMatchers.withDecorView(CoreMatchers.not(activityRule.activity.window.decorView)))84 .check(matches(isDisplayed()))85 onView(ViewMatchers.withContentDescription(R.string.abc_action_bar_up_description)).perform(ViewActions.click())86 }87}...

Full Screen

Full Screen

RemoveExistingUserTest.kt

Source:RemoveExistingUserTest.kt Github

copy

Full Screen

...5import android.support.test.espresso.assertion.ViewAssertions6import android.support.test.espresso.assertion.ViewAssertions.matches7import android.support.test.espresso.matcher.RootMatchers8import android.support.test.espresso.matcher.RootMatchers.isDialog9import android.support.test.espresso.matcher.RootMatchers.withDecorView10import android.support.test.espresso.matcher.ViewMatchers.*11import android.support.test.rule.ActivityTestRule12import android.support.test.runner.AndroidJUnit413import android.support.v7.widget.RecyclerView14import com.komnacki.sportresultstracker.R15import com.komnacki.sportresultstracker.funtional.Utils.TestUtils16import com.komnacki.sportresultstracker.usersActivity.UsersListActivity17import org.hamcrest.core.IsNot18import org.junit.Before19import org.junit.Rule20import org.junit.Test21import org.junit.runner.RunWith22@RunWith(AndroidJUnit4::class)23class RemoveExistingUserTest {24 private lateinit var stringToBetyped: String25 @get:Rule26 var activityRule: ActivityTestRule<UsersListActivity> = ActivityTestRule(UsersListActivity::class.java)27 @Before28 fun initValidString() {29 // Specify a valid string.30 stringToBetyped = "Espresso"31 }32 @Test33 fun testIfAddNewUserDialogAppear() {34 var listCount = 035 onView(withId(R.id.rv_usersList)).check { view, noViewFoundException ->36 listCount = TestUtils.getSizeOfRecyclerView(view as RecyclerView)37 }38 while (listCount > 0) {39 onView(withId(R.id.item_usersList_btn_delete)).perform(click())40 onView(withText("Delete user"))41 .inRoot(RootMatchers.withDecorView(IsNot.not(activityRule.activity.window.decorView)))42 .check(ViewAssertions.matches(isDisplayed()))43 onView(withId(android.R.id.button1))44 .perform(click())45 onView(withId(R.id.rv_usersList)).check { view, noViewFoundException ->46 listCount = TestUtils.getSizeOfRecyclerView(view as RecyclerView)47 }48 }49 onView(withId(R.id.fab)).perform(click())50 Thread.sleep(TestUtils.timeIntervalMillis)51 onView(withText("Add new user"))52 .check(matches(isDisplayed()))53 Thread.sleep(TestUtils.timeIntervalMillis)54 onView(withId(R.id.tv_input_user))55 .inRoot(isDialog())56 .check(matches(isDisplayed()))57 .perform(click())58 .perform(typeTextIntoFocusedView(TestUtils.userName))59 Thread.sleep(TestUtils.timeIntervalMillis)60 onView(withId(android.R.id.button1))61 .perform(click())62 Thread.sleep(TestUtils.timeIntervalMillis)63 onView(withId(R.id.item_usersList_btn_delete)).perform(click())64 Thread.sleep(TestUtils.timeIntervalMillis)65 onView(withText("Delete user"))66 .inRoot(withDecorView(IsNot.not(activityRule.activity.window.decorView)))67 .check(matches(isDisplayed()))68 Thread.sleep(TestUtils.timeIntervalMillis)69 onView(withId(android.R.id.button1))70 .perform(click())71 Thread.sleep(TestUtils.timeIntervalMillis)72 onView(withId(R.id.ic_empty_usersList))73 .check(matches(isDisplayed()))74 }75}...

Full Screen

Full Screen

Util.kt

Source:Util.kt Github

copy

Full Screen

...7import org.hamcrest.CoreMatchers8import org.hamcrest.Matchers9fun checkWithToast(activity: Activity, expectedString: Int) {10 Espresso.onView(ViewMatchers.withText(expectedString))11 .inRoot(RootMatchers.withDecorView(CoreMatchers.not(Matchers.`is`(activity.window.decorView))))12 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))13}14fun checkWithToast(activity: Activity, expectedString: String) {15 Espresso.onView(ViewMatchers.withText(expectedString))16 .inRoot(RootMatchers.withDecorView(CoreMatchers.not(Matchers.`is`(activity.window.decorView))))17 .check(ViewAssertions.matches(ViewMatchers.isDisplayed()))18}...

Full Screen

Full Screen

withDecorView

Using AI Code Generation

copy

Full Screen

1ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))2ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))3ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))4ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))5ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))6ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))7ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))8ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))9ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))10ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))11ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))12ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))13ViewMatchers.withDecorView(Matchers.not(Matchers.is(activity.getWindow().getDecorView())))

Full Screen

Full Screen

withDecorView

Using AI Code Generation

copy

Full Screen

1public void testToastMessage() {2 onView(withId(R.id.button)).perform(click());3 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));4}5public void testToastMessage() {6 onView(withId(R.id.button)).perform(click());7 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));8}9public void testToastMessage() {10 onView(withId(R.id.button)).perform(click());11 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));12}13public void testToastMessage() {14 onView(withId(R.id.button)).perform(click());15 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));16}17public void testToastMessage() {18 onView(withId(R.id.button)).perform(click());19 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));20}21public void testToastMessage() {22 onView(withId(R.id.button)).perform(click());23 onView(withText("Hello World!")).inRoot(withDecorView(not(mActivityRule.getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));24}

Full Screen

Full Screen

withDecorView

Using AI Code Generation

copy

Full Screen

1public static Matcher<Root> isToast() {2 return new TypeSafeMatcher<Root>() {3 public void describeTo(Description description) {4 description.appendText("is toast");5 }6 public boolean matchesSafely(Root root) {7 int type = root.getWindowLayoutParams().get().type;8 if ((type == WindowManager.LayoutParams.TYPE_TOAST)) {9 final View view = root.getDecorView();10 if (view != null) {11 final WindowManager.LayoutParams params = (WindowManager.LayoutParams) view.getLayoutParams();12 if (params != null) {13 if (params.getPackageName().equals("android")) {14 return true;15 }16 }17 }18 }19 return false;20 }21 };22}23public static Matcher<Root> isSystemAlertWindow() {24 return new TypeSafeMatcher<Root>() {25 public void describeTo(Description description) {26 description.appendText("is system alert window");27 }28 public boolean matchesSafely(Root root) {29 int type = root.getWindowLayoutParams().get().type;30 if ((type == WindowManager.LayoutParams.TYPE_SYSTEM_ALERT)) {31 final View view = root.getDecorView();32 if (view != null) {33 final WindowManager.LayoutParams params = (WindowManager.LayoutParams) view.getLayoutParams();34 if (params != null) {35 if (params.getPackageName().equals("android")) {36 return true;37 }38 }39 }40 }41 return false;42 }43 };44}45public static Matcher<Root> isSystemOverlays() {46 return new TypeSafeMatcher<Root>() {47 public void describeTo(Description description) {48 description.appendText("is system overlays");49 }

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