Jump to content
Incus J

VCL TEdgeBrowser not initialising

Recommended Posts

I have VCL TWebBrowser working in “EdgeOnly” mode (SelectedEngine) in a simple test app.

 

It’s loading pages and I can browse sites.  So far so good.

 

I’d like to execute some Javascript and obtain a result.  I’m happy to stick with TWebBrowser if it’s possible.  Must be in EdgeOnly mode though!

 

On the other hand, TEdgeBrowser has built in Javascript execution.  So maybe I should switch to that component - except I can’t get it to work.

 

When I run my test app, TWebBrowser loads OK, but TEdgebrowser remains a grey empty background and ignores all commands to Navigate etc. - I suspect it isn’t initialising.  No error messages.

 

WebView2Loader.dll is present in the app folder - and TWebBrowser is using it successfully.

 

Given that TWebBrowser is working in EdgeOnly mode, what am I missing with TEdgeBrowser?

 

Delphi 12.3 on Windows 11 (Arm, 24H2 64-bit).

Share this post


Link to post
4 minutes ago, Incus J said:

No error messages.

The TEdgeBrowser has an event handler to catch initialization (OnCreateWebViewCompleted and OnProcessFailed). Have you checked those?

Share this post


Link to post

Yes, I have an event handler assigned to each of those events - just to log any activity to a TMemo.  Neither event is triggered.

Share this post


Link to post

I am using TEdgeBrowser excessively, up to the point of completely replacing a VCL-based UI with a web-based interface, as well as injecting and calling JavaScript at runtime.

 

Can you provide a minimal example of your project?

 

One caveat is that you have to wait for the TEdgeBrowser to finish navigation and _then_ do something with its content, but I suppose that is the same when being wrapped by TWebBrowser.

Share this post


Link to post

@Incus

 

we work with both TEdgeBrowser and a "a version supporting the newest APIs of WebView2 (see https://github.com/salvadordf/WebView4Delphi)

for both, the scripting is working

var js:= 'document.querySelector(''[class=xyz]'').outerText';
edgeBrowser.ExecuteScript(js);

getting the result via

procedure TfrmMain.edgeBrowserExecuteScriptCompleted(Sender: TObject;
  aErrorCode: HRESULT; const aResultObjectAsJson: wvstring;
  aExecutionID: Integer);
begin
  ...

I had at the beginning a similar problem initializing correctly

a) the WebView2Loader.dll has to be not too old

b) the have to be the right choice of x86 or x64 (see https://github.com/salvadordf/WebView4Delphi for a new working copy)

c) why I selected: WebView4Delphi (see https://embt.atlassian.net/servicedesk/customer/portal/1/RSS-3509) ...  we needed to have extensions registered (specifically AdBlocker Plus) to make our solution working efficiantly.

 

best regards

Edited by Günther Schoch

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×