rahul7386 / robotium

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

ClickOnView(solo.getView(id)) is not working on a widget layout #608

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Launched the Android application through automation script, and waits until 
the main activity is launched, clicks on a link for which an overlay appears
2. On this overlay I have tried almost everything to click on a element, using 
clickOnView, clickOnButtonById , clickLongOnText, clickOnButton, clickOnScreen, 
clickOnText, but nothing is working. Is there any issue with clicking on 
elements on overlay

I have also tried below code

LinearLayout submitBtn = (LinearLayout) solo.getView(id);
assertNotNull(submitBtn);
submitBtn.performClick();

and 

ImageButton imageButton = (ImageButton) solo.getView(R.id.x);
solo.clickOnView(imageButton);

but nothing works

What is the expected output? What do you see instead?

Should click but it is not clicking and instead searching for element by 
scrolling till the end

Used code solo.clickLongOnText("text", 1, false); to avoid scroll but this is 
also not identifying the element

What version of the product are you using? On what operating system?

Android 4.4.2 platform and emulator is Nexus 5

Please provide any additional information below.

Original issue reported on code.google.com by avanthir...@gmail.com on 21 May 2014 at 4:11

GoogleCodeExporter commented 9 years ago
I have tried with text view and id of the element but nothing works.

I cannot share the details of the application.

Original comment by avanthir...@gmail.com on 21 May 2014 at 4:14

GoogleCodeExporter commented 9 years ago
Thanks for reporting this issue. The problem your experiencing is due to the 
overlay opened not running in the same process as the start activity. Due to 
Android restrictions the tests is only allowed to interact with the app under 
test. Unfortunately there is no way around this. 

Original comment by renasr...@gmail.com on 21 May 2014 at 6:25

GoogleCodeExporter commented 9 years ago
But I'm able to view the element on that overlay using hierarchy viewer and can 
get the ID as well.

Please let me know if there is any particular click code for elements on 
overlay.

Thanks..

Original comment by avanthir...@gmail.com on 21 May 2014 at 10:07

GoogleCodeExporter commented 9 years ago
Its the same click methods everywhere. As long as the view belongs to the app 
under test the  View will be available to Robotium.

Original comment by renasr...@gmail.com on 21 May 2014 at 10:09

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Ok so the click does not fail. Please see:

Why do text and button clicks get wrong?

https://code.google.com/p/robotium/wiki/QuestionsAndAnswers

Original comment by renasr...@gmail.com on 21 May 2014 at 10:34

GoogleCodeExporter commented 9 years ago
<uses-sdk 
        android:minSdkVersion="8" 
        android:targetSdkVersion="19"/>

    <supports-screens android:anyDensity="true"/> 

Adding these two - Does not work. Please specify if we have any other 
workarounds for this?

Original comment by mfsi.abh...@gmail.com on 21 May 2014 at 11:15

GoogleCodeExporter commented 9 years ago
This needs to be added to the AndroidManifest.xml of the app under test.

Original comment by renasr...@gmail.com on 21 May 2014 at 11:17

GoogleCodeExporter commented 9 years ago
Tried adding the same to AndroidManifest.xml of the app under test. But this 
doesn't help

Original comment by avanthir...@gmail.com on 21 May 2014 at 11:37

GoogleCodeExporter commented 9 years ago
Would it be possible for you to share the apk?

Original comment by renasr...@gmail.com on 21 May 2014 at 11:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
:(

Original comment by avanthir...@gmail.com on 21 May 2014 at 11:40

GoogleCodeExporter commented 9 years ago
Anyways this issue has been solved , when clicked by index e.g: 
solo.clickOnView(solo.getView(TextView.class, 13)); 

Don't understand why passing the id does not work e.g: 
solo.clickOnView(solo.getView("id_of_the_element"));

Original comment by mfsi.abh...@gmail.com on 21 May 2014 at 12:58

GoogleCodeExporter commented 9 years ago
Great. If you use solo.getView(String name) it should only be the simple name 
and not the whole com.x.x.x. but "my_id".

Original comment by renasr...@gmail.com on 21 May 2014 at 12:59

GoogleCodeExporter commented 9 years ago
Yes, was trying with solo.getView("my_id") only,
Not with solo.getView("com.packageName.x:id/my_id");

Original comment by mfsi.abh...@gmail.com on 21 May 2014 at 2:07