0

I've been successfully using a script for a long time, which uses Chrome to calculate execute some javascript and return the result.

tell application "Google Chrome"
    tell window 1
        tell tab 1
            [do something here]
        end tell
    end tell
end tell

Today, after many months, I tried editing the script but the AppleScript Editor is refusing to save it (even without any changes, e.g. after typing a space and then deleting it...), showing an error message:

Syntax Error
Expected end of line but found number.

while highlighting the 1 of tab 1 as being the offender...

What is wrong with the latest version of the applescript editor or of Chrome? Any ideas how to work around this problem?

  • Using script editor 2.7 and Google Chrome 39.0.2171.99 (64-bit) on OS X 10.10.1 and your script runs fine (using activate instead of "[do something here]"). – Asmus Jan 20 '15 at 17:59
  • Which version of OS X are you running? – nohillside Mar 9 '15 at 12:13
1

I can actually get your example to work with no problems, just doing something simple:

tell application "Google Chrome"
  tell window 1
    tell tab 1
        get URL
    end tell
  end tell
end tell

That makes me think the problem might be in the "do something here" section of your script—I've never found Applescript's error messages to be very reliable.

That said, you could also try shortening your code:

tell application "Google Chrome"
  tell active tab of first window
    [do something here]
  end tell
end tell

Using my earlier, super simple example, this works for me:

tell application "Google Chrome"
  get URL of active tab of first window
end tell

I should also note that I'm using Script Editor 2.7 (176) on Yosemite 10.10.1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .