CEF.net
E
About Me
LifePlus Limited Inc.
Technical Manager
PaganiniPlus Limited Inc.
Senior Developer
Freelancer
About 10 years
CEF
Chromium Embedded Framework
A simple framework for embedding
Chromium-based browsers in other
applications
CEF
Official Website
https://bitbucket.org/chromiumembedded
Download
http://opensource.spotify.com/cefbuilds/index.html
CefGlue
.NET/Mono Binding for CEF
Licensed under MIT License with portions of
code licensed under New BSD License
CefGlue
Official Website
https://bitbucket.org/xilium/xilium.cefglue
Download
https://bitbucket.org/xilium/xilium.cefglue/download
CefGlue > CEF
Compare versions
1. Get the second new version of CefGlue
2. Get the relative version of CEF
CefGlue
1. Go to Downloads, then select Branches
2. Find the second new version
3. Download the compressed file
CEF
1. Find Windows 64-bit Builds
2. Click Show more builds to see all versions
CEF
1. Find the matched version
2. Download Standard Distribution
CEF Content
Debug
Debug version binaries
Release
Release version binaries
Resources
Locale files and extensions
tests
Sample projects in C++
CefGlue Content
CefGlue
C# binding for CEF
CefGlue.WindowsForms
UI component named CefWebBrowser
Create Project
Windows Form Project
Application
• Target Framework 4.7
Build
• Output Path ..bin
• Uncheck Prefer 32-bit
Project Dependency
Add projects and reference them
CefGlue
CefGlue.WindowsForms
Use CefWebBrowser
Drag and drop CefWebBrowser
Change Dock property to Fill
Make viewport rendered by CEF
Set StartUrl property
http://www.google.com/
Binary Dependency
Copy CEF files into bin folder
Release*
Resources*
Build and Execute
Do you see the ghost ?
But
Failed to create browser
Not Yet
Some work to be done
CefMainArgs
CefApp
CefSettings
CefRuntime.Load
CefRuntime.Initialize
CefRuntime.Shutdown
CefWebApp
CefWebApp : CefApp
CefBrowserProcessHandler
CefRenderProcessHandler
CefWebBrowser
Constructor
Call CefRuntime.Load
Call CefRuntime.Initialize with CefSettings, CefApp, …
OnHandleCreated
Modify CefBrowserSettings
Dispose
Call CefRuntime.Shutdown
Build and Execute
Do you see the light ?
1st Example
Say Hello World
Set StartUrl to HTML File
Absolute Path
Write HTML5 into HTML File
<span>Hello World</span>
2nd Example
Say Hello World in another way
Use CefJSDialogHandler
Handle OnJSDialog
Implement alert and confirm
MessageBox.Show
MessageBoxButtons
3rd Example
Reload
Use CefKeyboardHandler
Handle OnKeyEvent
Implement reload
CefWebBrowser.reload
4th Example
DevTools
Use CefKeyboardHandler
Handle OnKeyEvent
Extend DevToolsClient
CefWebDevToolsClient : CefClient
5th Example
Video Player
6th Example
PDF Viewer
7th Example
RWD with BootStrap
8th Example
Windows-Like UI with GoldenLayout
9th Example
GridView with Vue.js
10th Example
Let JavaScript see C#
BDD
Behavior-Driven Development
Gherkin
Feature: Test CEF application
Test general features of CEF application
Scenario: Open window and navigate to Google
Given I have the url of Google
When I navigate to this url
Then there should be search input inside page
And there should be search button inside page
Cucumber
Feature Files
Written by user
Step Files
Generated by tool
Implemented by user
SpecFlow
Official Website
http://specflow.org/
Install Package from NuGet
Install-Package SpecFlow -Version 2.3.2
SpecFlow
Attributes
[BeforeScenario] [AfterScenario]
[BeforeTestRun] [AfterTestRun]
[BeforeFeature] [AfterFeature]
[BeforeStep] [AfterStep]
ScenarioContext
void ScenarioContext.Current.Set<T>(T value, String key)
T ScenarioContext.Current.Get<T>(String key)
Selenium
Official Website
https://www.seleniumhq.org
Download Chrome Driver
https://sites.google.com/a/chromium.org/chromedriver
Selenium
Install Packages from NuGet
Install-Package Selenium.WebDriver
Install-Package Selenium.Support
Install-Package DotNetSeleniumExtras.PageObjects
Install-Package DotNetSeleniumExtras.WaitHelpers
Selenium with CEF
Put chromedriver.exe into Test Project
{TestProject}binchromedriver.exe
ChromeOptions
ChromeOptions.AddArgument
ChromeOptions.BinaryLocation
1st Test
Google Search
2nd Test
GridView
3rd Test
Login Behavior
Replace F5 by F5
Chrome DeTools
Reload again and again
Fast, easy, and experienced as web developer
Visual Studio Debugger
Start debugging again and again
Slow, difficult, and worked as native app developer
THANKS

CEF.net