I am using chromedriver to test a javascript webapp. How can I get the memory usage information (the kind of information shown on the "History" tab of the chrome dev tools) through chromedriver and selenium.
This strikes me that it should be possible since chromedriver uses chrome's devtools's debugging system to interact with and control chrome.
The language I'm currently using for selenium is java but if you can provide examples in any language that would be aprreciated.
I did something like this in chrome for getting my application's javascript memory usage
Chrome driver should be opened with below chromeOptions.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--enable-precise-memory-info"); // enabling this flag to get precise js heap memory info for chrome browser
WebDriver driver = new RemoteWebDriver(new URL(localhost:4444+"/wd/hub"), chromeOptions);
& then using below logic , we can get JavaScript memory usage of chrome instance
JavascriptExecutor executor = (JavascriptExecutor) driver;
long value = (long) executor.executeScript("return window.performance.memory.usedJSHeapSize");
long valueInMB = value / (1024 * 1024);
PS : I was able to find this only for chrome browser & not for firefox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With