0

I am testing a Gallery application of android 4.0.3 using monkeyrunner with androidviewclient and when I am trying click on any album with touch() function of AVC it is selecting the album . It should open a album. My code for opening a album is

   MonkeyRunner.sleep(3)
   vc=ViewClient(device,serialNo)
   firstAlbum = vc.findViewById('id/no_id/1')
   firstAlbum.touch(MonkeyDevice.DOWN_AND_UP)

please let me know if i am doing something wrong?

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
NRP
  • 13
  • 3

1 Answers1

0

It's very unlikely that your album has uniqueId 'id/no_id/1'. You can verify it using dump.py. If I run dump.py --uniqueId on 4.0.3 Gallery I obtain

 com.android.internal.policy.impl.PhoneWindow$DecorView NO_ID None id/no_id/1
   android.widget.LinearLayout NO_ID None id/no_id/2
      android.view.ViewStub id/action_mode_bar_stub None id/action_mode_bar_stub
      android.widget.FrameLayout NO_ID None id/no_id/3
         android.widget.TextView id/title Gallery id/title
      android.widget.FrameLayout id/content None id/content
         android.widget.RelativeLayout id/root None id/root
            android.widget.GridView id/albums None id/albums
               android.widget.LinearLayout NO_ID None id/no_id/4
                  com.android.camera.GalleryPickerItem id/thumbnail None id/thumbnail
                  android.widget.TextView id/title All pictures (3) id/title/1
               android.widget.LinearLayout NO_ID None id/no_id/5
                  com.android.camera.GalleryPickerItem id/thumbnail None id/thumbnail/1
                  android.widget.TextView id/title Download (3) id/title/2

so, I guess you want the first album, then I would use:

vc = ViewClient(*ViewClient.connectToDeviceOrExit())
firstAlbum = vc.findViewWithTextOrRaise(re.compile('All pictures \(\d+\)'))
firstAlbum.touch()

or (as oneliner):

ViewClient(*ViewClient.connectToDeviceOrExit()).findViewWithTextOrRaise(re.compile('All pictures \(\d+\)')).touch()

using a regular expression you can select the album, the one with All pictures title independently of the number of pictures listed in the title.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
  • Thanks for reply but issue is not with the view ID, issue is with the touch() method, when I am using touch(UP), touch is not working , for touch(DOWN) it's select the album and when I am using touch(DOWN_AND_UP) it's doing the same thing select the album, it should open the album. BDW I'got the solution for opening the album you can find it here http://stackoverflow.com/questions/13660496/device-touch-is-not-working-properly-for-gallery-application – NRP Dec 14 '12 at 08:56
  • I don't understand what's your problem with opening the albums. See this precise example at https://github.com/dtmilano/AndroidViewClient/blob/master/AndroidViewClient/examples/gallery-select-album.py – Diego Torres Milano Dec 14 '12 at 16:00
  • Actually I don't want to select the album I want to open the album so for opening the album I am using the touch() command, but it's working as long tap my album got selected. I hope you've checked the link http://stackoverflow.com/questions/13660496/device-touch-is-not-working-properly-for-gallery-application – NRP Dec 15 '12 at 12:55
  • I'm running the example and see how the album opens. Can you explain exactly what you are expecting and what do you mean by "open"? – Diego Torres Milano Dec 16 '12 at 09:40
  • Hey milano thanks for your reply but your example is not working in my gallery app. and "Open" means touch on any album should display the content of the albums. – NRP Dec 18 '12 at 10:07
  • Same issue with the emulator. – NRP Dec 20 '12 at 13:45
  • Please add some screenshots of what you expect and what you obtain – Diego Torres Milano Dec 20 '12 at 21:31
  • Sorry Dtmilano but I can not upload the Screenshots as I don't have enough reputation too upload images. I need 20 to upload the images. – NRP Dec 24 '12 at 10:36
  • Use flickr, picasa, dropbox, google drive, wahtever, then link the images. – Diego Torres Milano Dec 28 '12 at 04:23