【问题标题】:requests are not captured on Nougat and above using browserMobProxy使用 browserMobProxy 在 Nougat 及更高版本上未捕获请求
【发布时间】:2018-05-11 10:18:08
【问题描述】:

我正在使用 BrowserMobProxy 对 android 本机应用程序进行分析测试,我能够生成 .har 文件并跟踪 android 版本 6.x 及更低版本但 7.x (Nougat) 或更高版本 .har 文件获取的所有所需请求生成但没有请求被跟踪/捕获。

任何有能力的人都可以提供帮助。

如果问题描述性不够,请告诉我是否需要添加任何代码/日志来支持我的问题。

public BrowserMobProxyBaseClass bmProxy = new BrowserMobProxyBaseClass();
    public void setUp() {
        try {
            bmProxy.proxyStart();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


public Map<String, String> getAnalyticsKeyValue() throws Exception {
        Map<String, String> keyValue = new HashMap<String, String>();
        BrowserMobProxy server;
        Har har = server.getHar();
        String strFilePath = "Selenium_test.har";
        FileOutputStream fos = new FileOutputStream(strFilePath, false);
        har.writeTo(fos);
        HarLog log = har.getLog();
        List<HarEntry> entries = log.getEntries();
        for (int i = entries.size() - 1; i >= 0; i--) {
            HarEntry entry = entries.get(i);
            System.out.println(entry.getRequest().getUrl());
            if (entry.getRequest().getUrl().contains("ResponseTargetName")) {
                List<HarPostDataParam> listpost = entry.getRequest().getPostData().getParams();
                HashMap<String, String> actualData = new HashMap<String, String>();
                for (HarPostDataParam pair : listpost) {
                    if (pair.getValue() != null)
                        keyValue.put(pair.getName(), pair.getValue());
                    System.out.println("key : " + pair.getName() + "    Value : " + pair.getValue());
                }
                break;
            }
        }

        return keyValue;
    }


public void tearDownProxy() throws Exception {
        bmProxy.stopProxy();
        driver.quit();
        new HtmlLogger().createHtmlAnalyticsLogFile(result);

    }


<dependency>
            <groupId>net.lightbody.bmp</groupId>
            <artifactId>browsermob-core</artifactId>
            <version>2.1.5</version>
        </dependency>

【问题讨论】:

    标签: android android-7.0-nougat browsermob-proxy


    【解决方案1】:

    此问题已解决,现在我可以在 android nougat (v7.x) 及更高版本上使用 BMP 通过自动化跟踪请求。

    开发者在应用中添加了 BMP 代理 CA

    在被测设备上安装了相同的 CA

    就是这样:

    参考:

    BMP 证书:https://github.com/lightbody/browsermob-proxy/tree/master/browsermob-core/src/main/resources/sslSupport

    网络安全配置:https://android-developers.googleblog.com/2016/07/changes-to-trusted-certificate.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 2020-01-23
      • 2017-01-07
      • 2015-03-04
      相关资源
      最近更新 更多