安卓系统上的远程 JS 调试 Remote JavaScript Debugging on Android

每当在 Android 移动设备上调试网页时,开发人员往往都会不自觉陷入调试的泥潭中去。《Android开发指南》提供了一个解决方案,却有点繁琐复杂。因此,许多 Web 开发人员会倾向于使用类似 Firefox Firebug 的或像 WebKit 的 Web Inspector 之类的工具进行调试,因为它们的确容易使用,而且功能强大。不过,即使开发人员使用了这些工具,但又有另外一个问题,就是调试的结果与最终设备上显示的完全不同。对此,我们决定去创建一套属于自己的解决方案——就是,根据 Android 团队所提出标准解决方案,衍生出来的这么一个工具——而实际上却又要简单得多的工具。我们称它为“RemoteJS”,RemoteJS 允许您调试真正运行在 Android 设备中 JavaScript 代码,或者说,就是一个在你工作站上所运行的仿真器。

Developers often run into debugging hurdles when testing web pages for Android mobile devices. And, while the Android Developers Guide provides a solution, it’s a bit cumbersome and complex. So, many web developers often turn to tools like Firefox’s Firebug or Webkit’s Web Inspector because they are easy to use, powerful, and convenient. However, what developers often find when using these tools is that the end result is quite different on the actual device. We decided to create our own solution — a tool based on the standard solution proposed by the Android team, but much simpler to use. We call it RemoteJS, a tool that enables you to debug your JavaScript code while running on an Android device or emulator from your workstation.

Build RemoteJS

构建 RemoteJS 程序是一个相当直截了当的过程。首先,请确认您已安装了 Qt 框架。然后,在Sencha 实验室源码库全新的“Android 工具”那里下载我们 RemoteJS 源代码。构建桌面应用程序如下:

Building the application is a fairly straight forward process. First, confirm that you haveQt framework installed. Then, download the RemoteJS source code from our brand new Android Tools repository on Sencha Labs.Build the desktop application as follows:

[plain] view plaincopy
  1. git clone git://github.com/senchalabs/android-tools.git  
  2. cd android-tools/remotejs/src/desktop  
  3. qmake && make   

接着需要做的的就是安装 Android SDK,将设备联入计算机(或启动你的模拟器)。下面的截图是位于模拟器旁边一个的 RemoteJS 工具,用来检测来自Sencha Touch 的例子:

Next, all you need to do is install the Android SDK, plug your device in (or launch your emulator), and you’re ready to go. Here’s a screenshot of the RemoteJS tool running next to an emulator, inspecting anexample from Sencha Touch:


该程序会自动安装一个包,包的名字与设备上的名称相同。这个工具,实际上是代替 Android 浏览器的网页加载器。由于两款程序都是使用同一款的 Web 浏览器引擎,所以从程序员角度看,不需要顾忌那些一致性的担心。用于正是这两个应用程序相同。欲了解工作原理及实施细则,请参阅自述文件。只需在控制台上输入 URL 就可以打开网址。如果你输入不包括开头的协议,就默认是“www”的。如果你连接超过一个以上的设备,您将会在一个列表中作出选择。同样,当您断开连接的设备时它会侦测这一事件,然后它会回落到刚才唯一连接着的设备。然后等待直到你再次连接下一个设备。请注意,要输出一些内容,你需要使用console.log。

The program automatically installs a package with the same name on the device.  This tool will actually be the one loading your page, instead of the Android browser.  This doesn’t represent any concern from the developer’s perspective, since the web engine component that is used is exactly the same on both applications. For further details on how it works and the implementation details, please refer to theREADME. To open a specific URL, just enter it on the console.  If you don’t include the protocol, only addresses starting with “www” will be validated.  If you have more than one attached device, you’ll be presented with a list to choose from.  Similarly, it will detect when you disconnect the device already being used.  It will then fall back to the only attached device left, if that’s the case, or wait until you connect one again. Please note that in order to actually get some output back, you need to make use of console.log.

编写远程调试的脚本 Scriptable Remote Debugging

我们认为,既然 GUI 版本的工作那么好,于是我们可以写类似而且无缝的东西。主要目标是,充分利用 Python 中已选择实现的语言自动化页回归测试。为此,写一个Android 调试桥(Android Debug BridgeADB)的 Python 模块,便可以非常灵活地从您的主机上写脚本。自然,一个 RemoteJS 外壳版本,也写在 adb 模块的顶部。它侦听 stdin 输入的 JavaScript 命令然后输出结果到 stdout。这里马上就有一个例子,调试另一个Sencha Touch 的例子:

We thought that since the GUI version worked so well, we could write something similar that would run headlessly.  The main goal was to automate page regression tests, taking full advantage of Python, the chosen implementation language.  For that, anAndroid Debug Bridge (adb)Python module was written, which allows for very flexible scripting from your host. Naturally, a shell version of RemoteJS was also written on top of the adb module.  It listens for JavaScript commands on stdin and output results to stdout.  Here’s the tool in action, debugging another Sencha Touch example:


未来 Coming Up

源代码不断在变化,我们计划为这些工具注入更多的功能。欢迎你以任何方式参与贡献。adb Python模块,将有可能远程自动注射设备上记录的事件,并可在任何时候进行截图。这将使线性的自动检查一致性成为可能。所以敬请关注,并不妨 clone 我们公共库上的Android 工具包然后亲自试一试。所有可用都遵循 MIT 许可。

The source code is changing constantly, and we plan to extend the capabilities of these tools.  You’re more than welcome to contribute in any way. With the adb Python module, it will be possible to remotely automate the injection of recorded events on the device and grab screenshots at any point.  This will allow automated verification of behavior consistency along time. Stay tuned and please feel free to clone our android-tools public repository to play around with the tools and code.  All is available under the MIT license.


REFERENCES:http://blog.csdn.net/zhangxin09/article/details/7069583

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/449768.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

js关于表单校验完善

<!DOCTYPE html><html> <head> <meta charset"UTF-8"> <title>注册页面</title> <style type"text/css"> .left{ width: 100px; …

Python高效编程技巧

摘要&#xff1a;作者有多年的Python编程经验&#xff0c;并且有很多的编程小技巧和知识&#xff0c;其中大多数是通过阅读很流行的开源软件&#xff0c;如Django, Flask, Requests中获得的。 我已经使用Python编程有多年了&#xff0c;即使今天我仍然惊奇于这种语言所能让代码…

quartz 任务调试 建表 sql 语句、create table语句

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到教程。 DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS; DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS; DROP TABLE IF EXISTS QRTZ_SCHEDUL…

关于ttk的使用与安装

ttk是tkinter中的子模块&#xff0c;在python2.x中是作为独立模块。但是在python3.x中则是成为了tkinter的子模块&#xff0c;因此调用时&#xff0c;转变为 from Tkinter import ttk

SEO艺术

SEO艺术 编辑推荐 在本书中&#xff0c;四位搜索引擎优化&#xff08;SEO&#xff09;领域最受瞩目的专家阐述了制订以及执行一个完善的SEO策略时应遵循的一些实用指南与最新技术。 基本信息 原书名&#xff1a; The Art of SEO原出版社&#xff1a; OReilly作者&#xff1a; (…

ActiveMQ支持的传输协议

连接到ActiveMQ Connector:ActiveMQ提供的&#xff0c;用来实现连接通信的功能。包括:client-to-broker、broker-to-broker。ActiveMQ允许客户端使用多种协议来进行连接。 client-to-broker模式一般是配置文件中的transportConnector配置 broker-to-broker:一般是指网络(networ…

http状态码301和302详解及区别

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到教程。 一直对http状态码301和302的理解比较模糊&#xff0c;在遇到实际的问题和翻阅各种资料了解后&#xff0c;算是有了一定的理解。这里记录下…

哪些编程语言需要修复?

摘要&#xff1a;编程语言有十全十美的吗&#xff1f;每种语言都有缺陷吗&#xff1f;这不&#xff0c;Java、C、C、Python都中枪了。语言之间也可相互“掐架”&#xff0c;一起来看下。 原文作者Kevin Kelleher采用一种比较新颖的方式来比较编程语言&#xff1a;即描述每个编程…

时间修改,学习

设定时间格式 import datetime print datetime.datetime.now().strftime("%Y-%m-%d %H:%M") # 2018-05-08 16:54 时间增加 import datetime print (datetime.datetime.now()datetime.timedelta(days1)).strftime("%Y-%m-%d %H:%M:%S") days改为hours m…

Python标准库

《Python标准库》基本信息原书名&#xff1a; The Python Standard Library by Example 原出版社&#xff1a; Pearson Education 作者&#xff1a; (美)Doug Hellmann 译者&#xff1a; 刘炽 出版社&#xff1a;机械工业出版社 ISBN&#xff1a;9787111378105上架时间&#xf…

五种世界顶级思维-20190303

一、墨菲定律&#xff1a; 你越害怕什么&#xff0c;就越会发生什么。 二、吉尔伯特定律&#xff1a;工作中最大的困难就是没人跟你说如何去做。 三、吉德林法则&#xff1a;把问题清楚的写下来&#xff0c;就已经成功一半了。 四、沃尔森法则&#xff1a;把信息和金钱排在第一…

状态码301和302的区别

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到教程。 定义如下&#xff1a; 301 Moved Permanently 被请求的资源已永久移动到新位置&#xff0c;并且将来任何对此资源的引用都应该使用本响应…

Perl迎来25岁生日

摘要&#xff1a;Perl迎来了它的第25岁生日&#xff0c;普天下Perlist都冒泡同庆一下&#xff0c;很多开发者喜欢它的理由是因其具备强力、稳定、成熟、可移植性等特点&#xff0c;Perl的爱好者们赶快送上你的祝福吧&#xff01; 昨天&#xff0c;Perl迎来了它的第25岁生日&…

20165114 《网络对抗技术》 Exp0 Kali安装与配置 Week1

目录&#xff1a; 一、kail的下载与安装 二、kali的网络设置 三、安装vmware-tools。 四、更新软件源。 五、共享文件夹 六、安装中文输入法 一、kail的下载与安装 VMware workstation的安装 因为之前的课程已经涉及&#xff0c;所以本机已经安装好了VMware workstation&#x…

大数据:互联网大规模数据挖掘与分布式处理

《大数据:互联网大规模数据挖掘与分布式处理》基本信息原书名&#xff1a;Mining of Massive Datasets作者&#xff1a; (美)拉贾拉曼(Rajaraman,A.) (美)厄尔曼(Ullman,J.D.) [作译者介绍]译者&#xff1a; 王斌丛书名&#xff1a; 图灵程序设计丛书出版社&#xff1a;人民邮电…

pip 切换源安装

https://pypi.tuna.tsinghua.edu.cn/simple/ # 清华大学 https://mirrors.aliyun.com/pypi/simple/ # 阿里云 https://pypi.douban.com/simple/ # 豆瓣 https://pypi.mirrors.ustc.edu.cn/simple/ # 中国科学技术大学 https://pypi.hustunique.com/ # 华中科技大学 代码…

String... 参数定义中有三个点的意思

前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到教程。 有一个方法&#xff1a; protected void addMessage(String... messages) { ... } String... 是指参数的长度是可以变化的&#xff0…

SpringCloud框架搭建+实际例子+讲解+系列五

&#xff08;4&#xff09;服务消费者&#xff0c;面向前端或者用户的服务 本模块涉及到很多知识点&#xff1a;比如Swagger的应用&#xff0c;SpringCloud断路器的使用&#xff0c;服务API的检查、token的校验&#xff0c;feign消费者的使用。大致代码框架如下&#xff1a; 先…

软件开发者最重要的四大技能

摘要&#xff1a;现如今&#xff0c;可供选择的技术、语言及平台可谓五花八门&#xff0c;因此要弄明白哪里是花时间训练的最佳投资点也就难上加难…… 现如今&#xff0c;可供选择的技术、语言及平台可谓五花八门&#xff0c;因此作为软件开发者&#xff0c;要弄明白哪里是花时…

数据缺失的补充与修改

1查看数据情况 df.shape df.info() 2.用指定值填充 df df.fillna(x) 3.判断是否缺失 df.isnull() 4.删除缺失数据 df df.dropna() 5.补充平均值 df df.fillna(df.mean()) 6.填充他前面一个元素值(ffill向前填充&#xff0c;bfill向后填充)&#xff08;limit:可以…