I have a applescript I have been using for a while and it works good:
set js to "document.getElementsByClassName('The_Class')[0].click();"
tell application "Google Chrome" to tell ¬
the front window to tell ¬
the active tab to ¬
set jsResult to execute javascript js
Now I want to add a if and else to it. Like this but I can't find a way to solve it:
if the class ('The_Class') exist then
set js to "document.getElementsByClassName('The_Class')[0].click();"
tell application "Google Chrome" to tell ¬
the front window to tell ¬
the active tab to ¬
set jsResult to execute javascript js
else
tell application "Google Chrome" to activate
tell application "System Events"
keystroke "r" using {command down}
end tell
end if
Aucun commentaire:
Enregistrer un commentaire