powered by simpleCommunicator - 2.0.49     © 2025 Programmizd 02
Форумы / Android [игнор отключен] [закрыт для гостей] / Espresso No views in hierarchy found matching
3 сообщений из 3, страница 1 из 1
Espresso No views in hierarchy found matching
    #39671898
nikomp
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Пишу UI тест с использованием библиотеки Espresso. Хочу проверить было ли показано Toast сообщение после загрузки фрагментов в активити. Делаю так

Код: java
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
@Rule
  public ActivityTestRule<StartActivity> activityRule = new ActivityTestRule(StartActivity
      .class);

  @Test
  public void checkToastDashboard() {
    CountingIdlingResource startActivityIdlingRes = activityRule.getActivity()
        .getEspressoIdlingResourceForMainActivity();

    Espresso.registerIdlingResources(startActivityIdlingRes);

    Espresso.onView(withText("Дашборды получены")).inRoot(withDecorView(not(is(activityRule
        .getActivity()
        .getWindow
        ().getDecorView())))).check(matches(isDisplayed()));

  }



Вижу в эмуляторе, что фрагмент загружен, появилось сообщение, но при этом тест валится с ошибкой:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with text: is "Дашборды получены"

View Hierarchy:
+>LinearLayout{id=-1, visibility=VISIBLE, width=335, height=129, has-focus=false, has-focusable=false, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=WM.LayoutParams{(0,63)(wrapxwrap) gr=#51 ty=2005 fl=#1000098 fmt=-3 wanim=0x1030004 colorMode=0}, tag=null, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=1}
|
+->AppCompatTextView{id=16908299, res-name=message, visibility=VISIBLE, width=209, height=51, has-focus=false, has-focusable=false, has-window-focus=false, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.LinearLayout$LayoutParams@2368897, tag=null, root-is-layout-requested=false, has-input-connection=false, x=63.0, y=39.0, text=SAVE TAG=2, input-type=0, ime-target=false, has-links=false}
|
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:1538)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:90)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.check(ViewInteraction.java:291)
at ru.bingosoft.androidmobileaccent.StartActivityTest.checkToastDashboard(StartActivityTest.java:43)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:433)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)

Пробовал даже переделать тест на поиск кнопки простой, и кнопка не находится в иерархии.
...
Рейтинг: 0 / 0
Espresso No views in hierarchy found matching
    #39671936
Фотография Джибс
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Потому как тост рисуется не в твоем окне.
...
Рейтинг: 0 / 0
Espresso No views in hierarchy found matching
    #39671954
nikomp
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Джибс, что значит не в моем окне? есть Активность, в которой динамически создаются фрагменты. В класс, который отвечает за создание фрагментов передается контекст Аквтиности. Тосты создаются с использованием этого контекста.

Я подозреваю, что проблема связана вот с этим, но поправить пока не получилось

https://stackoverflow.com/questions/38329114/espresso-checking-if-toasts-are-displayed-one-on-top-of-another
...
Рейтинг: 0 / 0
3 сообщений из 3, страница 1 из 1
Форумы / Android [игнор отключен] [закрыт для гостей] / Espresso No views in hierarchy found matching
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]