Jump to content
Wagner

Chromium1.Browser.MainFrame.ExecuteJavaScript

Recommended Posts

Wagner

Estou tentando inserir valores dentro dessa input, com o codigo abaixo:

Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("FormRow-BUY-quantity").value="100";', 'about: blank', 0);


 

Estou usando o chromium cef4 https://www.briskbard.com/index.php?lang=en&pageid=cef  no rad studio 10.2, o codigo envia o valor para o input, mais depois de alguns milisegundos o valor desaparece do input, como se não tivesse sido renderizado no input.

Mais testando outra forma eu consegui enviar o valor conforme codigo abaixo:

procedure TMiniBrowserFrm.Button1Click(Sender: TObject);
var
  event: TCefKeyEvent;
begin
  FillChar(event, SizeOf(TCefKeyEvent), 0);
  event.kind := KEYEVENT_KEYDOWN;
  event.windows_key_code := ord('1') ;
   Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);
  event.windows_key_code := ord('0') ;
  Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);

  FillChar(event, SizeOf(TCefKeyEvent), 0);
  event.kind := KEYEVENT_CHAR;
  event.windows_key_code := ord('1');
   Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);
  event.windows_key_code := ord('0') ;
  Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);

  FillChar(event, SizeOf(TCefKeyEvent), 0);
  event.kind := KEYEVENT_KEYUP;
  event.windows_key_code := ord('1');
   Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);
  event.windows_key_code := ord('0') ;
  Chromium1.Browser.Host.Browser.MainFrame.Browser.Host.SendKeyEvent(@event);

end;


 

Eu gostaria de saber como posso corrigir o problema usando o javaScripit o que eu devo fazer para ele funcionar?

Chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("FormRow-BUY-quantity").value="100";', 'about: blank', 0);
<input class="sc-1c2873k-1 gszTkZ" type="number" id="FormRow-BUY-quantity" name="quantity" step="0.000001" min="0.000001" value="">

 

Edited by thoga31
GeSHi

Share this post


Link to post
Share on other sites

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

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.