I am trying to capture network traffic of iPhone app (using WebdriverIO test framework) using https://www.npmjs.com/package/http-mitm-proxy but its not working for me. (there are no logs captured but when tried manually by installing mitmproxy, logs are coming in terminal)
Tried following steps, but no success:-
a) Have installed proxy certificate (generated by http-mitm-proxy) on iphone.
b) Set wifi proxy setting on iphone (server address : macbook ip, port : 8081)
Code:-
import {Proxy} from "http-mitm-proxy";
describe('Calculate perf data', () => {
it('Calculate perf data', async () =>
{
const proxy = new Proxy();
proxy.onError((ctx, err) => {
console.error('Proxy error:', err);
});
proxy.onRequest((ctx, callback) => {
console.log('Proxy request:', ctx.clientToProxyRequest.headers.host, ctx.clientToProxyRequest.url);
ctx.use(Proxy.gunzip);
ctx.onResponseData((ctx, chunk, callback) => {
console.log('Response data:', chunk.toString());
return callback(null, chunk);
});
return callback();
});
proxy.listen({port: 8081}, () => {
console.log('Proxy server is listening on port 8081');
});
console.log('begin listening on 8081')
const email = "///XCUIElementTypeTextField";
const pwd = "//XCUIElementTypeSecureTextField[@name=\"text-input-outlined\"]";
const login = "//XCUIElementTypeButton[@name=\"button\"]";
(await $(email).setValue("[email protected]"));
(await $(pwd).setValue("xyz"));
(await $(login).click());
})
})