2

is there any java API to capture Chrome Performance Lighthouse data using selenium Java?

Nick
  • 689
  • 14
  • 27

1 Answers1

1

This is probably not your answer but you can try something like this;

For example this calculates Scroll performance of in browser;

public static String toLastElement(WebDriver driver, List<WebElement> webElementList) {
        JavascriptExecutor js = (JavascriptExecutor) driver;
        int y = webElementList.get(webElementList.size() - 1).getLocation().getY();
        return (String) js.executeScript("var start = performance.now(); " +
                            "window.scrollTo(0," + y + "); " +
                            "var end = performance.now(); " +
                            "return '' + (end - start) + '';");
    }

In summary you can use javascript to measure performance in Selenium Webdriver.

Berkay Kirmizioglu
  • 1,134
  • 1
  • 11
  • 23
  • And also please check; https://github.com/lightbody/browsermob-proxy/ – Berkay Kirmizioglu May 29 '20 at 11:37
  • I used the same thing. but i want the performance audit data coz, it contains recommendations for each elements that can be optimized. it can be done using NODE js, using : { npm install -g lighthouse lighthouse --output=json --output-path=./report.json https://airhorner.com/ } this snippet. – Nick May 30 '20 at 04:17
  • here comes another problem, i have created a runable jar that can be used in any selenium automation script to capture all the performance needed with the redirection of pages. Now if i call light house command from jar it will find those values, but there is a high chance that user might not have node installed. – Nick May 30 '20 at 04:20