简体   繁体   中英

Android & Robotium - Testing that a fragment shows up?

In my android application (Tablet) I want to verify that after selecting a button the fragment appears on the screen. Is there a way to do this?

You can get a instance of the FragmentManager in your test since you have access to the activity. You can then either find the fragment by id or by tag and test that it is visible using the fragment method "isVisible" and assert that is set to true.

The javadoc for Fragment.isVisible() states Return true if the fragment is currently visible to the user. This means the fragment has been added, has its view attached to the window, and is not hidden.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM