how to access Network panel on google chrome developer tools with selenium?

0
0

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

  • You must to post comments
0
0

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

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

  2. To run a test with Chrome/Chromium you will also need chromdriver 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 chromdriver 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
options
.addArguments("user-data-dir=/root/Downloads/aaa");
options
.addArguments("start-maximized");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities
.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
driver
.get("http://www.google.com");
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 help you to get the networking (not only) info. The resulting string ‘netData’ will contain the required data in JSONArray format.

Hope this will help.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website