Currently on OSX Selenium driver start opens up a new Firefox icon on OSX. Also, the current application loses focus and thus interrupts e.g. your typing.
Is it possible to make Selenium launch Firefox on OSX such way that it would not take focus or cause extra action in Dock?
You can easily modify Firefox so it does not appear in the dock.
In Finder, right-click the Firefox app icon and choose Show Package Contents. Then open the Contents folder and edit
Info.plistusing Property List Editor (comes with XCode) or BBEdit/TextWrangler. Right at the beginning of the file add a keyLSUIElementwith a value of<true/>. In BBEdit/TextWrangler the beginning of the file would look like this:In Property List Editor, right-click any key and choose Show Raw Keys/Values, then right-click the top-level entry (“Information Property List”) and choose Add Row. Specify
LSUIelementfor the value of this item and mark the checkbox.I suggested using Property List Editor or BBEdit/TextWrangler instead of some other editor because most
.plistfiles are in a binary format theses days, and those tools can handle binary.plists. Other text editors will just display gibberish. However, I should mention that you can convert theInfo.plistfile to text using theplutilcommand line utility, e.g.:Then you can edit it in any text editor you like. You don’t even have to convert it back to binary afterward; the text format will actually work fine.
Anyway, save the info.plist file and close and relaunch Firefox. The icon (and menu bar) will now be gone. (No, it’s not possible to show the menu bar but hide the icon, but I don’t think this will bother Selenium.)
On to your second question: it’s technically possible to launch an application without giving it focus. For example, this Applescript launches Firefox and gets the list of windows, but does not send the
activatemessage that would bring it to the front.You can send any message; the
get windowspart is just a do-nothing for our purposes. The point is, you have to send Firefox some message to get it to launch (AppleScript knows you can’t send messages to apps that aren’t running, so it launches it for you, but in the background).Now I’m not sure sure how Selenium launches browsers, but it may be possible to modify it to launch Firefox using the
osascriptcommand line tool or something of that nature, and use the above command.I’ll leave it to you to put those pieces together…