如何调试UIAutomator脚本与Eclipse [英] How do I debug UIAutomator scripts with Eclipse

查看:427
本文介绍了如何调试UIAutomator脚本与Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我所看到的,当一个UIAutomator脚本编译成一个JAR文件,它就会通过亚行的shell命令来运行。我可以看到,有是等待一个调试器启动前连接,但我怎么连这个从Eclipse中的调试器,所以我可以调试我的用户界面的Automator脚本调试-e命令行选项?

From what I can see, when a UIAutomator script is compiled into a jar file and it gets run by using the adb shell command. I can see that there is a -e debug command line option which waits for a debugger to connect before starting but how do I connect this to the debugger from Eclipse so I can debug my UI Automator script?

推荐答案

我的工作了。这个过程是一个小长篇大论,但它的作品!

I've worked it out. The process is a little long winded but it works!

这里的关键是了解如何使用的Dalvik调试监视器服务器(DDMS)和理解远程调试与Java和Eclipse。简言之遵循以下步骤:

The key to this is understanding how to use the Dalvik Debug Monitor Server (DDMS) and understanding remote debugging with Java and Eclipse. In brief follow the following steps:

  1. 设置了DDMS透视图在Eclipse中点击窗口>打开透视图>其他...> DDMS 。您应该看到在设备选项卡中列出您的设备,假设你有一个模拟器/设备的运行。
  2. 设置了远程调试配置。要做到这一点去运行>调试配置 ...
  3. 右键从左侧面板中点击远程Java应用程序,然后单击新建创建一个新的配置。
  4. 在连接属性使用localhost和端口8700。对我来说,我使用的是在我的本地开发机器上运行的模拟器。对于DDMS默认端口是8700。如果这不是你的设置,你可以检查哪些端口需要可以从DDMS角度UI的Automator脚本运行后,在调试模式下的情况。 (参见步骤7-9下面)
  5. 确保您所选择的项目是,你将运行UI自动化项目。在源选项卡中,您还可以添加UI自动化项目,也有。 (不知道这是强制与否)
  6. 单击应用,然后关闭。
  7. 现在,我们将开始运行使用下面的命令行调试选项的用户界面的Automator脚本。在我的例子,命令(全部在一行):

  1. Set up a DDMS perspective in Eclipse by clicking Window > Open Perspective > Other... > DDMS. You should see your device listed in the Devices tab, assuming you have an emulator/device running.
  2. Set up a remote debugging configuration. To do this go to Run > Debug Configurations...
  3. Right click on Remote Java Application from the left hand panel and click 'New' to create a new configuration.
  4. In the connection properties use localhost and port 8700. In my case I am using an emulator that is running on my local development machine. The default port for DDMS is 8700. If this is not the case for your setup you can check what port needs to be from the DDMS perspective after the UI Automator script is run in debug mode. (See steps 7-9 below)
  5. Ensure that the project you've selected is the UI Automation project that you will be running. In the "Source" tab you may also add the UI Automation project there also. (Not sure if this is mandatory or not)
  6. Click "Apply" and then close.
  7. Now we will start running the UI Automator script with the debug option using the command line. For my example the command is (all on one line):

亚行外壳uiautomator的runTest AndroidUIAutomation.jar -c com.example.uiautomation.TestUiAutomation -e调试真正

adb shell uiautomator runtest AndroidUIAutomation.jar -c com.example.uiautomation.TestUiAutomation -e debug true

然后,它会说:

发送等待块

在Eclipse中进入DDMS透视图。在设备选项卡,你会看到一个红色的小错误符号的过程。下一步,这将是一个问号。在该表中的最后一列会有两个端口号如八千七百分之八千六百〇二。端口8700是一个你将你的远程调试会话连接。这是应该在上面的步骤4中进行配置。

In Eclipse go into the DDMS perspective. Under the Devices tab you should see a process with a little red bug symbol. Next to it will be a question mark. In the last column in the table there will be two port numbers such as 8602/8700. The port 8700 is the one you will connect your remote debugging session to. This is what should be configured in step 4 above.

现在你就可以开始远程调试。在UI的Automator脚本的地方设置一个断点。然后,通过将运行&GT调试;调试配置 ...,然后选择您之前创建的远程Java应用程序配置,然后单击调试。

Now you are ready to start remote debugging. Set a breakpoint somewhere in the UI Automator script. Then debug by going to Run > Debug Configurations... and then select the Remote Java Application configuration that you created earlier and then click on "Debug".

如果一切顺利的话,那么你应该能够调试您的用户界面的Automator脚本!

If everything has gone well, then you should be able to debug your UI Automator script!

这篇关于如何调试UIAutomator脚本与Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆