如何使用selenide/selenide webdriver获得每秒请求总数

问题描述:

我想获取网络上特定url的请求总数。我该如何使用硒或硒。 我的网页上有一个搜索栏,如果我开始在搜索框中输入,它会显示自动完成的结果,每输入一个字符都会提出一个请求。我想检查多少次请求。如何使用selenide/selenide webdriver获得每秒请求总数

有人可以请这方面的帮助或任何提示,如果有可能使用硒webdriver?

是的,你可以做到这一点使用JavascriptExecutor

代码是如下: -

ChromeOptions options = new ChromeOptions(); 
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(); 
System.out.println(netData); 

第一个代码retrun网络回路网;”因为这个JS标签,您可以删除实体的JS代码。你不需要

希望它能帮助你:)