fl11081103wngcl / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

When using Solo.clickOnActionBarHomeButton, can't click on text on the NavigationDrawer #666

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use Solo.clickOnActionBarHomeButton to open the navigation drawer
2. Added a sleep for wait until is opened
3. Use Solo.clickOnText to click on one of the navigation items

What is the expected output? What do you see instead?
Don't find the text of the items that I'm trying to click. I tried searchText 
and waitForText, and also don't work to find a text on the NavigationDrawer.

What version of the product are you using? On what operating system?
Robotium 5.0.1. Android 4.X

Please provide any additional information below.

If I try to get the ImageView from the ActionBar directly using this code:
View view = Solo.getView(android.R.id.home);
Solo.clickOnView(view);

I can click on items in the navigation drawer. However, this solutions leads me 
to sometimes have SecurityException regarding not having the inject events 
permission.

What can I do to solve this problem?

Original issue reported on code.google.com by ban...@gmail.com on 3 Mar 2015 at 5:19

GoogleCodeExporter commented 9 years ago
The actionbar views are not text views and therefore you need to use getView() 
and then clickOnView() just as you do. Please update to Robotium 5.3.1 and the 
security exceptions will be gone. Let me know if it fixes the problem for you. 

Original comment by renasr...@gmail.com on 3 Mar 2015 at 5:25

GoogleCodeExporter commented 9 years ago
Thanks for your fast answer.

I was using the clickOnText on the navigation drawer items, not the action bar.

Yes, I will update then to the last version and check if the security exception 
is gone.

To tap on the 'hamburger' icon, should I use:
Solo.clickOnActionBarHomeButton
OR
View view = Solo.getView(android.R.id.home);
Solo.clickOnView(view);

seems the last one for your answer, however, the method 
clickOnActionBarHomeButton seems made for that?

Original comment by ban...@gmail.com on 3 Mar 2015 at 5:35

GoogleCodeExporter commented 9 years ago
Always use the ID. ClickOnActionBarHomeButton does not work on the support
library.

Original comment by renasr...@gmail.com on 3 Mar 2015 at 5:37

GoogleCodeExporter commented 9 years ago
Still have the same SecurityException (sometimes):
Failure in testDifferentFragmentsCanBeSelected:
junit.framework.AssertionFailedError: Click at (85.0, 147.0) can not be 
completed! (java.lang.SecurityException: Injecting to another application 
requires INJECT_EVENTS permission)
    at com.robotium.solo.Clicker.clickOnScreen(Clicker.java:106)
    at com.robotium.solo.Clicker.clickOnScreen(Clicker.java:205)
    at com.robotium.solo.Clicker.clickOnScreen(Clicker.java:170)
    at com.robotium.solo.Solo.clickOnView(Solo.java:1096)

This is the code:
final View homeView = solo.getView(android.R.id.home);
solo.clickOnView(homeView);
solo.sleep();

Do you have any idea what could be?

Original comment by ban...@gmail.com on 3 Mar 2015 at 9:35

GoogleCodeExporter commented 9 years ago
Security exceptions are thrown by the Android platform when trying to click on 
a View that belongs to another app. Is something blocking the view you are 
trying to click?

Original comment by renasr...@gmail.com on 3 Mar 2015 at 9:37

GoogleCodeExporter commented 9 years ago
No. I have the last screenshot and our app is the most front (no dialog). 
Already using Robotium 5.3.1

Original comment by ban...@gmail.com on 3 Mar 2015 at 9:42

GoogleCodeExporter commented 9 years ago
This is strange. Would it be possible for you to email me your apk?

Original comment by renasr...@gmail.com on 3 Mar 2015 at 9:43

GoogleCodeExporter commented 9 years ago
Hey,

Sorry for the late response.
Regarding the APK, can't provide the debug version. Or do you want a production 
version?

The problem still happens on 5.3.1 :(
The device is a Nexus 5 ART with 4.4.2.
Other devices seems more stable (Huawei Valiant Y301 A1 4.1.1 and Sony Experia 
P 4.0.4)

Thanks

Original comment by ban...@gmail.com on 9 Mar 2015 at 4:42