Question

I recently updated to OS Mavericks and it appears a few of my applescripts dealing with Google Chrome have stopped working properly.

I have a simple function that opens chrome and creates a new window..

on openWindow()
  tell application "Google Chrome"
      activate
      set newWin to make new window
      tell active tab of newWin to set URL to "http://play.google.com/music"
  end tell
end openWindow

However, this gives me the error: Expected end of line but found property.

referring to the "tab" in "tell active tab of newWin." This link seems to offer a bit of help, but I'm still lost as to how to fix this issue. Can anyone help me get this working again? Thanks.

Was it helpful?

Solution

I'm having a similar problem, also on OS X 10.9.4, where a very simple script

tell application "iTunes"
    return persistent ID of (first source where kind is library)
end tell

every now and then returns the exact same error message:

NSAppleScriptErrorBriefMessage = "Expected end of line but found property.";
NSAppleScriptErrorMessage = "Expected end of line but found property.";
NSAppleScriptErrorNumber = "-2741";
NSAppleScriptErrorRange = "NSRange: {45, 2}";

It's not a real solution, but in my experience a computer restart gets rid of the issue (for a while). The whole problem looks like a bug in AppleScript to me.

Turns out I was running a Windows VM using Parallels at the same time. In the VM, there was also an iTunes instance. In essence, I had two different versions of iTunes on the same system. One that understands AppleScript and one that doesn't. Addressing the OS X iTunes like this solved the issue:

tell application "/Applications/iTunes.app"
    return persistent ID of (first source where kind is library)
end tell

Perhaps the problem in the original question can be solved the same way.

OTHER TIPS

Your code works for me with no errors in 10.9.2. So your error must be someplace else. I noticed I get your error if I call the handler using...

on openWindow()

However if I just use the following, which is how you should call the handler, then it works with no errors.

openWindow()

For example, run the code outside the handler like this and you shouldn't get any errors...

tell application "Google Chrome"
    activate
    set newWin to make new window
    tell active tab of newWin to set URL to "http://play.google.com/music"
end tell

As such it leads me to believe you are not calling the handler properly.

For that its simple

tell application "Google Chrome"
activate
set newWin to make new window
tell active tab of newWin to set URL to "http://play.google.com/music" 
end tell

but for that in full screen with no toolbar it is

    tell application "Google Chrome"
activate
set newWin to make new window
tell active tab of newWin to set URL to "http://play.google.com/music"
tell application "System Events"
keystroke "f" using {command down, shift down}

end tell

For anyone who has the same problem. My issue wasn't with the script, it was somehow related to the version of Parallels I had installed on my device. Uninstalling Parallels fixed my issue.

As hendrik said, if you specify that you want Chrome from Mac OS the issue should be solved. I was having this problem with Chrome, but then specified that I wanted to tell my Google Chrome on my mac os (Google Chrome.app) and it worked perfectly and compiled.

So based on the code above it would look something like this:

on openWindow()
    tell application "/Applications/Google Chrome.app"
    activate
  set newWin to make new window
    tell active tab of newWin to set URL to "http://play.google.com/music"
    end tell
end openWindow

Finally I got it fixed without removing Parallels Desktop.

Here are the basic steps:

First, cancel App sharing from your Parallels Desktop VM

Second, you need reset the Launch Services with the following command:

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed -r -f -v -domain local -domain user -domain system

Then, try your script again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top