我正在尝试使用以下方法捕获 iPhone 应用程序的网络流量(使用 WebdriverIO 测试框架) https://www.npmjs.com/package/http-mitm-proxy但它不适合我。
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());
})
})
已在iPhone上安装代理证书并尝试设置wifi代理设置(服务器地址:mac ip,端口:8081)但没有成功
确保您安装了正确的证书,否则它将无法工作(阅读有关 ssl 的部分)。您还可以查看 mitmproxy.org 作为替代方案。