landryshuai / robotium

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

clickOnButton not working on some screens #560

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. I run a script on an application and it runs well. I use 
solo.clickOnButton(3); to click a button
2. I try to run the same script on a new version of the application but the 
action solo.clickOnButton(3); has no effects.

What is the expected output? What do you see instead?
I expect to see a popup after clicking on a button identified by its id-

What version of the product are you using? On what operating system?
I've this problems on Samsung S4 and other devices too. Android version is 4.2.2

Please provide any additional information below.
I think this problem could be related to the fact that these buttons are marked 
as NAF Button in UI Automator screen.
You can see a screenshot on this page: 
http://stackoverflow.com/questions/20358149/naf-nodes-automation-with-robotium

Original issue reported on code.google.com by flavioca...@gmail.com on 4 Dec 2013 at 10:51

GoogleCodeExporter commented 9 years ago
Is the layout the same as before? Can you click on the button by changing the 
index?

Original comment by renasr...@gmail.com on 4 Dec 2013 at 12:03

GoogleCodeExporter commented 9 years ago
Layout has changed but I can't click anymore on buttons using robotium.

Original comment by flavioca...@gmail.com on 4 Dec 2013 at 12:09

GoogleCodeExporter commented 9 years ago
You cant click on any of the buttons?

Original comment by renasr...@gmail.com on 4 Dec 2013 at 12:16

GoogleCodeExporter commented 9 years ago
If I use solo.clickOnButton(0), solo.clickOnButton(1), ... and so on, It 
doesn't click. The same button are marked as NAF Node on previous screens; i 
resolved adding in the code the attribute android:contentdescription but I 
can't solve the problem i wrote above with robotium. 

Original comment by flavioca...@gmail.com on 4 Dec 2013 at 12:22

GoogleCodeExporter commented 9 years ago
Would it be possible for you to share an app that exhibits this issue?

Original comment by renasr...@gmail.com on 4 Dec 2013 at 2:59

GoogleCodeExporter commented 9 years ago
I can't because I'm not the owner but I'm just working on it to evaluate 
benefit of automation :(

Original comment by flavioca...@gmail.com on 4 Dec 2013 at 3:02

GoogleCodeExporter commented 9 years ago
What if you use the one of the ID:s? solo.clickOnView(solo.getString(String 
id));

Original comment by renasr...@gmail.com on 5 Dec 2013 at 7:54

GoogleCodeExporter commented 9 years ago
I can use this command on button with label but I can't on button with just an 
image. Right? I need to click on accept button whose id is "accept_button" but 
it has no label.

Original comment by flavioca...@gmail.com on 5 Dec 2013 at 11:13

GoogleCodeExporter commented 9 years ago
You can use it on all views. The recommendation is to always use ID:s if
possible.

/Renas

Original comment by renasr...@gmail.com on 5 Dec 2013 at 11:15

GoogleCodeExporter commented 9 years ago
I'm trying with this: solo.clickOnButton(solo.getString("acceptbutton"));    
but it doesn't work.

This is the failure trace:
android.content.res.Resources$NotFoundException: String resource ID #0x0
at android.content.res.Resources.getText(Resources.java:1057)
at android.content.res.Resources.getString(Resources.java:1149)
at android.content.Context.getString(Context.java:332)
at com.jayway.android.robotium.solo.Getter.getString(Getter.java:81)
at com.jayway.android.robotium.solo.Getter.getString(Getter.java:99)
at com.jayway.android.robotium.solo.Solo.getString(Solo.java:2460)
at com.MWalletTest.TestApk.test_coupons_002(TestApk.java:208)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
5)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1698)

In the same screen there are more items with same id ("acceptbutton");

Original comment by flavioca...@gmail.com on 5 Dec 2013 at 11:25

GoogleCodeExporter commented 9 years ago
If you want I can share my desktop with TeamViewer so you can inspect both 
code, layouts and whatelse you think could be useful. 

Original comment by flavioca...@gmail.com on 5 Dec 2013 at 3:06

GoogleCodeExporter commented 9 years ago
I found a tip; button index has been scaled; even if I don't add other button 
to layout, now buttons have an higher index; so I can still see them.

Original comment by flavioca...@gmail.com on 9 Dec 2013 at 2:02

GoogleCodeExporter commented 9 years ago
The index is based on how many views of a kind that are available.

Original comment by renasr...@gmail.com on 22 Dec 2013 at 8:18