安卓系統上的遠程 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.pswp.cn/news/449768.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/449768.shtml
英文地址,請注明出處:http://en.pswp.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:可以…