0 votes
1 view
in Devops and Agile by (19.8k points)

I want to get output that is a network panel on developer tools.[ Network panel--> Name,method,status,Type,Initiator,Size,Time,Timeline] I need this information.

1 Answer

0 votes
by (63.4k points)

This is possible using Selenium WebDriver. For this you should do the following:

  1. Download selenium language-specific client drivers from - http://docs.seleniumhq.org/download/ and add appropriate jar files to your project build path.

  2. To run a test with Chrome/Chromium you will also need chrome driver binary which you can download from - http://chromedriver.storage.googleapis.com/index.html

  3. Create a test case like this:


 // specify the path of the chromedriver binary that you have downloaded (see point 2)

    System.setProperty("webdriver.chrome.driver", "/root/Downloads/chromedriver");

    ChromeOptions options = new ChromeOptions();

    // if you like to specify another profile



    DesiredCapabilities capabilities = DesiredCapabilities.chrome();

    capabilities.setCapability(ChromeOptions.CAPABILITY, options);

    WebDriver driver = new ChromeDriver(capabilities);


    String scriptToExecute = "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;";

    String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString();

Executing javascript on Chrome/Chromium will be helpful as it will give you the networking information also. The resulting string 'netData' will contain the required data in the JSONArray format.

I hope this helps.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !