1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <html>
        <head>
        <title>Test</title>
    </head>

    <body>
        <h1>Test</h1>
        <hr>
        <div id="a1">
            <div id="a2">
                <div id="a3">
                    <div class="hello">
                      <a href="http://google.com">Google</a>
                    </div>
                </div>
            </div>
        </div>

    </body>
</html>

The webpage is like above, and I cannot find any way to click it using AppleScript. I'm very new to AppleScript. I've searched Google, but none of them is working for above.

vaultah
  • 44,105
  • 12
  • 114
  • 143

1 Answers1

0

Try:

tell application "Safari"
    tell current tab of window 1
        do JavaScript "document.getElementsByClassName('hello')[0].firstElementChild.click()"
    end tell
end tell
adayzdone
  • 11,120
  • 2
  • 20
  • 37