0

I am using BrowserMobProxy for analytics testing of android native app, I am able to generate .har file and track all desired requests on android version 6.x and below but on 7.x (Nougat) or above .har file getting generated but no requests being tracked/captured.

Anyone who is able to do so kindly help.

If question is not descriptive enough, Please let me know if I need to add any code/log in support of my question.

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>
Vikas
  • 11
  • 4

1 Answers1

0

This issue is resolved, now I am able to track requests via automation using BMP on android nougat (v7.x) and above.

Developers added BMP proxy CA in app

Installed same CA on device under test

and that's it :

reference:

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

network security config: https://android-developers.googleblog.com/2016/07/changes-to-trusted-certificate.html

Vikas
  • 11
  • 4