2 Replies Latest reply: Mar 11, 2013 6:02 AM by adayzdone
nevin009 Level 1 Level 1

I've seen many variations and parts of this, but can't connect the dots.  I need an automator script to:

1) Search for a defined (hard coded) text string in on a web page in Safari

2) Get the size & coordinates of the text string

3) Use the size & coordinates to determine the middle of the text string (horrizaontal & verticle)

4) Left mouse click on the middle point determined in the previous step


I think this would be very useful and could work (depending on how its done) for both buttons and text links on web pages even if they have java scripts to execute the links.

Automator, Mac OS X (10.7.5)
  • Camelot Level 8 Level 8
    Mac OS X

    This is way, way, way beyond Automator's top-line capability - that is there's nothing directly that Automator can do in this respect. The cloest you can get it an automator action that fires off some other process to do the work, in which case you might as well go straight to the source.


    I suspect that you're way, way over-thinking the need, though - why do you care about finding the object's position in the page? or clicking it directly? It would be easier (although not necessarily 'easy') to query the DOM (or even the source) with a corresponding JavaScript action to 'click' the object. Unless there's something special about clicking in the middle (which, since you're talking about text, hardly seems likely), just following the link the text points to should be sufficient.


    It's far, far easier to write a JavaScript to identify an object on the page and 'click' it, than it is to try and drill down through screen renderings.


    There are numerous examples online of using AppleScript to click links on a page - remove your 'click in the center of the text based on its position on screen' requirement and you're almost there.

  • adayzdone Level 2 Level 2

    Camelot is right. You should post the URL along with the button you are trying to click and someone may be able to help you.