gpt4 book ai didi

android - Espresso 单击 Textview 中的特定子字符串

转载 作者:行者123 更新时间:2023-12-05 00:13:55 24 4
gpt4 key购买 nike

我有一个包含 TextView 的布局,如下所示,它将在文本 block 中包含一些自动生成的链接。当用户单击链接时,会打开一个包含相关信息的窗口。

screenshot of app

但是,我完全不知道如何让 Espresso 点击链接。已经尝试过类似

的多种变体

匹配(withText(containsString(“45”)))

但这要么不起作用,要么让 Espresso 只需点击文本框本身,而这不会执行任何操作。

有什么办法吗?在 Espresso 的限制范围内甚至有可能吗?

最佳答案

您可以使用 openLinkWithText(String linkText)

Returns an action that opens a link matching the given link text and uri matchers. The action is performed by invoking the link's onClick method (as opposed to actually issuing a click on the screen).

这是一个如何使用它的例子:

Espresso.onView(ViewMatchers
.withId(R.id.your_text_view_id))
.perform(ViewActions.openLinkWithText("45"));

引用文献:espresso-recipes-for-android

关于android - Espresso 单击 Textview 中的特定子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54394167/

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