Setting up BrowserMob proxy to work with iOS Safari

Has anyone tried using browser mob proxy with iOS Safari?
Below is my code , but it doesn’t generate any HAR File. So I doubt if traffic is being routed through proxy.

If I manuall set the browserMob proxy on device, it works

   //Create new proxy server
    mobProxyServer = new ProxyServer(9901);
    mobProxyServer.start();

    //Create Selenium Proxy Object
    Proxy proxy = mobProxyServer.seleniumProxy();


    //Set Capabilities
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability(CapabilityType.PROXY,proxy);
    desiredCapabilities.setCapability("platformName", "iOS");
    desiredCapabilities.setCapability("platform-version", "7.0");
    desiredCapabilities.setCapability("browserName","safari");
    desiredCapabilities.setCapability("deviceName","iPhone 5s");

    //Create Driver
    //AppiumDriver driver = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"),desiredCapabilities);
     driver = new RemoteWebDriver(new URL("http://0.0.0.0:4723/wd/hub"),desiredCapabilities);


    //Create HAR File
    mobProxyServer.newHar("test");

    //Open website
    driver.get("http://m.att.com");
    Thread.sleep(10000);

    //get and save HAR
    Har har = mobProxyServer.getHar();
    FileOutputStream fHarFile = new FileOutputStream("test.har");
    har.writeTo(fHarFile);

Hi Aniket,

I am looking for the same … any luck on this ?
-Amarnath Rayudu

I do automation using iOS Simulators on VMs. (VMWare Fusion) You need to set the OS X System Proxy in order for the emulator to use a proxy.

If you’re using a physical device, I’m not sure I can help.

When setting the system proxy, make sure to add the IP of your Selenium Grid and of the host running BMProxy to the proxy bypass settings, or Appium will try to connect to the grid via the proxy.

We haven’t looked into it in a while, but we have to use a set of static proxy port mappings (instead of on-the-fly) because the proxy Capability doesn’t seem to work in the scenario we use.

Granted, the initial research and implementation was done about a year ago using Appium 1.0, so if this has changed, that would be awesome.

I am able to get the HAR entries for Firefox but no luck with simulator or device(getting HAR with no entries in the file).
Is there anyway to setup browsermob proxy on my device ? Please help.

Thanks,
Amarnath

I was able to do it with both Android Emulators/Real device and also with iOS simulators/real device. We did it with Appium 1.0. I will try again doing this with latest Appium version 1.3.7 and share my findings soon.

Hi Amit,

Were you able to test browsermob proxy with iOS real device and simulators?

Thanks
Gulshan

Hi Gulshan,

I am trying to accomplish the same but i am also getting empty HAR file. Were you able to find the resolve to this problem.

Regards,

JK

Hi Folks …

It works on real device, need to change the proxy settings in the device.

Thanks,
Amarnath

1 Like

I am able to finally make it work on simulator as well. Please see this.

Hi Amit,

I referred : http://stackoverflow.com/questions/26058211/ios-8-xcode-6-simulator-is-not-using-http-proxy-anymore

but they just suggest to restart the simulator which did not work for me… can you suggest what exactly you did to make your simulator to use proxy?

Hi Amarnath,

What settings do i need to change in device for browsermob proxy to work on a real device. I am using Appium 1.5.3 and trying to run my tests on iPhone 10.x version.

Below is my code.

    BrowserMobProxy proxy = new BrowserMobProxyServer();
	proxy.start();		
	Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
	capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);

Any help would be appreciated.

Thanks,
Manoj

Hi Amarnath,

What proxy setting need to do in device. Can you elaborate.?