I am trying to automate a javascript function call on an external webpage.
the line of code I want to execute is triggered by the click of this div
<div class="vote_btn 151" onclick="vote('151', 'California Square Red Paso','145');"> VOTE ►</div>
Instead of automating the clicking of the div, I am just skipping to calling the vote function. I am attempting to do this in two browsers. Here is the applescript for safari:
tell application "Safari" to do JavaScript "vote('151', 'California Square Red Paso', '145');" in document 1
and for chrome:
tell application "Google Chrome"
tell window 1
tell tab 1
execute javascript "vote('151', 'California Square Red Paso', '145');"
end tell
end tell
end tell
the problem is, I am getting weird errors. For chrome, it says "vote is not defined" and safari "variable vote is not defined". It seems like my applescripts aren't able to access the javascript? I know there are similar questions to this on stackoverflow but I have read and tried all of the solutions from them with no successful results. Any help will be greatly appreciated!