As you click Tchromium element using getelementbyid ('element'). click; ?????

3,241 views
Skip to first unread message

Underground

unread,
Oct 20, 2011, 1:38:59 AM10/20/11
to delphichromiumembedded
As you click Tchromium element using ...

TWebBrowser in Delphi I could click on an element
using the following code:

webbrowser.oleobject.document.getelementbyid ('element'). click;

Can anyone help me how to do this in Chromium??

I await answers!

Christian Sciberras

unread,
Oct 20, 2011, 4:51:59 AM10/20/11
to delphichrom...@googlegroups.com
Simply execute it as javascript. No need to call it natively.

Underground

unread,
Oct 23, 2011, 10:49:52 AM10/23/11
to delphichromiumembedded
I tried using the following code, but without results:

var
code: string;
begin
code: = 'document.getElementById ("button"). click;';
ie.Browser.MainFrame.ExecuteJavaScript (code, 'about: blank', 0);

It could send me some examples??

Christian Sciberras

unread,
Oct 23, 2011, 2:58:34 PM10/23/11
to delphichrom...@googlegroups.com
Uh, the correct javascript would be:

  code := 'document.getElementById("button").click();';

Chris.

Underground

unread,
Oct 23, 2011, 5:17:23 PM10/23/11
to delphichromiumembedded
Ta tough guy saw!

Searching on Google found a way Q works in internet explorer

ie.navigate ('javascript: void (document.getElementById ("button").
());'); click

Thus the above works ie, not more chromium in ...
Any idea why?

Christian Sciberras

unread,
Oct 24, 2011, 2:22:30 AM10/24/11
to delphichrom...@googlegroups.com
I don't know how IE got to run that, but, that is not even javascript. The correct one would be:

  ie.navigate('javascript:document.getElementById("button").click();');

Chris.

Underground

unread,
Oct 24, 2011, 11:18:01 PM10/24/11
to delphichromiumembedded
Sorry to ask so much more to have to solve my problem =].

Able to use javascript in other pages with the above, plus the page I
need to use is not working.

Its clicking on the element using the code below?

q: = doc.GetElementById ('button');
if Assigned (q) then

q.SetElementAttribute (?,?)

WHAT SetElementAttribute put in?

Thank you for always answering my questions!

Christian Sciberras

unread,
Oct 25, 2011, 2:29:05 AM10/25/11
to delphichrom...@googlegroups.com
I would guess that SetElementAttribute takes a 'name' and a 'value' as parameters.

Chris.



Underground

unread,
Oct 30, 2011, 7:38:20 PM10/30/11
to delphichromiumembedded
Is there any parameter to click the button?

type

q.SetElementAttribute ('click', 'true') or

q.SetElementAttribute ('clicked', 'true')

Already tried, no longer works!

You know how to do using the setelementattribute??

Christian Sciberras

unread,
Oct 31, 2011, 3:21:44 AM10/31/11
to delphichrom...@googlegroups.com
You really need to get a clue on how DOM work.

The setElementAttribute method will only SET AN ATTRIBUTE.
Clicking an element is NOT an attribute.

    q.setElementAttribute('style', 'color: red;'); // for example

Chris.

Reply all
Reply to author
Forward
0 new messages