Google Debugging tools in the mobile phone simulator analog phone WebApp development, and the effect of the real machine is still some deviation, opera mobile phone simulator effect is also poor. Sometimes developed on the PC WebApp effect is good, in some real machine on the deviation, this time we need to fine-tune.
On the PC after fine-tuning to the test environment and then on the phone to see the effect, development is very slow, inefficient. At this time, I think there is a tool that can be debugged on the phone, you can change the parameters at any time to see the effect on the phone, eliminating the issue of re-testing, fuzzy estimation parameters are not accurate trouble, weinre is a tool like this.
Weinre can remotely debug the page on the phone on the PC, similar to the debugging tools of the PC browser, select a tag in the code on the PC, the corresponding part on the mobile page will be highlighted, change the attribute parameters on the PC, can immediately see the effect on the phone, such as:
How to configure and use Weinre:
I. Configuring the Environment
1. First ensure that you install the NODEJS environment, if not, first go to the official website to download the installation.
2. Nodejs v0.10 has integrated NPM, so it can be installed directly with NPM and entered directly in cmd: NPM install WEINRE-G.
3. After the installation is complete, you will see the weinre in the directory C:\Users\Administrator\AppData\Roaming\npm\node_modules, this is its home directory.
4. Run weinre--httpport 8081-boundhost-all-in cmd, start weinre: keep cmd window not closed during debugging
Open the browser access 192.168.0.20:8081(192.168.0.20 is my local LAN IP address, which needs to be changed to you), if the following page appears, the installation is successful:
Click Debug Client User interface:
5. PC-Side Build server locally
Weinre already contains an HTTP server whose root directory is C:\Users\Administrator\AppData\Roaming\npm\node_modules\weinre\web. The target page is placed under this directory. in order to organize your target page, you can create a new folder in the current directory, such as www.
Try accessing 192.168.0.20:8081/demo/weinre-demo.html on your PC
Note: This sentence is key: weinre--httpport 8081 -boundhost-all- must write like this, case-sensitive
--httpport 8081 : Sets the access port, which, if not, is port 8080 by default. Port initial must be uppercase, do not capitalize the setting of ports is not successful, still not the default 8080:
It is also recommended not to use the default 8080 port, change to 8081. Since eclipse will be able to run the project using port 8080, if you set the port of Weinre to 8080 and then start Eclipse, Eclipse prompts for port conflict to not work, try the following to turn off the 8080 ports that are occupied:
-boundhost-all-: This sentence is guaranteed with 127.0.0.1:8081, localhost:8081, 192.168.0.20:8081(192.168.0.20 is my local LAN IP address) can be accessed, no this sentence or less-boundhost or host does not have an initial capitalization , can not guarantee that 192.168.0.20:8081 access, this is very important, because on the phone can only access 192.168.0.20:8081
two. Using weinre debugging
1. pc End Access Debug Side page: 192.168.0.20:8081.
2. phone access to PC server destination file
1. pc End Access Debug Side page: 192.168.0.20:8081/client#anonymous
#anonymous为默认的ID , can be changed to a custom ID, this can be used for multi-user debugging, refer to: http://wyqbailey.diandian.com/post/2011-11-09/20511143
2. Mobile Access is placed on the target page in the server:
Note: the phone needs to be connected to Wi-Fi, The address of the WiFi needs to be the same network segment as the computer's IP. For example, the company all computers in a local area network, one computer as a server emitted wireless WiFi, the phone directly connected to this WiFi, you can access the Weinre server.
In order for the page to be debugged to be weinre detected, there are two ways to add debug Target:
(1) , Target Script
This method needs to add a JSto the Debug page:
<script src= "http://192.168.0.20:8081/target/target-script-min.js#anonymous" type= "Text/javascript" ></ Script>
(192.168.0.20 is my local LAN IP address, you need to change it here)
After adding to the mobile device to access the page, if you debug the page less can use this method, if more than recommended the second method
(2), Target bookmarklet(This method I did not succeed, if you know how to make, then share)
This method is to save a section of JS to the mobile device bookmarks, can be found in the http://192.168.0.20:8081/JS:
JavaScript: (function (e) {e.setattribute ("src", "http://localhost:8081/target/target-script-min.js#anonymous"); document.getElementsByTagName ("Body") [0].appendchild (e);}) (Document.createelement ("script")); void (0);
Save this JS to the name debug bookmark, and then use the mobile device to access the page I want to debug, such as Http://iinterest.net, and finally click on the debug bookmark to OK.
below to see the effect, here I use the demo page weinre to do the example:
Mobile phone connection after WiFi access: 192.168.0.20:8081/demo/weinre-demo.html
Then back to the PC to look at the http://192.168.0.20:8081/client/page, there is a mobile phone on the target page to visit the address:
Click on the link, turn green, click on the top of the elements, you can debug it, there has been the beginning of the effect:
Change the properties below to see the effect on your phone ~ ~
Note: when changes are made to the HTML file, the changed content is not synced to the phone, and it must be accessed on the PC as well, and the phone will not synchronize the updated content until it is refreshed.
Summarize:
Although this method can see the effect of debugging in real-time on the phone, but each time you need to move the local static files to the Weinre server, and then the target page with the JS header, the only JSP has no local static HTML page, Either convert all or part of the JSP page into HTML and put it on the weinre server or do not convert closed eyes estimated parameter changes after the release to see the effect ... There are certain limitations.
(I tried to merge the address of the local static file with the address of the WEINRE server to the same one so that you don't have to copy the new version often, but found that the default path for the Weinre installation is C:\Users\hp\AppData\Roaming\npm\node_modules, Do not know how to change this path O (╯-╰) o, if you know you can try it out)
when developing WebApp, it is recommended to develop the whole process on the PC, release the test version of the mobile phone on the interface and can not use the PC debugging part of this method for debugging.
There are two ways to access a static file on a PC from the phone side (only access to see effects cannot be debugged in real time):
1. Using Nginx
Open Nginx configuration file:
Restart Nginx, mobile phone connection wireless network, Access: 192.168.0.20/static/login-register/login.html Try it ~
(192.168.0.20 is my local LAN IP address, followed by the path under my configured paths D:\woqu_work_svn\m, which needs to be changed to yours)
Note: phone needs to connect to the wireless Wifi,wifi address needs and the computer's IP for the same network segment. For example, the company all computers in a local area network, one computer as a server emitted wireless WiFi, the phone directly connected to this WiFi, you can access the Weinre server.
2. Upload a static file to your own server space
For example, you can upload a static file to the SAE (Sina Cloud) or your own domain name space, then the mobile phone access to the domain name address (this is certainly accessible O (∩_∩) o~)
Suggestions:
1.webapp development, you can connect the page with a jump link, so that when we visit the test link on the phone, we can jump to other pages on the visited page, instead of testing a page to enter a link address, you can enter a test multiple pages. and the link to the page can be connected to the background staff changes also have no effect.
2. In addition, for the page from HTML to JSP, if the front-end staff in the JSP has changed, then also synchronized to the HTML changes, so that the subsequent test is helpful, and the part of the synchronization to the HTML is only part of the change, not trouble.
Reference:
Http://www.cnblogs.com/lvdabao/p/3436620.html?
If you are not welcome to indicate ~ ~
WebApp Development Debugging Environment--weinre configuration