远程实时调试手机上的web页面
1. 安裝
????需要Node.js平臺, 先安裝好后, 打開Node.js command prompt, 通過NPM來安裝 weinre
| npm -g install weinre |
2. 啟動
????安裝完成后, 我們接著啟動 weinre
| weinre -httpPort 8081 -boundHost -all- |
?
| 能打開這個地址就說明weinre啟動成功了 |
????可以配置?.weinre/server.properties?讓啟動 weinre 變得更方便, 具體方法請參考官網(wǎng), 配置好后, 以后想啟動 weinre, 直接運行weinre命令即可, 無需每次都追加那些參數(shù)了.
3. Instrumenting your web page to act as a debug target
????將如下腳本追加到你將要調(diào)試的頁面上
????<script src="http://你的IP地址:8081/target/target-script-min.js#anonymous"></script>
4. 折騰這么久, 快點讓我遠程調(diào)試吧
????在手機上打開要調(diào)試頁面的地址
| ? |
????在 weinre Access Points 中開始遠程調(diào)試
| 點擊anonymous Access Points |
?
| 點擊一下激活target |
????終于可以調(diào)試了! 接下來隨便怎么玩都可以了, 大家應(yīng)該都很熟練了吧...
以上為http://www.douban.com/note/289846168/ 測試過程中發(fā)現(xiàn)的問題及解決: 1 .ipconfig看ip:10.62.0.173
cmd下輸入:weinre --httpPort 8080 --boundHost 10.62.0.173
手機訪問:http://10.62.0.173:8080/www/2.html
電腦也訪問:http://10.62.0.173:8080/www/2.html
[注意:若是使用無線則需要是同一個熱點。。手機和電腦都訪問同一個網(wǎng)址。。](www是我建立的目錄:C:\Users\lenovo\AppData\Roaming\npm\node_modules\weinre\web\www)
這只是手機訪問電腦ip的網(wǎng)址而已。。并沒有將手機和電腦連接到一起調(diào)試,一開始以為這就行了,后來才發(fā)現(xiàn)是錯的。
?
2. 若:cmd下輸入:weinre --httpPort 8080 --boundHost -all- [8080為端口號。。]
? ? 【注意:若為weinre --httpPort 8080 --boundHost all,則報錯weinre: unable to resolve boundHost address:all】
則電腦直接訪問 http://127.0.0.1:8080/client/
訪問文件:http://127.0.0.1:8080/www/2.html
(本地路徑:C:\Users\lenovo\AppData\Roaming\npm\node_modules\weinre\web\www)
3.測試是否成功。。
訪問:http://localhost:8080/client/#anonymous然后頂部有一個:Targets: 若后面為none之類的信息代表沒有完成。。。 a.手機訪問(注意是谷歌或safari瀏覽器才可以):10.62.0.172:8081/www/1.html ? ? ?(我的ip10.62.0.172:8081) b.電腦訪問:http://localhost:8080/client/#anonymous。。出現(xiàn)類似 10.200.108.11 [channel: t-5 id: anonymous] - http://10.62.0.173:8081/www/1.html 代表已經(jīng)手機和電腦連上去了,主要:上面的文字顏色是藍色,還需要鼠標(biāo)點擊一下,使其變成綠色,才代表可以最終調(diào)試手機上的頁面。 c.變成綠色后,則點擊elements選項卡,就會出現(xiàn)當(dāng)前頁面的html結(jié)構(gòu),進行調(diào)試。。console中輸入alert('123'),手機上馬上出現(xiàn)結(jié)果。。 1.html內(nèi)容:
<!doctype html>
<html>
<head>
<script src="http://10.62.0.173:8080/target/target-script-min.js#anonymous"></script>
<script src="../target/target-script-min.js" /></script>
</head>
<body>
<style>
body{background:#ff7300}
h3{font-size:50px;padding:100px;}
</style>
<h3>測試內(nèi)容。。。。。</h3>
</body>
</html>
。。最終10.200.108.11 [channel: t-7 id: anonymous] - http://10.62.0.173:8080/www/1.html 方可。。。
總結(jié)
以上是生活随笔為你收集整理的远程实时调试手机上的web页面的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 磁盘管理开源工具TestDisk
- 下一篇: [附源码]java+ssm计算机毕业设计