CefSharp.WinForms.ChromiumWebBrowserExtensions 83.4.20

CefSharp.WinForms.ChromiumWebBrowserExtensions

Install-Package CefSharp.WinForms.ChromiumWebBrowserExtensions -Version 83.4.20
dotnet add package CefSharp.WinForms.ChromiumWebBrowserExtensions --version 83.4.20
<PackageReference Include="CefSharp.WinForms.ChromiumWebBrowserExtensions" Version="83.4.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CefSharp.WinForms.ChromiumWebBrowserExtensions --version 83.4.20
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CefSharp.WinForms.ChromiumWebBrowserExtensions, 83.4.20"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install CefSharp.WinForms.ChromiumWebBrowserExtensions as a Cake Addin
#addin nuget:?package=CefSharp.WinForms.ChromiumWebBrowserExtensions&version=83.4.20

// Install CefSharp.WinForms.ChromiumWebBrowserExtensions as a Cake Tool
#tool nuget:?package=CefSharp.WinForms.ChromiumWebBrowserExtensions&version=83.4.20
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

主要功能

  • 类库基于CefSharp.WinForms,纯C#开发,主要是对public static Task<JavascriptResponse> EvaluateScriptAsync(this ChromiumWebBrowser browser,string script,TimeSpan? timeout = null)进行常用js方法扩展,封装在CefSharp.WinForms.ChromiumWebBrowserExtensions命名空间下,通过var value = await browser.ExGetValue("div.number", 0);调用,可以快速获取和指定指定节点的类、文本、属性等值,模拟鼠标点击、拖放等,节点通过css选择器进行选择。

  • 初始化:

      private void InitBrowser()
      {
          if (browser == null)
          {
              CefSharpSettings.ShutdownOnExit = true;
              var settings = new CefSettings();
              settings.Locale = "zh-CN";
              Cef.Initialize(settings);
              browser = new ChromiumWebBrowser(HomePageUrl);
              var changeResponseBodyItems = new List<IChangeResponseBody>();
              var changeRequestItems = new List<IChangeRequest>();
              browser.RequestHandler = new MyRequestHandler
              {
                  ChangeResponseBodyItems = changeResponseBodyItems,
                  ChangeRequestItems = changeRequestItems
              };
              browser.RequestContext = new RequestContext();
              browser.KeyboardHandler = new MyKeyBoardHander();
              browser.JsDialogHandler = new MyJsDialogHandler(false);
              browser.LifeSpanHandler = new MyLifeSpanHandler();
              browser.FrameLoadEnd += (sender, args) =>
              {
                  if (args.Frame.IsMain)
                  {
                  }
              };
              panel1.Controls.Add(browser);
              browser.Dock = DockStyle.Fill;
          }
      }
    

1.0.0

  • 命名空间为CefSharp.WinForms.ChromiumWebBrowserExtensions
  • 通过扩展函数调用,如var value = await browser.ExGetValue("div.number", 0);

63.0.3

  • 匹配CefSharp 63.0.3版本号

优化

  • 优化public static async Task<bool> ExSetValue(this ChromiumWebBrowser browser, string cssSelector, int index, string value),触发inputchange事件,适配React框架,文本框不再被清空。
  • 重写MyRequestHandler,通过ChangeDataItemsRedirectItems修改响应返回值或者重定向

63.0.3.1

  • 重写MyRequestHandler,通过ChangeResponseBodyItemsChangeRequestItems修改响应返回值或者重定向
  • 优化ExSetValue,添加等待文本框存在、文本框存在后延时、赋值后延时
  • 优化ExClick,添加等待按钮存在、按钮存在后延时、点击后延时
  • 优化文件结构,将ChromiumWebBrowserExtensions.cs拆分为多个文件
  • 添加ProxyExtensions运行时动态设置代理
  • 添加CookieExtensions删除Cookies

63.0.3.2

  • 修复ExClick点击后不延时
  • 优化MyRequestHandler默认初始化ChangeResponseBodyItemsChangeRequestItems,通过Add函数添加操作

63.0.3.3

  • 添加ExLoadAsync加载网页并等待页面加载完成
  • 优化ExWaitForLoadEnd

63.0.3.4

  • 新增MyRequestHandlerProxyUsernameProxyPassword,用于设置代理用户名和密码,默认不启用:ProxyUsernamenull
  • 优化ExLoadAsync,添加页面元素判断,用于判断网页是否加载成功

63.0.3.5

  • 优化ExLoadAsync,添加运行日志

83.4.20

  • 匹配CefSharp 83.4.20版本

主要功能

  • 类库基于CefSharp.WinForms,纯C#开发,主要是对public static Task<JavascriptResponse> EvaluateScriptAsync(this ChromiumWebBrowser browser,string script,TimeSpan? timeout = null)进行常用js方法扩展,封装在CefSharp.WinForms.ChromiumWebBrowserExtensions命名空间下,通过var value = await browser.ExGetValue("div.number", 0);调用,可以快速获取和指定指定节点的类、文本、属性等值,模拟鼠标点击、拖放等,节点通过css选择器进行选择。

  • 初始化:

      private void InitBrowser()
      {
          if (browser == null)
          {
              CefSharpSettings.ShutdownOnExit = true;
              var settings = new CefSettings();
              settings.Locale = "zh-CN";
              Cef.Initialize(settings);
              browser = new ChromiumWebBrowser(HomePageUrl);
              var changeResponseBodyItems = new List<IChangeResponseBody>();
              var changeRequestItems = new List<IChangeRequest>();
              browser.RequestHandler = new MyRequestHandler
              {
                  ChangeResponseBodyItems = changeResponseBodyItems,
                  ChangeRequestItems = changeRequestItems
              };
              browser.RequestContext = new RequestContext();
              browser.KeyboardHandler = new MyKeyBoardHander();
              browser.JsDialogHandler = new MyJsDialogHandler(false);
              browser.LifeSpanHandler = new MyLifeSpanHandler();
              browser.FrameLoadEnd += (sender, args) =>
              {
                  if (args.Frame.IsMain)
                  {
                  }
              };
              panel1.Controls.Add(browser);
              browser.Dock = DockStyle.Fill;
          }
      }
    

1.0.0

  • 命名空间为CefSharp.WinForms.ChromiumWebBrowserExtensions
  • 通过扩展函数调用,如var value = await browser.ExGetValue("div.number", 0);

63.0.3

  • 匹配CefSharp 63.0.3版本号

优化

  • 优化public static async Task<bool> ExSetValue(this ChromiumWebBrowser browser, string cssSelector, int index, string value),触发inputchange事件,适配React框架,文本框不再被清空。
  • 重写MyRequestHandler,通过ChangeDataItemsRedirectItems修改响应返回值或者重定向

63.0.3.1

  • 重写MyRequestHandler,通过ChangeResponseBodyItemsChangeRequestItems修改响应返回值或者重定向
  • 优化ExSetValue,添加等待文本框存在、文本框存在后延时、赋值后延时
  • 优化ExClick,添加等待按钮存在、按钮存在后延时、点击后延时
  • 优化文件结构,将ChromiumWebBrowserExtensions.cs拆分为多个文件
  • 添加ProxyExtensions运行时动态设置代理
  • 添加CookieExtensions删除Cookies

63.0.3.2

  • 修复ExClick点击后不延时
  • 优化MyRequestHandler默认初始化ChangeResponseBodyItemsChangeRequestItems,通过Add函数添加操作

63.0.3.3

  • 添加ExLoadAsync加载网页并等待页面加载完成
  • 优化ExWaitForLoadEnd

63.0.3.4

  • 新增MyRequestHandlerProxyUsernameProxyPassword,用于设置代理用户名和密码,默认不启用:ProxyUsernamenull
  • 优化ExLoadAsync,添加页面元素判断,用于判断网页是否加载成功

63.0.3.5

  • 优化ExLoadAsync,添加运行日志

83.4.20

  • 匹配CefSharp 83.4.20版本

Release Notes

CefSharp.WinForms.ChromiumWebBrowserExtensions

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
83.4.20 82 6/3/2021
63.0.3.5 108 4/28/2021
63.0.3.4 102 4/24/2021
63.0.3.3 45 4/23/2021
63.0.3.2 64 4/21/2021