appium-interceptor
v1.0.0-beta.12
Published
Appium 2.0 plugin to mock api calls for android apps
Downloads
148
Readme
appium-interceptor-plugin
This is an Appium plugin designed to intercept API response and mocking easy. This plugin uses mitmproxy
Prerequisite
- 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.
Installation - Server
Install the plugin using Appium's plugin CLI, either as a named plugin or via NPM:
appium plugin install --source=npm appium-interceptor
Activation
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
what does this plugin do?
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.
Supported Platforms
💚 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.
Usage
Refer Examples here
Troubleshooting
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
Build local
npm install
npm run build
Credits
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.