Safari - How to click on a google ad scriptomatically

Hi, I’m trying to test some pages on a website. I’d like to scriptomatically click on the various ads on the page. The ad or ads can be anywhere on a long page, and one would usually have to scroll down to see them. They appear due to some google javascript gizmo that rotates in different sized ads, so they don’t seem to have a predictable string to address. I know I can send javascript commands to Safari but I can’t figure out what commands to send. Any insight or help would be appreciated!