Saturday 14 November 2020

Espresso: Not able to launch inner fragment

I am using launchFragmentInContainer<FragmentOne>() to launch fragment and able to perform actions using EspressoMatchers, it's all working fine.

But the issue comes when I want to launch another fragment onClick Of button(this code is inside FragmentOne) but while launching getting an error for FragmentTwo

Example:

onClick {

val fragment = FragmentTwo.newInstance()
        val transaction = requireActivity().supportFragmentManager.beginTransaction()
        transaction.add(fragmentContainerID, fragment)
        transaction.commit()

}

Above code giving error java.lang.IllegalArgumentException: No view found for id 0x4d2 (unknown) for fragment FragmentTwo{bc39d06} (6f4636b5-f441-4e38-956a-47ac91d261bc) id=0x4d2}

How to resolve this inside fragment? or I have to do something in espresso test.



from Espresso: Not able to launch inner fragment

No comments:

Post a Comment