I am trying to extract the network calls of chrome developer tools via selenium webdriver using json, Is there is any other json format available to extract the network size or content-length?
I am trying to extract the network calls of chrome developer tools via selenium webdriver using json, Is there is any other json format available to extract the network size or content-length?
Share Improve this question asked Aug 26, 2015 at 6:07 DineshDinesh 712 silver badges8 bronze badges 3- 1 Take a look at: stackoverflow./questions/20401264/… – RiZKiT Commented Aug 26, 2015 at 8:00
- As advised tried with the below code stackoverflow./a/22502405/4683640 but these code doesn't extract the network size..if possible to extract the network size via the above approach pls advice to proceed further – Dinesh Commented Aug 26, 2015 at 8:53
- Maybe this helps you more: slideshare/watsonmw/performance-monitoring-in-a-day/16 – RiZKiT Commented Aug 27, 2015 at 23:34
1 Answer
Reset to default 4You can use the LoggingPreferences to get the Performance logs. It returns the data in json format. Here is a sample java code. Tested this with selenium 2.53, chromedriver 2.20, Chrome 50 on Ubuntu 14.04. This should work on windows also.
DesiredCapabilities d = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.PERFORMANCE, Level.ALL);
d.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
WebDriver driver = new ChromeDriver(d);
driver.get("http://www.google.");
LogEntries les = driver.manage().logs().get(LogType.PERFORMANCE);
for (LogEntry le : les) {
System.out.println(le.getMessage());
}
Here is a sample output. It is formatted manually. The actual ouput is in a single line.
{
"message": {
"method": "Network.requestWillBeSent",
"params": {
"documentURL": "https://www.google.co.in/?gfe_rd=cr&ei=gpwxV4OSKMmR2ASEg6-YCg&gws_rd=ssl",
"frameId": "31172.2",
"initiator": {
"stack": {
"callFrames": [
{
"columnNumber": 11511,
"functionName": "",
"lineNumber": 55,
"scriptId": "50",
"url": "https://www.google.co.in/?gfe_rd=cr&ei=gpwxV4OSKMmR2ASEg6-YCg&gws_rd=ssl"
}
]
},
"type": "script"
},
"loaderId": "31172.3",
"request": {
"headers": {
"Accept": "*/*",
"Referer": "https://www.google.co.in/",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36"
},
"initialPriority": "Low",
"method": "GET",
"mixedContentType": "none",
"url": "https://www.google.co.in/xjs/_/js/k=xjs.s.en.VTDhrkH4c9U.O/m=sx,c,sb,cdos,cr,elog,jsa,r,hsm,qsm,j,p,d,csi/am=AJQ0CwoS8fchIGwhrCA1YGBR/rt=j/d=1/t=zcms/rs=ACT90oGi2YIjVL5cBzOc1-MD37a1NqZ1jA"
},
"requestId": "31172.3",
"timestamp": 251208.074288,
"type": "Other",
"wallTime": 1462869123.92204
}
},
"webview": "8AF4A466-8027-4340-B9E9-CFEBDA769C50"
}