AlertDialog is not getting launched properly(distorting app UI) when i am trying to launch it while doing Espresso test

妖精的绣舞 提交于 2021-01-29 15:00:22

问题


I am trying to test Alert dialog launch code on a fragment button click and as mentioned in the question title it is distorting up the UI whenever i run this test. the layout doesn't appear properly just some icons without the background of the Alertdialog box appears and no text is being displayed.

Here's the test:

    @Test
    fun mytest() {
        //on this click dialog should launch
        onView(withId(R.id.button)).perform(click())
        
        //below line verifies whether the dialog has been launched or not
        onView(withText(R.string.name)).check(matches(isDisplayed()))
    }

So please tell me what I am doing wrong here.

来源:https://stackoverflow.com/questions/63793127/alertdialog-is-not-getting-launched-properlydistorting-app-ui-when-i-am-trying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!