我一直在尝试编写C#代码,将开发者工具的网络选项卡内容输出为JSONArray,以下是目前的代码:
*IWebDriver driver = new ChromeDriver(@"C:\Users\xxx\Downloads\chromedriver_win32");
driver.Navigate().GoToUrl("https://google.com");
String scriptToExecute = "var performance = window.performance || window.mozPerformance || window.msPerformance || window.webkitPerformance || {}; var network = performance.getEntries() || {}; return network;";
String netData = ((IJavaScriptExecutor)driver).ExecuteScript(scriptToExecute).ToString();
Console.WriteLine(netData);*
另一个:
*IWebDriver driver = new ChromeDriver(@"C:\Users\xxx\Downloads\chromedriver_win32");
driver.Navigate().GoToUrl("https://google.com");
String ste = "Return window.performance.getEntries();";
String Timings = ((IJavaScriptExecutor)driver).ExecuteScript(ste).ToString();
Console.WriteLine(Timings);*
但我的输出没有给出预期的结果。看起来String netData变量返回为空,认为这是脚本问题。 有什么解决方法建议吗?