Download and install
Download the installation package from the Charles official website and install it as instructed
Website address: www.charlesproxy.com
Charles Activation Code:
Registered Name: https://zhile.io
License Key: 48891cf209c6d32bf4
(From CSDN: blog.csdn.net/qq_25821067…)
Activation steps:
Open Charles, help→Registered to, enter the account and key to submit the decrypt success can be used normally!
HTTP Proxy Settings
Set the proxy port number of the PC
Set the port number such as: 8888 (can also be changed, mobile phone set agent input consistent)
Set the proxy port number of the mobile phone
Viewing IP Addresses
The mobile phone is connected to the same Wi-Fi network as the Mac, and the current Mac IP address is displayed
PS: Can also be directly option+wifi view
IOS mobile agent Settings
Settings – Wireless LAN, enter connected WiFi manual Settings (the port number must be the same as the port number set on the PC)
Android agent Settings
Settings -WLAN, access connected WiFi manual Settings (the port number must be the same as the port number set on the PC)
Different Android phones have different entry points for pop-up agent Settings. If there is no proxy item in the network details page, you can hold down the wifi name in the WLAN list and pop-up agent Settings are as follows:
When the phone makes a data request, Charles will pop up whether to allow the connection to the agent (select Allow), after which HTTP packet capture can be performed
HTTPS Proxy Settings
The above describes the HTTP proxy Settings, but sometimes it is found that the HTTPS is all garble, so you need to set the HTTPS proxy, the phone needs to install Charles SSL certificate authentication, certificate download address: charlesproxy.com/getssl. The following describes how to install the certificate for iOS and Android phones
Setting the SSL on the PC
Select Proxy→SSL Proxying Setting
Enable the SSL proxy and add trusted addresses
Add Method of adding
Install aN iOS phone
Ensure that the Charles agent is connected to the mobile network. Open Safari and enter the address for downloading the certificate. A message is displayed asking you to install the certificate
Click install in the upper right corner, and a message is displayed asking you to enter the lock screen password. After the password is entered, the installation is successful
Finally go to Settings – General – About local-Certificate trust Settings, select Charles Trust – continue, installation is complete!
Install an Android phone
As above, the browser opens the download address
After the certificate is successfully downloaded, go to the Settings – More Settings – System Security – installation page of the storage device to view the downloaded certificate, select certificate installation, enter the certificate name, you can fill in the certificate name at will, and the installation is successful!
PS: the above is the mi phone installation path, different Android phone Settings in the choice of different, you can find the system security to enter the certificate installation
The use of Charles
View Structure and Sequence
Set to list method
Clear and pause
Clear is to clear all requests that have been caught
Pause is to stop fetching data and retain previously fetched data
Filter Focus
After the agent is set, all kinds of requests are captured from the phone, many of which are not needed, so you need to filter the requests
Select the required request and right-click Focus
Or filter at the bottom of the captured packet list indicates the keyword to be queried
Repeat request Repeat/Repeat Advanced
Tools → Repeat/ Advanced Repeat (can do simple concurrent pressure test)
Repeat Repeat the request
Repeat Advanced Repeat the request multiple times
If an interface requires a total of 20 requests and 10 concurrent requests per time, set the parameters as follows
Assertions Breakpoints
In test or development scenarios where you might need to manually build a lot of data to find a problem, the ability to mock for JSON return values can be useful. Right-click the request URL and select Breakpoints to add a list of incoming interface assertions for that request by default
Or the Proxy – > Breakpoints Settings
Add the following request URLS that need to be asserted:
After the assertion is successfully set, the request is re-initiated, the status becomes editable, and the request parameter or is returned to modify the parameter
Modify the request parameter ↓. After the setting is successful, click “Execute” at the bottom to go to the next step
Modify return parameters as follows, for example, the title “rice cake mom mall” needs to be changed to “AAAA”, directly edit in JSON Text
The modification is as follows:
Finally, “Execute” is allowed. If it is a mobile request, the mock will show the modified data on the front page! Isn’t that convenient! If you want to test the interface list of dozens of data function points, you can save the database or background data creation time, directly TXT made dozens of JSON data can be! (PS: modify the parameters of the hand speed to fast oh ~ because in general, for the user experience, most pages will be compatible with a certain period of time interface no response, display the default friendly prompts of the empty page, so the replacement of JSON can be in the JSON editor or TXT edit, and then directly copy and paste it.)
Redirection Map Remote
If you need to switch to a different host environment to test during the test, you can replace the host function without manually repackaging and changing the domain name. Open Charles→Tools→Map Remote→ click ADD
Add as follows
Internet speed simulates Throttling
Proxy-throttling Select Enable Throttling to Enable network speed simulation. You can select some built-in bandwidth Settings or custom Settings. After saving the Settings, you can click on the main interfaceButton To enable or disable the slow network speed function
Configuration meaning:
Bandwidth, Utilistation, round-trip, MTU
These are the basic features of Charles, but there are many more interesting features that can be explored by yourself. Charles is a very useful tool for troubleshooting problems on the way to testing. Testing is a must