我无法使用Browsermob代理来捕获网络流量。
我正在使用Appium在Android应用程序中编写测试。我想使用Browser mob代理来捕获和验证网络调用。浏览器mob代理正在端口19536启动。我正在使用shell脚本在端口19536上打开Mac代理。
下面是我正在使用的代码,但我在HAR文件中看不到任何网络请求。它几乎是空的。
有人可以帮忙吗? TIA。
代码
//Start Proxy Server
server = new BrowserMobProxyServer();
server.start(19536);
//Turn Mac http Proxy on
Global.runShellCmdWithArg("/usr/local/bin/webproxy.sh", "on");
// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(server);
File appDir = new File("/build/outputs/apk/");
File app = new File(appDir, "Demo-debug.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName","Android Emulator");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("platformVersion", "5.1");
capabilities.setCapability("app", app.getAbsolutePath());
capabilities.setCapability("appPackage", "com.test");
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
driver = new AndroidDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.REQUEST_BINARY_CONTENT);
server.newHar("newHar");
testApp = new DemoAppPage(driver);
wait = new WebDriverWait(driver, 30);
testApp.clickGetStarted();
testApp.clickButton();
// Get the HAR data
Har har = server.getHar();
File harFile = new File("test.har");
har.writeTo(harFile);