我正在使用Selenium进行测试,试图获取带有标头和内容/正文的HTTP请求。用我的代码,我从chrome获取了整个“性能”日志,但是我只想解析“点击”或页面加载后生成的HTTP请求,有人可以帮我解析带有名称或参数的整个日志吗? >
ChromeOptions options = new ChromeOptions();
var perfLogPrefs = new ChromePerformanceLoggingPreferences();
perfLogPrefs.AddTracingCategories(new string[] { "devtools.network" });
options.PerformanceLoggingPreferences = perfLogPrefs;
//options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true);
options.SetLoggingPreference("performance", LogLevel.All);
Uri driverlocation = new Uri("http://localhost:5556/wd/hub");
IWebDriver _driver = new RemoteWebDriver(driverlocation, options.ToCapabilities());
WebDriverWait _wait = new WebDriverWait(_driver, TimeSpan.FromMinutes(2));
return new ChromeDriverModel()
{
driver = _driver,
wait = _wait
};
这:
var logs = driver.Manage().Logs.GetLog("performance");
object s = JsonConvert.SerializeObject(logs);
File.AppendAllText($@"c:\{"qalogs"}\json.json", s.ToString());