• <small id='udIYS'></small><noframes id='udIYS'>

      <legend id='udIYS'><style id='udIYS'><dir id='udIYS'><q id='udIYS'></q></dir></style></legend>

      • <bdo id='udIYS'></bdo><ul id='udIYS'></ul>
        <i id='udIYS'><tr id='udIYS'><dt id='udIYS'><q id='udIYS'><span id='udIYS'><b id='udIYS'><form id='udIYS'><ins id='udIYS'></ins><ul id='udIYS'></ul><sub id='udIYS'></sub></form><legend id='udIYS'></legend><bdo id='udIYS'><pre id='udIYS'><center id='udIYS'></center></pre></bdo></b><th id='udIYS'></th></span></q></dt></tr></i><div id='udIYS'><tfoot id='udIYS'></tfoot><dl id='udIYS'><fieldset id='udIYS'></fieldset></dl></div>
        <tfoot id='udIYS'></tfoot>
      1. 无法在 Selenium C# 中获取 Chrome 性能日志

        Unable to get Chrome Performance logs in Selenium C#(无法在 Selenium C# 中获取 Chrome 性能日志)
          • <legend id='SnTHW'><style id='SnTHW'><dir id='SnTHW'><q id='SnTHW'></q></dir></style></legend>
              <tbody id='SnTHW'></tbody>
            <tfoot id='SnTHW'></tfoot>
              <bdo id='SnTHW'></bdo><ul id='SnTHW'></ul>

                <i id='SnTHW'><tr id='SnTHW'><dt id='SnTHW'><q id='SnTHW'><span id='SnTHW'><b id='SnTHW'><form id='SnTHW'><ins id='SnTHW'></ins><ul id='SnTHW'></ul><sub id='SnTHW'></sub></form><legend id='SnTHW'></legend><bdo id='SnTHW'><pre id='SnTHW'><center id='SnTHW'></center></pre></bdo></b><th id='SnTHW'></th></span></q></dt></tr></i><div id='SnTHW'><tfoot id='SnTHW'></tfoot><dl id='SnTHW'><fieldset id='SnTHW'></fieldset></dl></div>

                <small id='SnTHW'></small><noframes id='SnTHW'>

                  本文介绍了无法在 Selenium C# 中获取 Chrome 性能日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在我的解决方案中使用以下 nuget 包

                  I am using following nuget packages in my solution

                  1. Selenium.WebDriver - v3.141.0
                  2. Selenium.WebDriver.ChromeDriver - v79.0.3945.3600

                  我正在使用以下代码创建 Chrome 驱动程序实例

                  using following code I am creating a Chrome driver instance

                  ChromeOptions options = new ChromeOptions();
                  
                  //Get Performance Logs from Network tab
                  ChromePerformanceLoggingPreferences perfLogPrefs = new ChromePerformanceLoggingPreferences();
                  options.PerformanceLoggingPreferences = perfLogPrefs;
                  options.SetLoggingPreference("performance", LogLevel.All);
                  

                  (或)

                  ChromePerformanceLoggingPreferences perfLogPrefs = new 
                  ChromePerformanceLoggingPreferences();
                  perfLogPrefs.AddTracingCategories(new string[] { "devtools.timeline" });
                  options.PerformanceLoggingPreferences = perfLogPrefs;
                  options.SetLoggingPreference("goog:loggingPrefs", LogLevel.All);
                  options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true);
                  

                  并与此结合

                  options.AddUserProfilePreference("intl.accept_languages", "en-US");
                  options.AddUserProfilePreference("disable-popup-blocking", "true");
                  options.AddArgument("test-type");
                  options.AddArgument("--disable-gpu");
                  options.AddArgument("no-sandbox");
                  options.AddArgument("start-maximized");
                  options.LeaveBrowserRunning = true;
                  
                  IWebDriver driver = new ChromeDriver(options);
                  

                  但在创建 Chrome 驱动程序实例时,我收到以下错误消息

                  but while creating Chrome driver instance, I am getting following error message

                  无效参数:'firstMatch' 的条目 0 无效来自无效参数:指定了 perfLoggingPrefs,但未启用性能日志记录

                  请问我需要进行哪些更改才能使用最新版本的 Chrome 和 Selenium 驱动程序获取性能日志

                  May I know what changes do I need to make please to get the performance logs with latest version of Chrome and Selenium driver

                  当我使用较低版本的 Chrome 驱动程序 (2.35.0) 时,我可以使用以下代码检索性能日志

                  I am able to retrieve Performance Logs using the below code when I was using lower versions of Chrome driver (2.35.0)

                  var logs = driver.Manage().Logs.GetLog("performance");
                  
                  for (int i = 0; i < logs.Count; i++)
                  {
                     Console.WriteLine(logs[i].Message);
                  }
                  

                  推荐答案

                  使用 Selenium WebDriver (v4.0.0-alpha04) 和 Selenium.Chrome.WebDriver (v79.0.0) 并使用以下代码,我能够检索性能日志.

                  With Selenium WebDriver (v4.0.0-alpha04) and Selenium.Chrome.WebDriver (v79.0.0) and using the following code, I am able to retrieve the performance logs.

                  ChromeOptions options = new ChromeOptions();
                  
                  //Following Logging preference helps in enabling the performance logs
                  options.SetLoggingPreference("performance", LogLevel.All);
                  
                  //Based on your need you can change the following options
                  options.AddUserProfilePreference("intl.accept_languages", "en-US");
                  options.AddUserProfilePreference("disable-popup-blocking", "true");
                  options.AddArgument("test-type");
                  options.AddArgument("--disable-gpu");
                  options.AddArgument("no-sandbox");
                  options.AddArgument("start-maximized");
                  options.LeaveBrowserRunning = true;
                  
                  //Creating Chrome driver instance
                  IWebDriver driver = new ChromeDriver(options);
                  
                  //Extracting the performance logs
                  var logs = driver.Manage().Logs.GetLog("performance");
                  for (int i = 0; i < logs.Count; i++)
                  {
                     Console.WriteLine(logs[i].Message);
                  }
                  

                  希望这会有所帮助.

                  这些天来,我在最新版本的 Selenium WebDriver 和 Chrome 驱动程序中使用以下两行代码,但无法弄清楚问题所在,现在使用最新版本,不需要以下两行代码.

                  All these days, I was using the following two lines with latest versions of Selenium WebDriver and Chrome Driver and couldn't figure out what the issue was and now with the latest versions, the following two lines of code is not required.

                  var perfLogPrefs = new ChromePerformanceLoggingPreferences();
                  options.PerformanceLoggingPreferences = perfLogPrefs;
                  

                  这篇关于无法在 Selenium C# 中获取 Chrome 性能日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                  Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                  Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                  IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                  .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                  Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution(引用 IBM.Data.DB2 中的代码使该程序集对我的解决方案的其余部分不可用)

                  <small id='hkNhc'></small><noframes id='hkNhc'>

                    <tbody id='hkNhc'></tbody>

                      <bdo id='hkNhc'></bdo><ul id='hkNhc'></ul>
                    • <legend id='hkNhc'><style id='hkNhc'><dir id='hkNhc'><q id='hkNhc'></q></dir></style></legend>

                        <tfoot id='hkNhc'></tfoot>
                          1. <i id='hkNhc'><tr id='hkNhc'><dt id='hkNhc'><q id='hkNhc'><span id='hkNhc'><b id='hkNhc'><form id='hkNhc'><ins id='hkNhc'></ins><ul id='hkNhc'></ul><sub id='hkNhc'></sub></form><legend id='hkNhc'></legend><bdo id='hkNhc'><pre id='hkNhc'><center id='hkNhc'></center></pre></bdo></b><th id='hkNhc'></th></span></q></dt></tr></i><div id='hkNhc'><tfoot id='hkNhc'></tfoot><dl id='hkNhc'><fieldset id='hkNhc'></fieldset></dl></div>