tag:blogger.com,1999:blog-25456655.post6253017763115647849..comments2024-02-09T11:53:32.369-05:00Comments on Diego Torres Milano's blog: monkeyrunner: interacting with the ViewsDiego Torres Milanohttp://www.blogger.com/profile/12030778501784140349noreply@blogger.comBlogger85125tag:blogger.com,1999:blog-25456655.post-16501648165802832332013-02-14T01:04:05.277-05:002013-02-14T01:04:05.277-05:00Hi,
I have a scroll window, i need to find a part...Hi,<br /><br />I have a scroll window, i need to find a particular text and click on it so i did this..<br /><br /><br /> tv = self.vc.findViewWithText(text)<br /> <br /> MonkeyRunner.sleep(10.0)<br /> <br /> if tv:<br /> print tv<br /> self.ApplyTouch(tv,text)<br /> <br /> else:<br /> self.device.drag((400,600), (300, 200), 0.01, 120)<br /> MonkeyRunner.sleep(5)<br /> self.vc.dump()<br /> tv = self.vc.findViewWithText(text)<br /> if tv:<br /> print tv<br /> self.ApplyTouch(tv,text)<br /><br /> else:<br /> self.device.drag((400,600), (300, 200), 0.01, 120)<br /> MonkeyRunner.sleep(5)<br /> self.vc.dump()<br /> tv = self.vc.findViewWithText(text)<br /> if tv:<br /> print tv<br /> self.ApplyTouch(tv,text)<br /> else:<br /> print >>sys.stderr, "TextView %s not found,May be not downloaded yet" % text<br /><br /><br /><br />This works fine. But that scroll window is dynamic it may require 2-5 more scrolls to go through to find that text. And it may increase in future as well. so can i replace above code with something else so that it should scroll through the list automatically.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-83497760692583790302013-01-03T02:23:00.060-05:002013-01-03T02:23:00.060-05:00Thanks Diego. It worked...And next time will post ...Thanks Diego. It worked...And next time will post on particular threads..Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-40104163193710966102013-01-03T00:30:49.987-05:002013-01-03T00:30:49.987-05:00@Manasa Muchchatti,
You dind't provide much in...@Manasa Muchchatti,<br />You dind't provide much information about your problem (i.e. source code) but I think I can guess.<br /><br />After dragging you have to capture the new screen content again using ViewClient.dump():<br /><br />drag(...)<br />sleep(...)<br /><b>vc.dump()</b><br />vc.findViewById(...)<br /><br /><br />Also, please take a look at this post: http://dtmilano.blogspot.com/2012/10/androidviewclient-google-pages.html.<br />I would really appreciate if you place your AndroidViewClient comments there as they are much easier to handle.Diego Torres Milanohttps://www.blogger.com/profile/12030778501784140349noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-48751371303142093052013-01-02T04:46:03.189-05:002013-01-02T04:46:03.189-05:00hI..
I'm able to find a text view and get its...hI..<br /><br />I'm able to find a text view and get its co-ordinate and touch it if view is present in 1st page/screen.<br /><br />If it couldnt find that text in that page/screen, it should scroll to next page/screen. Hence i gave a device.drag() method(which worked fine). But is not able to identify that text. Hence throws error that text is not found.<br /><br />Why i'm not able to find and touch a text after scroll.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-70214754369378936552012-12-16T04:57:45.847-05:002012-12-16T04:57:45.847-05:00Whenever I use vc=ViewClient(device) Error Comes
T...Whenever I use vc=ViewClient(device) Error Comes<br />TypeError: _init_() takes at least 3 arguments(2 given).<br />What am I doing wrongBlog_Rohithttps://www.blogger.com/profile/04523711891197239800noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-48281535641070844982012-11-29T10:58:50.636-05:002012-11-29T10:58:50.636-05:00@Deepak,
These lines are taken from AndroidViewCli...@Deepak,<br />These lines are taken from <a href="http://dtmilano.blogspot.ca/2012/11/androidviewclient-uiautomator-support.html" rel="nofollow">AndroidViewClient: UiAutomator support</a>. They show how you can use text and even regular expressions to find the Views:<br /><br />for t in [re.compile('Button 1 .*'), re.compile('Button 2 .*'), 'Button with ID']:<br /> try:<br /> vc.findViewWithTextOrRaise(t).touch()<br /> except ViewNotFoundException:<br /> print >>sys.stderr, "Couldn't find button with text=", t<br /><br />This works independently of the backend version used (ViewServer, UiAutomator).Diego Torres Milanohttps://www.blogger.com/profile/12030778501784140349noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-77302436337691359942012-11-29T05:14:21.744-05:002012-11-29T05:14:21.744-05:00Diego,
Is it possible to detect or press a partic...Diego,<br /><br />Is it possible to detect or press a particular button or frame using the findviewbytext or View.mText, if so please provide us with a sample code.<br />We dont have access to ID values.. <br />Thanks in advance !!<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-82485297961839198572012-11-23T02:39:55.501-05:002012-11-23T02:39:55.501-05:00You need to add the module to path variable. As yo...You need to add the module to path variable. As you have done for monkeyrunner and other modules.Ashwani Kumarhttps://www.blogger.com/profile/05703851854131695993noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-81318160627235363282012-11-23T02:04:04.666-05:002012-11-23T02:04:04.666-05:00i am importing-
"from com.dtmilano.android.vi...i am importing-<br />"from com.dtmilano.android.viewclient import ViewClient" in a script.I have set ANDROID_VIEW_CLIENT_HOME.It works fine when i am running the script as main script,but if i import the script in another script,then it says NO module named dtmilano!i just dont get why,Help?<br /><br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-56147905375494959752012-10-15T08:27:38.330-04:002012-10-15T08:27:38.330-04:00@Ashwani,
i am trying to touch the seekbar to seek...@Ashwani,<br />i am trying to touch the seekbar to seek the video and it is not happening with the Keycode-"KEYCODE_MEDIA_FAST_FORWARD" using the device.press(Keycode, MonkeyDevice.DOWN_AND_UP)) function,right now what i ve done is i am using the drag(co-ordinates of the seekbar) function,using which i am able to seek the video.But that would be a very hardcoded way to do it.So,i want to touch the seekbar in a generic way,probably using androidviewclient ,if possible<br /><br />Also,where is this sendKeyEvent() func?is it in monkeyrunner or what?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-47942843041306151802012-10-15T08:22:51.805-04:002012-10-15T08:22:51.805-04:00Also,i want to know why i cant touch the views whe...Also,i want to know why i cant touch the views when the video is being played,but only when it is paused??Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-63575791685606914292012-10-15T08:20:52.366-04:002012-10-15T08:20:52.366-04:00This comment has been removed by the author.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-53139572766696177652012-10-15T07:46:24.045-04:002012-10-15T07:46:24.045-04:00You can do this without AndroidViewClient. You can...You can do this without AndroidViewClient. You can use sendKeyEvents(KEYCODE) or sendRepeatedKeyEvents(value, KEYCODE, value, KEYCODE)Ashwani Kumarhttps://www.blogger.com/profile/05703851854131695993noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-31322537677885192362012-10-15T07:43:02.059-04:002012-10-15T07:43:02.059-04:00i am playing a video on my android target,i want t...i am playing a video on my android target,i want to touch the views while the video is being played,but that is not happening,i can only touch the views only when the player is paused.can anybody please suggest anything here?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-46391358428063890472012-10-15T05:06:57.404-04:002012-10-15T05:06:57.404-04:00This comment has been removed by the author.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-64943638993780760762012-10-15T05:04:42.204-04:002012-10-15T05:04:42.204-04:00This comment has been removed by the author.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-19048523846510233342012-10-10T17:17:52.164-04:002012-10-10T17:17:52.164-04:00@Prachi Bhagat,
Some of the documentation can be f...@Prachi Bhagat,<br />Some of the documentation can be found<br /><a href="http://dtmilano.blogspot.com/search/label/AndroidViewClient" rel="nofollow">Searching for label AndroidViewClient</a>.<br /><br />The examples provided in the source distribution also show a lot of aspects of AVC usage.Diego Torres Milanohttps://www.blogger.com/profile/12030778501784140349noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-82645078006830628582012-10-10T03:50:15.846-04:002012-10-10T03:50:15.846-04:00Thanks!its works when run with monkeyrunner.Where ...Thanks!its works when run with monkeyrunner.Where can i get a documentation/tutorial of androidviewclient to start with?it would be of great help!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-68713782269925256762012-10-05T01:59:42.466-04:002012-10-05T01:59:42.466-04:00Hi Prachi,
As Diego mentioned you have to run mon...Hi Prachi, <br />As Diego mentioned you have to run monkeyrunner as your pyhton interpreter. You can do that using following command:<br />monkeyrunner help.py <br />for more information refer to following link:<br />http://developer.android.com/tools/help/monkeyrunner_concepts.htmlAshwani Kumarhttps://www.blogger.com/profile/05703851854131695993noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-46719404943306726592012-10-04T11:51:24.033-04:002012-10-04T11:51:24.033-04:00I guess the error
ImportError: No module named jav...I guess the error<br /><b>ImportError: No module named java</b><br />comes from executing the scripts with python and not monkeyrunner.Diego Torres Milanohttps://www.blogger.com/profile/12030778501784140349noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-36641789609165342482012-10-04T09:08:14.692-04:002012-10-04T09:08:14.692-04:00I am not using any IDE.I am invoking the script fr...I am not using any IDE.I am invoking the script from shell (python scriptname.py).java version "1.6.0_22" is installed on my machine.i have set ANDROID_JAVA_HOME to /usr/bin/java..is that right?Also,i have set ANDROID_VIEW_CLIENT_HOME to pathtomyhome/pythonmods/dtmilano-AndroidViewClient-579227f/dtmilano-AndroidViewClient-579227f/AndroidViewClient<br />This is the script i am running-<br />import re<br />import sys<br />import os<br />try:<br />sys.path.append(os.path.join(os.environ['ANDROID_VIEW_CLIENT_HOME'], 'src'))<br />print sys.path<br />except:<br />pass<br /><br />from com.dtmilano.android.viewclient import ViewClient, View<br /><br />after running this test script i get this -<br />File "pathtomyhome/pythonmods/dtmilano-AndroidViewClient-579227f/dtmilano-AndroidViewClient-579227f/AndroidViewClient/src/com/dtmilano/android/viewclient.py", line 27, in<br />import java<br />ImportError: No module named javaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-51510805646928621362012-10-04T09:05:28.676-04:002012-10-04T09:05:28.676-04:00This comment has been removed by the author.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-88287782508786239562012-10-04T08:35:44.086-04:002012-10-04T08:35:44.086-04:00Is java installed on your machine. try running &qu...Is java installed on your machine. try running "java -version" from shell. If it displays version information that mean java is installed. You also need to check the Java path is set properly i.e. JAVA_HOME. If problem still persists please send complete error log that will help me analyze the error.<br />Also, i would also like to know how you are executing your python code?<br />Are you using any IDE?<br />Ashwani Kumarhttps://www.blogger.com/profile/05703851854131695993noreply@blogger.comtag:blogger.com,1999:blog-25456655.post-59396545954549810482012-10-04T08:25:08.787-04:002012-10-04T08:25:08.787-04:00i have already DONE THAT if you read my post.MY IS...i have already DONE THAT if you read my post.MY ISSUE IS THAT it is giving me error no module named java.what should be done about that?where n how do i get the module javaAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-25456655.post-44208266804918949862012-10-04T06:42:15.995-04:002012-10-04T06:42:15.995-04:00Just extract AndroidViewClient and set the classpa...Just extract AndroidViewClient and set the classpaths to the root directory of AndroidViewClient. To use Android view client you have to run monkeyrunner from android SDK in shell to execute python files.Ashwani Kumarhttps://www.blogger.com/profile/05703851854131695993noreply@blogger.com