lightbody / browsermob-proxy

A free utility to help web developers watch and manipulate network traffic from their AJAX applications.
http://bmp.lightbody.net
Apache License 2.0
2.17k stars 660 forks source link

HarLog/HarFile empty IE11 #761

Closed karim-nabli closed 6 years ago

karim-nabli commented 6 years ago

Hi, Env: Win Server 2016 - IE11 - Java 8- bmp 2.1.5 - Selenium 3.12.0 I have set up browsermob proxy as following:

            BrowserMobProxy proxy = new BrowserMobProxyServer();
// proxy.setHarCaptureTypes(CaptureType.getAllContentCaptureTypes());
            Set<CaptureType> set = CaptureType.getAllContentCaptureTypes();
            set.addAll(CaptureType.getBinaryContentCaptureTypes());
            set.addAll(CaptureType.getHeaderCaptureTypes());
            set.addAll(CaptureType.getNonBinaryContentCaptureTypes());
            set.addAll(CaptureType.getRequestCaptureTypes());
            set.addAll(CaptureType.getResponseCaptureTypes());
            proxy.setHarCaptureTypes(set);          
            proxy.setTrustAllServers(true);
            proxy.start(0);
            Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);    
            seleniumProxy.setHttpProxy("127.0.0.1:"+proxy.getPort());
            seleniumProxy.setSslProxy("127.0.0.1:7357");
                        proxy.newHar();

after creating IE webdriver instance

 InternetExplorerOptions ieOption = new InternetExplorerOptions();
ioOption.setCapability(CapabilityType.PROXY, seleniumProxy)
        ieOption.setCapability(InternetExplorerDriver.IE_USE_PER_PROCESS_PROXY, true);
        ieOption.setCapability("ie.setProxyByServer", true);
        ieOption.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, true);   
 ieOption.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
        ieOption.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "http://localhost:7357");
        ieOption.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
        ieOption.setCapability(CapabilityType.BROWSER_NAME, DesiredCapabilities.internetExplorer().getBrowserName());

the I create webdriver object, I open page in http localhost, so far so good, click event works fine. (manually I was able to see the http traffic) from trace

 2018-06-07 12:30:41:116 c:\projects\webdriver\cpp\webdriver-server\server.cc(409) Response: {

    "value" : 
    {
        "capabilities" : 
        {
            "acceptInsecureCerts" : false,
            "browserName" : "internet explorer",
            "browserVersion" : "11",
            "pageLoadStrategy" : "normal",
            "platformName" : "windows",
            "proxy" : 
            {
                "httpProxy" : "127.0.0.1:53513",
                "proxyType" : "manual",
                "sslProxy" : "127.0.0.1:7357"
            },
            "se:ieOptions" : 
            {
                "browserAttachTimeout" : 0,
                "elementScrollBehavior" : 0,
                "enablePersistentHover" : true,
                "ie.browserCommandLineSwitches" : "",
                "ie.ensureCleanSession" : true,
                "ie.fileUploadDialogTimeout" : 3000,
                "ie.forceCreateProcessApi" : false,
                "ie.usePerProcessProxy" : true,
                "ignoreProtectedModeSettings" : true,
                "ignoreZoomSetting" : false,
                "initialBrowserUrl" : "http://localhost:7357",
                "nativeEvents" : true,
                "requireWindowFocus" : false
            },
            "setWindowRect" : true,
            "timeouts" : 
            {
                "implicit" : 0,
                "pageLoad" : 300000,
                "script" : 30000
            }
        },
        "sessionId" : "aa53cdd7-5ebe-4c55-9910-9a76acfeecfc"
    }
}

But the generated harfile entires are empty:

{  
   "log":{  
      "version":"1.2",
      "creator":{  
         "name":"BrowserMob Proxy",
         "version":"2.1.5",
         "comment":""
      },
      "pages":[  
         {  
            "id":"1528374636121",
            "startedDateTime":"2018-06-07T12:30:37.436Z",
            "title":"1528374636121",
            "pageTimings":{  
               "comment":""
            },
            "comment":""
         }
      ],
      "entries":[  

      ],
      "comment":""
   }
}
karim-nabli commented 6 years ago

Well, it is Microsoft - ie- edge webdriver issue: they don't support proxy capability, in other word ioOption.setCapability(CapabilityType.PROXY, seleniumProxy) has no impact. It wont tell the webdriver to use a proxy. reference: https://docs.microsoft.com/en-us/microsoft-edge/webdriver in W3C WebDriver section, there is the line Proxy Configuration | "proxy" | Not Supported | N/A the update since 6 June 2018. There was an issue in Nov 2015 raised for similar problem : https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5468949/ So microsoft people knows about this problem for more than 2 years but they have done nothing related to that.