How To Check If I'm At The Right Url In Applescript (chrome)
I'm new to AppleScript and having trouble with this: I'm creating a script for Chrome where I want to login to a site and check something for me. For now, I just need to check if I
Solution 1:
Here is a script that opens the location, waits til it's done loading, checks the url for a particular string, and if it's there, presses a button using javascript.
tell application "Google Chrome"
activate
open location "http://somesite.com"
set theTab to tab 1 of window 1repeatif (loading of theTab) is falsethenexitrepeatendrepeat
set theURL to URL of theTab
if theURL contains "login"thenexecute theTab javascript "document.getElementById('login-button').click();"endifend tell
You'll need to change what string the script checks for in the url. You will also need to learn the button ID. Just browse the the source code (Menu View/Developer/) of the page to find that, and switch it out for 'login-button'. Look for a line like:
<button class="login submit" value="Login now"type="submit"id="login-button">
Post a Comment for "How To Check If I'm At The Right Url In Applescript (chrome)"