Search code examples
c#chromium-embeddedcefsharp

Why using SetAsPopup prevent event FrameLoadEnd to be executed using a CefSharp ChroniumWebBrowser


I'm using CEFSharp with WinForms C#, I added an handler on FrameLoadEnd of a ChroniumWebBrowser control.

I also created my own LifeSpanHandler to create a custom popup window. This is working great but I still have a problem with the FrameLoadEnd not executing when the ChroniumWebBrowser is set as a popup: ChroniumWebBrowser.SetAsPopup();

Can someone point me out what I have to do to fix this?

I already tried to remove the "SetAsPopop()", this fix the event but I can't use this solution because the website that I'm tring to "automate" will redirect me somewhere else if I don't call the SetAsPopup(); over my ChroniumWebBrowser popup.

To help you see my problem I made a small solution that demonstrate it. You can download it via this link :

http://www.blacketik.com/stackoverflow/FormTester.zip

The zipfile is big because I included everything needed to test it, including cefsharp/CEF. I made the solution using Visual Studio 2015.

To debug the solution, you will have to look at your console output.

Thank you


Solution

  • Implement ILoadHandler and assign a new instance, e.g. browser.LoadHandler = new CustomLoadHandler()

    https://github.com/cefsharp/CefSharp/blob/cefsharp/45/CefSharp/ILoadHandler.cs

    The FrameLoad/End events of ChromiumWebBrowser aren't called for Popups.