Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Cómo verificar que la notificación emergente NO se muestra. Café exprés

Tengo notificación emergente. Mi primera prueba verifica si se muestra esa notificación y pasa con éxito. Yo uso el siguiente método para esta prueba:

 fun viewInNotificationPopupIsDisplayed(viewMatcher: Matcher<View>) { onView(viewMatcher) .inRoot(RootMatchers.isPlatformPopup()) .check(ViewAssertions.matches(isDisplayed())) }

Tengo un problema con el segundo caso de prueba en el que tengo que verificar que mi notificación emergente ya haya desaparecido (significa que ya no se muestra). Así que estoy tratando de usar el siguiente método:

 fun viewInNotificationPopupIsNotDisplayed(viewMatcher: Matcher<View>) { Espresso.onView(viewMatcher) .inRoot(RootMatchers.isPlatformPopup()) .check(matches(not(isDisplayed()))) //.check(ViewAssertions.doesNotExist()) // doesn't work as well }

Obtengo la siguiente excepción:

 android.support.test.espresso.NoMatchingRootException: Matcher 'with decor view of type PopupWindow$PopupViewContainer' did not match any of the following roots: [Root{application-window-token=android.view.ViewRootImpl$W@bb8371e, window-token=android.view.ViewRootImpl$W@bb8371e, has-window-focus=true,

Por favor, ¿alguien puede ayudar con esto?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Parece que una verificación tan simple es imposible con espresso si tiene una PopupWindow debido a la forma en que se lanza la NoMatchingRootException

Puede capturar la excepción y completar la prueba, pero esa no es una buena opción, ya que lanzar y capturar NoMatchingRootException consume mucho tiempo en comparación con el caso de prueba predeterminado. Parece que Espresso está esperando la Raíz por un tiempo

Para este caso, se sugiere renunciar al espresso aquí y usar UiAutomator para esta afirmación.

 val device: UiDevice get() = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) fun assertPopupIsNotDisplayed() { device.waitForIdle() assertFalse(device.hasObject(By.text(yourText)))) } fun assertPopupIsDisplayed() { device.waitForIdle() assertTrue(device.hasObject(By.text(yourText)))) }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!