title: Is there a way to capture network using BrowserStack with Selenium?
body: <p>I use <a href="https://www.browserstack.com/automate" rel="nofollow noreferrer">BrowserStack</a> with Selenium-webdriver to run tests on different types of devices and browsers. So actually tests are running by RemoteWebDriver.
  I know that it's possible to capture network within Selenium tests using <a href="https://github.com/lightbody/browsermob-proxy" rel="nofollow noreferrer">BrowserMobProxy</a>, but as i understand it's working only if test is running on local machine.<br>
  <strong>Is there a way to capture network while running test on cross-platform base like BrowserStack?</strong>
  <br>
  <br>
  UPDATE <br>
  I managed to get capture of network in har file (from link "localhost:8080/proxy/8081/har"), using standalone BrowserMobProxy and standalone local BrowserStack, as I was advised.</p>
  
  <p>I tried to do the same automatically from code:</p>
  
  <pre><code>    BrowserMobProxy proxy = new BrowserMobProxyServer();
      proxy.start(8080);
      System.out.println("Proxy port: " + port);
      System.setProperty("java.net.useSystemProxies", "true");
      System.setProperty("http.proxyHost", "127.0.0.1");
      System.setProperty("http.proxyPort", "8080");
      System.setProperty("https.proxyHost", "127.0.0.1");
      System.setProperty("https.proxyPort", "8080");
  
      Local l = new Local();
          Map&lt;String, String&gt; options = new HashMap&lt;String, String&gt;();
          options.put("key", accessKey);
          options.put("forcelocal", "true");`
  
      //when I uncomment it i get an exception: 
      //com.browserstack.local.LocalException: Could not connect to www.browserstack.com! 
  
      //            options.put("forceproxy", "true");
      //            options.put("proxyHost", "localhost");
      //            options.put("proxyPort", "8080");
          l.start(options);
      }
      Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
      capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
      proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
      driver = new RemoteWebDriver(new URL("http://"+username+":"+accessKey+"@"+config.get("server")+"/wd/hub"), capabilities);'
  
      proxy.newHar("testHar.com");
  
      driver.get(testUrl);
      Thread.sleep(15000);
      Har har = proxy.getHar();
      FileOutputStream fos = new FileOutputStream("C:\\LoadingPage\\network\\testHar.har");
      har.writeTo(fos);
  </code></pre>
  
  <p>The connection to the url is working, I could see it and make screenshouts.
  BUT! In the har file I see only request to "hub-cloud.browserstack.com/wd/hub/...", not the requests from page itself. </p>
  
  <p><strong>How to get correct har from code?</strong>
  What in the code is not correct?</p>