Here's the output :-)
"com.apple.finder" works fine.
The actual identifier is com.apple.finder, why should it be case insensitive?
As com.apple.Finder still works but causes a RuntimeError when it should just fail as not found.
The issue is that NSWorkspace.launchAppWithBundleIdentifier is case-insensitive, but NSRunningApplication.runningApplicationsWithBundleIdentifier is case-sensitive.
The problem then is that "com.apple.Finder" will not be found as a running application, so we try to launch it, which then brings Finder to the front (because it is already running). Then we sleep on the run loop for a couple of seconds and try again.
After looping a few times we raise an exception.
I think this might actually be an Apple problem...something to report to them. I just need to double check what I've claimed here first...
Hey, we all make mistakes.....right?
Let me know then and I'll direct my gaze over to radar.
1.9.3-p362 :003 > apple_contacts = AX::Application.new "com.apple.addressbook"
RuntimeError: com.apple.addressbook failed to launch in time
from /Users/mp4976qpa/Developer/AXElements/lib/accessibility/dsl.rb:136:in raise'
from (irb):3:in new'
Here again, it's case sensitive. The identifier actually is com.apple.AddressBook. Probably it's best if you check the Info.plist of the application.
Hmmm, that might have to be the work around for now. Fortunately, there are a few ways to easily get the bundle identifier for an application. Here's a non-exhaustive list of ways you can do it from within Ruby (with AXElements):
1: If the app is already running
2: If you know where the app is: