javascriptandroiddelphifiremonkeytwebbrowser

Trouble inserting text value into HTML input with TWebBrowser.EvaluateJavaScript()


I use TWebBrowser to insert data into a web form. My application is written in Delphi FMX and runs on Android. The element type text is not inserting the value string.

HTML:

<input 
  type="text" 
  name="txtCPF" 
  id="txtCPF" 
  size="18" 
  maxlength="14" 
  autofocus="" 
  title="Informe os onze dígitos do número do CPF." 
  onkeypress="javascript: return EntradaNumerico(event);" 
  onfocus="javascript: RemoveMask('txtCPF');" 
  onblur="javascript: FG_FormatarCPF('txtCPF');" 
  autocomplete="off" 
  value=""
>

I need to insert into element txtCPF the value type String '02403989987', but

wbConsultaCPF.URL := 'https://servicos.receita.fazenda.gov.br/servicos/cpf/consultasituacao/ConsultaPublica.asp';

Solution

  • I created a function in .EvaluateJavaScript() and it worked. Example:

    wbConsultaCPF.EvaluateJavaScript('(function() { document.getElementById("txtCPF").value = "012345"; })()');