How can I programmatically click on this web page button

92 Views Asked by At

I have a Delphi 2007 application that generates a lump of JSON. In order the validate the JSON quickly I was submitting it via the URL to JSONLint.com (as here: https://jsonlint.com/?json=%7B%22hello%22:%20%22world%22%7D). The amount of JSON you can submit this way is limited however, so I resorted to copying the JSON to the clipboard and then invoking JSONLint.com, which loads the validation page and leaves focus in the memo where the text to be validated is submitted. That just left the manual steps of:

  • Ctrl-V to paste the JSON into the memo.
  • Click on the Submit JSON button.

I want to automate these last 2 steps. I am using SendInput () to send a Ctrl-V to the memo, but I can't see how to move focus to the Submit JSON button. Once focus is in the memo, the only way I can find to move it elsewhere is Ctrl-L to move focus to the address bar, then successive tabs to move it to the next tab-stoppable element. Once we tab into the memo however successive tabs are just entered into the memo text. So my question:

How can I "click" on a particular element on a browser web page?

<div class="validate">
  <button type="submit" data-ga="validate">Validate JSON</button>
  ...
</div>

I don't need it to be browser-agnostic (using Chrome as the default browser).

0

There are 0 best solutions below