在Appium中通过浏览器移动代理自动捕获网络流量

在Appium中通过浏览器移动代理自动捕获网络流量,appium,browsermob-proxy,Appium,Browsermob Proxy,我无法让Browsermob代理捕获网络流量 我正在使用Appium在android应用程序中编写测试。我想使用浏览器移动代理来捕获和验证网络呼叫。浏览器移动代理正在端口19536处启动。我正在使用shell脚本在端口19536上打开Mac代理 下面是我正在使用的代码,但我在HAR文件中看不到任何网络请求。它几乎是空的 有人能帮忙吗?蒂亚 代码 //启动代理服务器 服务器=新浏览器mobproxyserver(); 服务器启动(19536); //打开Mac http代理 Global.runS

我无法让Browsermob代理捕获网络流量

我正在使用Appium在android应用程序中编写测试。我想使用浏览器移动代理来捕获和验证网络呼叫。浏览器移动代理正在端口19536处启动。我正在使用shell脚本在端口19536上打开Mac代理

下面是我正在使用的代码,但我在HAR文件中看不到任何网络请求。它几乎是空的

有人能帮忙吗?蒂亚

代码

//启动代理服务器
服务器=新浏览器mobproxyserver();
服务器启动(19536);
//打开Mac http代理
Global.runShellCmdWithArg(“/usr/local/bin/webproxy.sh”,“on”);
//获取Selenium代理对象
代理seleniumProxy=ClientUtil.createSeleniumProxy(服务器);
文件appDir=新文件(“/build/outputs/apk/”);
File app=新文件(appDir,“Demo debug.apk”);
DesiredCapabilities=新的DesiredCapabilities();
setCapability(“deviceName”、“Android Emulator”);
能力。设置能力(“平台名”、“安卓”);
能力。设置能力(“平台版”、“5.1”);
setCapability(“app”,app.getAbsolutePath());
capabilities.setCapability(“appPackage”、“com.test”);
能力.setCapability(CapabilityType.PROXY,seleniumProxy);
驱动程序=新的AndroidDriver(新的URL(“http://127.0.0.1:4723/wd/hub(能力),;
server.enableHarCaptureTypes(CaptureType.REQUEST\u内容,CaptureType.REQUEST\u二进制内容);
server.newHar(“newHar”);
testApp=新的DemoAppPage(驱动程序);
等待=新的WebDriverWait(驱动程序,30);
testApp.ClickGetStart();
testApp.clickButton();
//获取HAR数据
Har=server.getHar();
File harFile=新文件(“test.har”);
har.writeTo(harFile);

有人能帮忙吗?运气好吗?就连我也被同样的事情缠住了!有人能帮忙吗?运气好吗?就连我也被同样的事情缠住了!
  //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);