How to check from Robotium that my png is present on the screen?

0
0

I create an additional method:

public boolean exampleEdTxt1(){
try{
solo
.getCurrentActivity().getResources().getDrawable(R.drawable.action_drw);
return true;
}
catch(AssertionError e){
return false;
}
}

But, when test is runing, code

assertTrue(exampleEdTxt1());

always returns success and code

assertFalse(exampleEdTxt1());

always returns fail.

How to check from Robotium that my png is present on the screen?

  • You must to post comments
0
0

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" />
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website