Here's a video some co-workers did on charles. They go over using breakpoints to simulate network issues among a few other features.
EDIT
OK, here it is laid out.
Step-by-step guide
- Download and Install Charles
- Make sure device and computer are on same wifi
- Open Charles
- Go to Settings - Recording Settings - Include tab to filter irrevant data
Enter Host for your project
For example,
metrics.myapp.com could record only analytics (omniture) calls for an app
api.myapp.com could record api calls for an app
*.myapp.com could record both plus some additional transactions
Configure Proxy settings on your device
For iOS:
Go to the Settings app, tap Wi-Fi, find the network you are connected to and then tap the blue disclosure arrow to configure the network.
Scroll down to the HTTP Proxy setting, tap Manual.
Enter the IP address of your computer running Charles in the Server field, and the port Charles is running on in the Port field (default: 8888).
- Leave Authentication set to Off.
Note: You can use Charles with iOS simulator by going to to Help > SSL Proxying > Install Charles Root Certificate in iOS Simulators
For Android:
[Note: Each Android phone is slightly different. These steps should work for most Android devices]
- Go to Settings.
- Select “Wireless & Networks”.
- Make sure WiFi is turned on and you are connected to your network.
- Select WiFi settings using a long press (touch and hold).
- Select “Modify network”.
- Select “Show Advanced Options”.
- Under Proxy Settings, select “Manual”.
- For the Proxy Hostname (Server) field, enter your network IP address.
- For the Proxy Port field, enter the port number listed in Charles.
- Tap Save
Note: You can use Charles with an Android emulator by adding an additional emulator command line option: "-http-proxy http://[Your computers IP address]:8888"
For example, "emulator -avd [name of android virtual device] -http-proxy http://10.0.0.46:8888"
With Charles open and record button pressed, launch app. You should see data recorded on Charles.
SSL Setup
- Go to http://charlesproxy.com/getssl and install certificate on device.
- After certificate is installation is successful, On host(running Charles) go to Charles --> Proxy --> SSL Proxy Settings
- Make sure 'Enable SSL Proxying' is checked
- Add host names for SSL proxy.
- With Charles open and record button pressed, launch app. You should see required data recorded on Charles.
Breakpoint (Edit api request or response This is where you could make a false server response):
- To modify API Request or Response, click on the 'Enable Breakpoints' button.
- Find the api Path you want to modify. (The api call in Charles)
- Right click and select 'Breakpoints'.
- Refresh the page or Kill and relaunch the app on your device. When the app makes a request or receives a response at breakpoint, you will be presented with option to modify.
- Edit your request / response.
*) You can enable or disable individual breakpoints and corresponding request/response by going to Proxy - Breakpoints Settings.
*) Double click on the location to enable / disable particular request or response.
Click Execute.
Note the changes taking effect on the app.
Don't forget to turn breakpoints off after finishing tests.