This is an Appium plugin designed to intercept API response and mocking easy. This plugin uses mitmproxy
- Appium version 2.0
- Intercepting API requests from android requires CA certificate to be installed on the device. Follow the instructions in How to install CA certificate on android section and install the CA certificate.
Install the plugin using Appium's plugin CLI, either as a named plugin or via NPM:
appium plugin install --source=npm appium-interceptor
The plugin will not be active unless turned on when invoking the Appium server:
appium server -ka 800 --use-plugins=appium-interceptor -pa /wd/hub
For every appium session, interceptor plugin will start a proxy server and updates the device proxy settings to pass all network traffic to proxy server. Mocking is disabled by default and can be enabled from the test by passing appium:intercept : true
in the desired capability while creating a new appium session.
Please refer to the commands sections for detailed usage.
💚 Android
Mocking support
- Update outgoing request URL
- Fully Replace or partially modify the request payload (POST Body)
- Update the request headers
- Update the response headers
- Fully Replace or partially modify the response body
- Update the response status code.
Refer Examples here
In certain instances where the session terminates abruptly, the device proxy state may persist without being cleared, leading to a non-functional network connection. To rectify this issue and reset the device proxy state, execute the following adb command.
adb shell settings put global http_proxy :0
npm install
npm run build
A special thanks to creators and maintainers of node-http-mitm-proxy. Their efforts have laid the foundation for the capabilities embedded in this plugin.