Skip to content Skip to sidebar Skip to footer

How To Check From Robotium That My Png Is Present On The Screen?

I create an additional method: public boolean exampleEdTxt1(){ try{ solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw); return true; } catch(Asserti

Solution 1:

try using .isShown()

solo.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw).isShown();

this assert i used to check if my image is displayed:

assertEquals(true, solo.getCurrentActivity().findViewById(R.id.getting_started_image_1).isShown());

hope it helps

Here i check for imageView

Boolean isVisible = (Boolean) solo.getCurrentActivity().findViewById(R.id.imageView1).isShown();
        assertTrue(isVisible);

Here is to check for drawable (image)

Boolean isVisible2 = (Boolean) solo.getCurrentActivity().getResources().getDrawable(R.drawable.image).isVisible();
        assertTrue(isVisible2);

imageView from the xml i used:

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="186dp"
    android:layout_height="90dp"
    android:src="@drawable/image" />

Solution 2:

For

Boolean isVisible2 = (Boolean) solo.getCurrentActivity().getResources().getDrawable(R.drawable.image).isVisible();

code

assertTrue(isVisible2);

always returns success (Even if there is no drawable on the screen) and code

assertFalse(isVisible2);

always returns fail.

Post a Comment for "How To Check From Robotium That My Png Is Present On The Screen?"