gpt4 book ai didi

Android espresso 测试在本地通过,但在 Firebase 测试实验室中失败

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:29:05 27 4
gpt4 key购买 nike

我对 android espresso 测试有疑问。测试在本地通过但在 FTL 上失败。这是简单的测试

onView(allOf(withId(R.id.text_supercategory_name), withText("Air conditioners"))).
check(matches(withText("Air conditioners")));

这个测试在本地通过。在 FTL 上我有错误:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: (with id: blablabla:id/text_product_verdict and with text: is "Air conditioners")

我不明白为什么我看到我的测试中没有使用的 ID id/text_product_verdict ......以及来自另一个 Activity 的这个ID ......测试 Activity 正确

@Rule
public ActivityTestRule<HomeActivity> mActivityTestRule = new ActivityTestRule<>(HomeActivity.class);

我查看了 FTL 测试失败的视频,在模拟器上看到了很多通知 img from FTL

我确定问题是来自 Google Hangouts 的粘性通知,并尝试使用 --no-auto-google-login 运行我的测试旗帜。但是得到相同的结果。与 onView(withText("Air conditioners")).check(matches(isDisplayed())); FTL 测试通过。

有人可以帮忙解决问题吗?

最佳答案

我也遇到过。在某些设备中,Firebase 测试实验室似乎无法识别 withId(R.id.text_supercategory_name) 处的 id。我们可以使用 res-name 代替。

检查日志中的 View 层次结构并使用 onView(withResourceName("res-name")).perform(click()); 获取 res-name

// change res-name to buttonPanel, button3, button2, or button1
+---->ScrollView{id=16908757, res-name=buttonPanel, visibility=VISIBLE, width=1008, height=217, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=1507.0, child-count=1}
|
+----->ButtonBarLayout{id=-1, visibility=VISIBLE, width=1008, height=217, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=4}
|
+------>AppCompatButton{id=16908315, res-name=button3, visibility=GONE, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, text=, input-type=0, ime-target=false, has-links=false}
|
+------>Space{id=16909293, res-name=spacer, visibility=INVISIBLE, width=429, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=42.0, y=203.0}
|
+------>AppCompatButton{id=16908314, res-name=button2, visibility=VISIBLE, width=271, height=189, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=471.0, y=14.0, text=Cancel, input-type=0, ime-target=false, has-links=false}
|
+------>AppCompatButton{id=16908313, res-name=button1, visibility=VISIBLE, width=224, height=189, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=742.0, y=14.0, text=OK, input-type=0, ime-target=false, has-links=false}

关于Android espresso 测试在本地通过,但在 Firebase 测试实验室中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46586542/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com