Calling a web page via a button and from the procedure "wbBrowser_NavigationCompleted" behaves differently.
Posted: Tue Jul 19, 2022 7:51 pm
I apologize in advance for not being able to publish the source code, I will try to explain the problem in general:
- I call a specific website with login (user, password) via the button
- I wait for the page to load and use 3 ExecuteScript to fill in the user, password and press the "confirm" button
- I wait for the login and call the next_web_page in the wbBrowser_NavigationCompleted procedure. But this call does not retrieve the FResourceContents in the procedure wbBrowser_WebResource_ResponseViewGetContent_Completed - the constant aContents = nil
- However, calling the same page via a button
will return the constant aContens correctly and return a filled FResourceContents.
Can you please advise what I am doing wrong? I hope I have described it clearly.
- I call a specific website with login (user, password) via the button
Code: Select all
procedure TfrmBrowser.btn1Click(Sender: TObject);
begin
wbBrowser.Navigate(any_www);
end;
Code: Select all
procedure TfrmBrowser.wbBrowser_NavigationCompleted (Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2NavigationCompletedEventArgs);
begin
wbBrowser.ExecuteScript('document.getElementById("*txtLogin*").value = "login"',0);
wbBrowser.ExecuteScript('document.getElementById("*txtPassword*").value = "psw"',0);
wbBrowser.ExecuteScript('document.getElementById("*ID_button*").click();', 1 );
...
...
end;
- However, calling the same page via a button
Code: Select all
procedure TfrmBrowser.btn1Click(Sender: TObject);
begin
wbBrowser.Navigate(next_web_page);
end;
Can you please advise what I am doing wrong? I hope I have described it clearly.