Silent install for Safari extension on Mac without any user prompting - macos

I am setting up Selenium testing for Safari 5 on Mac. I need to install our Safari extension before hand, and it needs to happen silently and without any user prompting. From previous posts, I've found this works in that it loads the browser with the extension:
open -a Safari okta.safariextz
But it leaves the browser opened with a prompt to the user: "Are you sure you want to install the extension?"
Selenium doesn't have access to this prompt and can't click install. I need to configure Safari such that it does not prompt the user to install, but just allows the extension to be installed.
Is there any way to do this?
Any pointers appreciated.
-Denali

Edit: Possible new method: The answer here might suggest (it's somewhat unclear) that, with a possible risk of messing up your future safari upgrades, you might be able to manually install an extension, skipping the confirmation prompt, via a file move and a plist hack. I haven't tried it, but it looks as if it might work:
If you're just doing this for in-house deployment and don't mind if it breaks on a Safari upgrade, then you can quit Safari, install the extension into ~/Library/Safari/Extensions and update ~/Library/Safari/Extensions/Extensions.plist (the format is rather obvious; /usr/libexec/PlistBuddy is useful for such things).
You can't do what you're after--at least, not with any commandline switch or plist hack that I know of. Extension install confirmation is a core part of Safari's security model, and is not easily circumvented.
Instead, I'd consider using automator (if you're not familiar with it, think Selenium but for desktop apps, and more) to send a click on the appropriate button, and then distributing an automator app that launches safari with the appropriate parameters, sends the click when the extension dialog appears, and then goes on to run Selenium-based (rather than automator-based) automations. To get started, I'd check out the following links:
Automating via applescript rather than the "duplo legos" automation builder: http://www.mactech.com/articles/mactech/Vol.21/21.06/UserInterfaceScripting/index.html
Very brief overview of macro recording (you hit record, send the click you want, hit save, and you can re-execute your recorded actions): http://automator.us/leopard/features/virtual-user.html
My favorite intro to automator tutorial: http://cjrtools.org/mac/tutorials/autohowto.html

I don't believe there is any way to do a silent extension install as it would be a security hole. You may want to try incorporating an AppleScript to do the extension install before running your Selenium tests.
Here is another question on StackOverflow with AppleScript details for Safari extension reloading that can be used for your purposes:
How to reload a Safari Extension from the command line?

Related

On macOS how can I open a gui .app hidden or off screen?

I have a cross platform need to open a gui application programmatically, but keep it hidden from the user. Effectively, I want a command line driven interface to act as a wrapper over this gui app, and insulate the end user from seeing or interacting with it. The program is from a third party, I did not write it, and I can't edit it.
I can do this one way or another on Windows, on Linux, and (in theory) on older versions of Mac, but not the most recent ones. On Windows, I can use the native api ShellEx with a hide window parameter. It's very easy and straight forward. In Linux, I can can render a gui app to a virtual frame buffer (using xvfb).
On macOS, the open command has a --hide and --background option, but they don't have any effect (at least on this app...)
I tried changing the plist file and found that LSUIElement will hide the app from the docker, but it still shows up on the screen. LSUIPresentationMode=4 or 3 OUGHT to work for exactly this, but apparently that doesn't do anything anymore as of a few os versions ago...
I tried the approach of moving the .app off of the screen with AppleScript. That works, but you have to manually grant permissions for such a thing to occur via System Preferences. In prior versions of Mac, those permissions could be twiddled on the fly via sqlLite (so long as you had sudo rights), but now they blocked that too. You can only pull that off apparently through a process of disabling "SIP" and forcing a reboot. That is totally outside the realm of what I want.
I've tried using the xvfb approach on Mac (jumping through hoops to acquire the binary they use to include stock, and now dropped), but I'm not having luck with that. I don't think it's possible to direct a mac .app to another display is it? A .app does not render on X11 by it's nature right?
What other clever ways might there be to hide a third party app on a mac? (and that still works in most recent os versions!)

Starting Chrome on macOS from the Finder with extra command line parameters

I want to stuff remote debugging and other esoteric dev-only only parameters to the Chrome application when it starts but I want it to be always there, including when I click on the app icon.
E.g.:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
How do I pass these command line parameters to the app directly?
I ended up creating an automator application with as shell task. Customized the icon and replaced Chrome.app with the new app in the dock.
I am still looking for a way to change the settings in Chrome so it can connect with remote debugger "on-demand" for specific tasks (not everything as it is set now) but that doesn't seem to be possible at this time. The VSCode folks have apparently solicited the Chrome team to provide this functionality. Stay tuned...

Launch Firefox from Finder with logging modules

I have found this site: https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging
My problem is: The settings for about:networking only work for the current session. And I have no interest to always start Firefox from the console. Is there a way to launch Firefox (under Mac OS X) via Finder and to permanently enable those logging features?
BG
I'm not a Mac user, so this might be not the best way. However, you might try using an approach similar to running Firefox with multiple profiles, as documented here on MDN. It suggests creating an Automator application that runs a shell script. You can follow this guide, which tells you to:
Open Automator
Go to File->New->Application
Choose Utilities group under Library
Drag Run Shell Script to the workflow pane on the right
Paste the script used to run Firefox with logging enabled
Choose Save As and store it somewhere
You should be good to go.

Open Chrome from terminal with developer console open

I can run Google Chrome from the command line using $ google-chrome, but what flag can I pass to open it with developer console already open, preferably open to the console tab?
I checked the man page for google-chrome but it states that
Google Chrome has hundreds of undocumented command-line flags that are added and removed at the whim of the developers.
I'm hoping one of those undocumented flags does what I want.
The flag you're looking for is --auto-open-devtools-for-tabs. Please note, that you should quit Chrome before this setting will take effect.
This has worked at least since Chrome 55.0.2883.87 m (the latest version as of initial post)
A Google employee maintains this list of automatically updated Chromium flags. There doesn't seem to be a flag for opening Chrome with developer console open.
Seems there is no such option. I added a feature request in Chrome product forum
https://productforums.google.com/forum/#!category-topic/chrome/give-feature-feedback-and-suggestions/mac/Stable/3HYIAl8_ndc
What exactly are you trying to achieve by that? If you are trying to run some kind of automated tests, you should try out PhantomJS.

ClickOnce is it a good WIndows installer for an invisible installation?

Is ClickOnce a viable technology for a software that wants to be installed in Windows, from all browsers, as invisibly as possible (I want to minimize, or completely remove, the "Do you want to save file", "Do you want to run this file", etc)?
Will ClickOnce only install from IE, or is it supported by Firefox, Chrome, Safari, etc?
For guaranteed installation, a use must install a ClickOnce application through Internet Explorer 6 or higher. Also, the user will need Microsoft Windows Installer. (I'm having a tough time quickly finding which version of the MS Installer is required, but if the user has purchased their PC within the last 6, or so, years, they will be fine.)
Yes, ClickOnce can still be installed through Firefox and Chrome, however, they will have to go and search for a plug-in or extension and install that, first, before installing your software. In my case, I test for the user's browser using JavaScript. If they are using anything but Internet Explorer, I hide the installation instructions and links, and prompt them to return from within IE.
In regards to your comments, it is also worth mentioning that ClickOnce isn't 'invisible'. The user will need to click at least two buttons. One to start the download and another which always pops up in regards to application security. They could have to click through a couple more screens if you have to bundle any prerequisite software. At a minimum, most pre-requisites require the clicking of an Accept button to a EULA.

Resources