Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Get input value

Post Reply
Laertes
Posts: 29
Joined: Fri Apr 27, 2018 1:27 pm

Get input value

Post by Laertes »

Hello !
I ran a test running the command in the google chrome console and returned the input value typed. How do I pass this value to a string?

I used this command in google chrome

Code: Select all

document.getElementById("login-email").value
In delphi without success

Code: Select all

var S: String 
emailLogin:= chromium1.Browser.MainFrame.ExecuteJavaScript('document.getElementById("email").value;','about:blank', 0);
Error:
uMiniBrowser.pas(4804): E2010 Incompatible types: 'string' and 'procedure, untyped pointer or untyped parameter'
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Get input value

Post by salvadordf »

Chromium doesn't allow to execute and assign JavaScript values like that.
You need to use a special JavaScript function that executes Delphi code. That JavaScript function is called "JavaScript extension".

Read this :
https://bitbucket.org/chromiumembedded/ ... gration.md

Each code example in that document has a Delphi demo in the "demos\JavaScript" directory. Many demos in that directory do what you need.

Check out the JSExtension demo to see how to get a string value from the web page and send it to Delphi.
Post Reply