sangmingming / robotium

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

Not able to click on menu option #61

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.In my contact application->launch the contacts list view.
2.Calling str = "^Create contact$", solo.clickOnMenuItem(str);
3.

What is the expected output? What do you see instead?
Should be able to click on the menu item

What version of the product are you using? On what operating system?
Robotium2.1 on froyo

Please provide any additional information below.
Previously able to click on the menu item in robotium 2.0 and 1.9

Original issue reported on code.google.com by anandpai...@gmail.com on 1 Feb 2011 at 5:48

GoogleCodeExporter commented 9 years ago
Only this menu option is not getting clicked.

But if i build with old robotium jar files 2.0. and 1.9.0 then it is working 
fine.

Original comment by anandpai...@gmail.com on 1 Feb 2011 at 6:18

GoogleCodeExporter commented 9 years ago
Where does it click then? Does clickOnMenuItem() work for the other menu items?

Original comment by renasr...@gmail.com on 1 Feb 2011 at 9:37

GoogleCodeExporter commented 9 years ago
it is launching the menu but not clicking on the item passed but for other 
items it is able to click.

If i build with robotium older versions 2.0 and 1.9.0 this is working.

Original comment by anandpai...@gmail.com on 1 Feb 2011 at 10:20

GoogleCodeExporter commented 9 years ago
What happens if you do the following:

solo.sendKey(Solo.MENU);
ArrayList<TextView> textViews = solo.getCurrentTextViews();

for(TextView textView : textViews)
Log.d("Robotium", "textView.getText");

Does the log print out the Create contact text view?

Original comment by renasr...@gmail.com on 1 Feb 2011 at 2:03

GoogleCodeExporter commented 9 years ago
Please check the log for which i have debugged the problem.

02-02 15:11:00.900: DEBUG/ContactsListActivity(788): Inside onCreateOptionsMenu 
fucntion
02-02 15:11:03.089: WARN/KeyCharacterMap(788): No keyboard for id 0
02-02 15:11:03.089: WARN/KeyCharacterMap(788): Using default keymap: 
/system/usr/keychars/qwerty.kcm.bin
02-02 15:11:03.140: INFO/createNewContactFromMenu(788): value: ^Create contact$
02-02 15:11:17.209: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Dialer
02-02 15:11:17.209: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Call log
02-02 15:11:17.236: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Contacts
02-02 15:11:17.236: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Favorites
02-02 15:11:17.240: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: 
02-02 15:11:17.240: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Please input number or name
02-02 15:11:17.240: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Please wait...
02-02 15:11:17.240: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: 
02-02 15:11:17.240: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: 
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Create contact
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: 
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Displaying 8 contacts
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Anand Huawei
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: A
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Anand Tagore
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Jayanth Test
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: J
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Jest123
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: You don't have any contacts to display.
02-02 15:11:17.250: DEBUG/Robotium(788): To add contacts, press Menu and touch:
02-02 15:11:17.250: DEBUG/Robotium(788): Accounts to add or configure an 
account with contacts you can sync to the phone
02-02 15:11:17.250: DEBUG/Robotium(788): Create contact to create a new contact 
from scratch
02-02 15:11:17.250: DEBUG/Robotium(788): Manage contacts to copy contacts from 
SIM card or restore from SD card.
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Uninstall some applications
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Retry upgrade
02-02 15:11:17.250: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Search
02-02 15:11:17.269: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Create contact
02-02 15:11:17.269: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Display options
02-02 15:11:17.269: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Accounts
02-02 15:11:17.269: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Multi-select
02-02 15:11:17.269: DEBUG/Robotium(788): xxxxxxxxxxxxxxxxxxxxxx not found. Have 
found: Manage contacts
02-02 15:11:18.023: INFO/ActivityManager(68): Starting activity: Intent { 
act=android.intent.action.MAIN cat=[android.intent.category.HOME] 
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher }
02-02 15:11:19.150: WARN/InputManagerService(68): Window already focused, 
ignoring focus gain of: 
com.android.internal.view.IInputMethodClient$Stub$Proxy@43eb0ff0
02-02 15:11:19.819: DEBUG/CommApplication(788): phoneIsCdma() ---> Entered
02-02 15:11:19.838: INFO/CommApplication(788): This is CDMA phone = false
02-02 15:11:19.850: DEBUG/TwelveKeyDialer(788): Cleared all digits
02-02 15:11:21.160: INFO/CommApplication(788): exit CommApplication 2
02-02 15:11:21.799: WARN/WindowManager(68): Permission denied: injecting key 
event from pid 788 uid 10009 to window Window{43f45040 
com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 
10010
02-02 15:11:22.588: WARN/WindowManager(68): Permission denied: injecting key 
event from pid 788 uid 10009 to window Window{43f45040 
com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 
10010
02-02 15:11:23.219: WARN/WindowManager(68): Permission denied: injecting key 
event from pid 788 uid 10009 to window Window{43f45040 
com.android.launcher/com.android.launcher2.Launcher paused=false} owned by uid 
10010
02-02 15:11:23.418: INFO/TestRunner(788): failed: 
test_TC_SNS_C_NewCon_01_01(com.huawei.test.scripts.SmokeTestCases)
02-02 15:11:23.418: INFO/TestRunner(788): ----- begin exception -----
02-02 15:11:23.508: INFO/TestRunner(788): junit.framework.AssertionFailedError: 
The text: xxxxxxxxxxxxxxxxxxxxxx is not found!
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.Assert.fail(Assert.java:47)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.Assert.assertTrue(Assert.java:20)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
com.jayway.android.robotium.solo.Clicker.clickOnText(Clicker.java:282)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
com.jayway.android.robotium.solo.Clicker.clickOnMenuItem(Clicker.java:200)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
com.jayway.android.robotium.solo.Solo.clickOnMenuItem(Solo.java:695)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
com.huawei.test.framework.Contacts.createNewContactFromMenu(Contacts.java:56)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
com.huawei.test.scripts.SmokeTestCases.test_TC_SNS_C_NewCon_01_01(SmokeTestCases
.java:226)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
java.lang.reflect.Method.invokeNative(Native Method)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
java.lang.reflect.Method.invoke(Method.java:521)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:186)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.TestCase.runBare(TestCase.java:127)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.TestResult$1.protect(TestResult.java:106)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.TestResult.runProtected(TestResult.java:124)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.TestResult.run(TestResult.java:109)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
junit.framework.TestCase.run(TestCase.java:118)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
0)
02-02 15:11:23.508: INFO/TestRunner(788):     at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
02-02 15:11:23.508: INFO/TestRunner(788): ----- end exception -----

Original comment by anandpai...@gmail.com on 2 Feb 2011 at 9:42

GoogleCodeExporter commented 9 years ago
This the code written:

solo.sendKey(Solo.MENU);
        String actual = "^Create contact$";
        solo.sendKey(Solo.MENU);
        CommonUtils.logI("createNewContactFromMenu", "value: "+actual);
        solo.clickOnMenuItem(actual);
        solo.clickOnMenuItem("xxxxxxxxxxxxxxxxxxxxxx");

Original comment by anandpai...@gmail.com on 2 Feb 2011 at 9:44

GoogleCodeExporter commented 9 years ago
With same piece of code i am able to run with robotium 1.9.0 and 2.0 versions 
please the log and above sample code written.

Original comment by anandpai...@gmail.com on 2 Feb 2011 at 9:45

GoogleCodeExporter commented 9 years ago
What if you replace clickOnMenuItem(actual); with clickOnMenuItem(actual, 
false); ?

Original comment by renasr...@gmail.com on 2 Feb 2011 at 5:12

GoogleCodeExporter commented 9 years ago
Still it is not able to click on it.

More over this application cannot be shared as per our company policies.

You can please try base froyo contacts.

Original comment by anandpai...@gmail.com on 3 Feb 2011 at 11:38

GoogleCodeExporter commented 9 years ago
This seems to be a timing issue. I will contact you and give you a release 
candidate of the new version so that you can verify if the issue has been 
corrected or not.

Original comment by renasr...@gmail.com on 3 Feb 2011 at 1:58

GoogleCodeExporter commented 9 years ago
Hi renes,

     I apologize for the delay as i was out of the station.
     I have tried with your new apk - "robotium-solo-2.1.1-SNAPSHOT.jar", but the issue still remains as it is,it is still reproducable with this jar file also.

With regards,
Anand

Original comment by anandpai...@gmail.com on 19 Feb 2011 at 9:46

GoogleCodeExporter commented 9 years ago
This issue has been fixed in Robotium 2.2.

Original comment by renasr...@gmail.com on 21 Feb 2011 at 6:00

GoogleCodeExporter commented 9 years ago
Hopefully this problem has been fixed in Robotium 2.2. If it is still not 
working for you please use pressMenuItem() instead.

Original comment by renasr...@gmail.com on 21 Feb 2011 at 6:01

GoogleCodeExporter commented 9 years ago
Renes and others,

I am still facing issues with clickOnMenuItem as well as pressMenuItem with the 
robotium 2.2 jar file.  It seems to me the that timing issue is still not 
resolved at least using eclipse and emulators.  The menu appears to close 
before the menu item is found to press on.
I use solo.sendKey(Solo.Menu) pop-up the menu.  Is there a way to keep it up 
longer?

Jeff

Original comment by jeffbyer...@gmail.com on 25 May 2011 at 3:54

GoogleCodeExporter commented 9 years ago
I can not reproduce that. Would it be possible for you to share your 
application or another application that reproduces this behavior?

Original comment by renasr...@gmail.com on 26 May 2011 at 7:31

GoogleCodeExporter commented 9 years ago
My robotium test code is:

    public void checkSettings(Solo solo, int i, Activity act){
        signIn(solo, loginDetails);
        solo.sendKey(Solo.MENU);
        //solo.waitForActivity("Settings",20000);
        //solo.clickOnButton("Settings"); 
        solo.pressMenuItem(3);

I can see the memu pops up with Settings and Help on the bottom row with Get 
Paid and History on top.
The pop-up menu only stays open for perhaps 2 seconds then closes.

I use virtual device 2.2 for API level 8 and 2.3.3 for API level 10

Regards,
Jeff

Original comment by jeffbyer...@gmail.com on 26 May 2011 at 9:22

GoogleCodeExporter commented 9 years ago
When the menu closing withing 2 secs, I see from adb logcat
W/InputManagerService(   58): Window already focused, ignoring focus gain of: 
com.android.internal.view.IInputMethodClient$Stub$Proxy@44028e28

Original comment by jeffbyer...@gmail.com on 27 May 2011 at 2:35

GoogleCodeExporter commented 9 years ago
You need to remove solo.sendKey(Solo.MENU); as pressMenuItem/clickOnMenuItem 
already does that for you. Unfortunately there is no way to know if the menu is 
up or not so that logic can not be added to the above methods.

Original comment by renasr...@gmail.com on 27 May 2011 at 5:29

GoogleCodeExporter commented 9 years ago
Removing solo.sendKey(Solo.MENU) worked.

Thank you

Original comment by jeffbyer...@gmail.com on 27 May 2011 at 4:46

GoogleCodeExporter commented 9 years ago
I was having similar issue. I just added

 solo.waitForText("Menu item") 
before 
solo.clickOnMenuItem("Menu item")

It worked for me.Looks like a timing issue. I was using 2.1

Original comment by akhil....@gmail.com on 19 Oct 2011 at 1:13