I would like to simulate the mouse click on a page. I'm using TChromium in Delphi.
I've tried the following code, but it did not work.
code := 'document.getElementById(_2lkdt).click();';
Chromium1.Browser.MainFrame.ExecuteJavaScript(Code, 'about:blank', 0);
The page button is this:
<button class="_2lkdt">
<span data-icon="send" class="">
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="#263238" fill-opacity=".45" d="M1.101 21.757L23.8 12.028 1.101 2.3l.011 7.912 13.623 1.816-13.623 1.817-.011 7.912z"></path>
</svg>
</span>
Solution:
Use
document.getElementsByClassName().Example:
HTML part (button_tchromium.html). I've defined class for testing purpose.
DELPHI part:
Just for this test, I use two buttons on a form, one for loading the html file and another for executing javascript. Just check
getElementsByClassName()browser support.Notes:
Tested with Delphi7 and TChromium (Delphi Chromium Embeded, dcef3-2378 branch).