英文:
How to get Chrome Performance lighthouse data using Selenium
问题
很抱歉,根据您的要求,我只会翻译代码之外的部分。以下是您提供的内容的翻译:
有没有Java API可以使用Selenium Java捕获Chrome性能Lighthouse数据?
英文:
is there any java API to capture Chrome Performance Lighthouse data using selenium Java?
答案1
得分: 1
这可能不是你要的答案,但你可以尝试类似这样的方法;
例如,这个示例计算浏览器中的滚动性能;
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) + '';");
}
总之,你可以在Selenium Webdriver中使用JavaScript来测量性能。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论