junit.framework.AssertionFailedError: View can not be clicked!

914 views
Skip to first unread message

Mathias Lin

unread,
Oct 11, 2010, 11:04:53 PM10/11/10
to Robotium Developers
I just got started with Robotium and tried a first very simple test,
but experience some problem which I can't explain / doesn't seem logic
to me.

I have a TabHost with a ActivityGroup and a toggle button on each
activity that's displayed in the tabhost content section. When I press
the toggle button, the tab content area changes to another activity
(mTabHost.setCurrentTab(Intent intent);). Every activity holds such a
toggle button, always with a label "Toggle". When I click the toggle
button on the seconds activity, it will switch back to the first (all
inside the tab content area).

|-----------------|
| TabHost | |
|-----------------|
| |
| Toggle-Button |
| |
| (Activities |
| change in here) |
| |
|-----------------|

Now, manually this all works fine, but the robotium test doesn't. When
I attempt to click the toggle button on the second activity, I get an
error message "junit.framework.AssertionFailedError: View can not be
clicked!"

This is my test - very simple and small:

solo.sleep(5000);
solo.waitForActivity("StartTabsActivity", 10000);

solo.clickOnButton("Toggle");
// this will swap the activity inside the tabhost content
section

solo.sleep(5000);
solo.waitForActivity("StatusListActivity", 5000);

solo.assertCurrentActivity("Expected StatusList activity",
"StatusListActivity");

LogUtils.logD("robotium: button label: " +
solo.getButton(1).getText());
// ... outputs: robotium: button label: Toggle

LogUtils.logD("robotium: button clickable: " +
solo.getButton(1).isClickable());
// ... outputs: robotium: button clickable: true

solo.clickOnButton("Toggle");
// ... throws: junit.framework.AssertionFailedError: View can
not be clicked!


What I don't understand here: I am checking that the button with
"Toggle" label exists and is clickable, nevertheless, I'm getting an
error saying "This view cannot be clicked.". And there's only one
"Toggle" button in the respective current activity.


Related to this question I have another minor one:
When I work with TabHost + ActivityGroup, will
"solo.getCurrentActivity()" always return the embedded activity of the
ActivityGroup, not the outer one? Can solo still access elements of
the outer activity though?
In my above case though, the toggle button is always part of the inner/
embedded activity - in case that matters here.

Renas Reda

unread,
Oct 12, 2010, 5:57:40 AM10/12/10
to Robotium Developers
Hi,

The problem here is that the buttons have the same name. The system
has not cleaned up the old button and so Robotium is trying to click
that one instead of the new one. This problem will be fixed in 1.8.0.

/Renas

Mathias Lin

unread,
Oct 12, 2010, 6:04:56 AM10/12/10
to Robotium Developers
Thanks Renas,
good to know.

So this is only related to ActivityGroups, right? If I have two
entirely separate activities with the same button label, would the
error also occur?

Mathias

chetan jain

unread,
Oct 12, 2010, 6:06:33 AM10/12/10
to robotium-...@googlegroups.com
Hi All,

I am facing the similar kind of problem..like
I am clicking an button  like (+)  that is an image view, i am able to click on the button and its getting expand, but problem is when i run it in a loop then next time it does not click on the button and says VIew can  not be clicked.

I am using the code as:  solo.clickOnView(imgbut1.get(1));

Please suggest me the solution.

Regards
Chetan


--
You received this message because you are subscribed to the Google Groups "Robotium Developers" group.
To post to this group, send email to robotium-...@googlegroups.com.
To unsubscribe from this group, send email to robotium-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotium-developers?hl=en.


Renas

unread,
Oct 12, 2010, 6:25:21 AM10/12/10
to robotium-...@googlegroups.com
No, because then the first one would get cleaned by the system. However this problem is solved now. Thanks for pointing it out.

/Renas

Renas

unread,
Oct 12, 2010, 6:36:20 AM10/12/10
to robotium-...@googlegroups.com
Hi Chetan,

This problem is fixed in the new release. It has to do with visible and non-visible views. The get(1) is an invincible view (after the first click) and therefore it can not be clicked. In 1.8.0 only the visible views are triggered in the getX(int index) and clickOn(int index) methods.

/Renas
Reply all
Reply to author
Forward
0 new messages