RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

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

Closed renas closed 9 years ago

renas commented 9 years ago

From avanthir...@gmail.com on May 20, 2014 21:11:09

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

  1. 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: http://code.google.com/p/robotium/issues/detail?id=608

renas commented 9 years ago

From avanthir...@gmail.com on May 20, 2014 21:14:00

I have tried with text view and id of the element but nothing works.

I cannot share the details of the application.

renas commented 9 years ago

From renasr...@gmail.com on May 20, 2014 23:25:05

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.

Status: Invalid
Owner: renasr...@gmail.com

renas commented 9 years ago

From avanthir...@gmail.com on May 21, 2014 03:07:46

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..

renas commented 9 years ago

From renasr...@gmail.com on May 21, 2014 03:09:22

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

renas commented 9 years ago

From renasr...@gmail.com on May 21, 2014 03:34:10

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

renas commented 9 years ago

From mfsi.abh...@gmail.com on May 21, 2014 04:15:25

<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?

renas commented 9 years ago

From renasr...@gmail.com on May 21, 2014 04:17:44

This needs to be added to the AndroidManifest.xml of the app under test.

renas commented 9 years ago

From avanthir...@gmail.com on May 21, 2014 04:37:41

Tried adding the same to AndroidManifest.xml of the app under test. But this doesn't help

renas commented 9 years ago

From renasr...@gmail.com on May 21, 2014 04:38:21

Would it be possible for you to share the apk?

renas commented 9 years ago

From avanthir...@gmail.com on May 21, 2014 04:40:32

:(

renas commented 9 years ago

From mfsi.abh...@gmail.com on May 21, 2014 05:58:21

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"));

renas commented 9 years ago

From renasr...@gmail.com on May 21, 2014 05:59:51

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".

renas commented 9 years ago

From mfsi.abh...@gmail.com on May 21, 2014 07:07:00

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