1

i am trying to press a button in javascript using chromium.

In twebbroswer i am using

WebBrowser1.OleObject.document.GetElementByID('uidPasswordLogon').Click; 

With Chromium i am using

code := 'document.getElementById("uidPasswordLogon").click()' ;
chromium1.Browser.MainFrame.ExecuteJavaScript (code, '', 0);

but it doesn´t work.

I have managed to complete Javascript fields by using

chromium1.Browser.MainFrame.ExecuteJavaScript('document.all("logonuidfield").value="'+User_Email.Text+'";', '', 0);

but for the clicks it just doesn´t work. Any suggestions? :D

1 Answer 1

2

If you are using DCEF3 version of TChromiumEmbed then you need address focused frame. Do't be scared from the "about:blank", it works on active document too.

procedure TForm1.executeChromeJavascript(javascript: string);
begin
  if crm.Browser <> nil then
    crm.Browser.FocusedFrame.ExecuteJavaScript(
      javascript, 'about:blank', 0);
end;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.