delphi chromium 填写表格

技术文摘
Use the java to fill form, See example.
Procedure TfmMain.JavaExec(const S: string);
begin
  if Crm.browser <> nil then
    Crm.browser.MainFrame.ExecuteJavaScript(S, ‘about:blank’, 0);
end;
Begin
  strTemp := ‘document.forms[0].inmembername.value=”User_Name”;’;
  JavaExec(strTemp);
  strTemp := ‘document.forms[0].inpassword.value=”Password”;’;
  JavaExec(strTemp);
  strTemp := ‘document.forms[0].submit.click();’;
  JavaExec(strTemp);
end;
 
 
 

is somebody experience on using delphi embedded chrome? delphichromiumembedded. how to make get accessed to its HTML DOCUMENTS? like assign a value to Editbox

 

 // https://login.live.com

  strTemp := ‘document.forms[0].loginfmt.value=”justtest”;’;
  JavaExec(strTemp);
  strTemp := ‘document.forms[0].passwd.value=”123456″;’;
  JavaExec(strTemp);
  strTemp := ‘document.forms[0].SI.click();’;
  crm.Browser.MainFrame.ExecuteJavaScript(strTemp,’about:blank’,0);  //

See demos\guiclient directory for an example.

Update: an example to set text of an input field on the iGoogle page:

procedure TMainForm.actDomExecute(Sender: TObject);
var
  q: ICefDomNode;
begin
  crm.Browser.MainFrame.VisitDomProc(
    procedure (const doc: ICefDomDocument)
    var
      q: ICefDomNode;
    begin
      // "q" is the ID of the text input element
      q := doc.GetElementById('q');
      if Assigned(q) then
        q.SetElementAttribute('value', 'Hello, world');
    end
  );
end;
var
s: string;
….
s := ‘document.getElementById(‘#39’next_button’#39′).click();’;
              chrom.browser.MainFrame.ExecuteJavaScript(s, ‘about:blank’, 0);

没时间整理,凑合看看

发表评论