【发布时间】:2020-03-02 13:33:15
【问题描述】:
我使用 automator/espresso 测试来检查是否跟随网络链接并返回到应用程序:
@RunWith(AndroidJUnit4::class)
@SdkSuppress(minSdkVersion = 18)
class AboutApplicationActivityTest {
private lateinit var device: UiDevice
@Before
fun startMainActivityFromHomeScreen() {
device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
...
}
@Test
fun checkLink() {
val link: UiObject = device.findObject(UiSelector().resourceId("${BASIC_SAMPLE_PACKAGE}:id/link"))
link.click() // follow the link
/*
* How to check that the browser was open after
* clicking on the link? Which assertion can I use here?
*/
device.pressBack() // back to application
onView(withId(R.id.link))
.check(matches(isDisplayed())) // check return to application
}
}
点击链接后如何查看浏览器是否打开?我可以在这里使用哪个断言?
【问题讨论】:
标签: android kotlin android-espresso android-uiautomator