Documentation on Application.launch() in JXA? - javascript-automation

Where can I find documentation on Application.launch() in JXA?
Application('Safari').launch();
It seems Application.launch(), unlike Application.activate(), only starts the application process without actually open or activate an application window.
I searched the Internet and find no documentation on this function.

The launch command:
Launches an application, if it is not already running, but does not send it a run command.
If an application is already running, sending it a launch command has no effect. That allows you to open an application without performing its usual startup procedures, such as opening a new window or, in the case of a script application, running its script. For example, you can use the launch command when you don’t want an application to open and close visibly.
via https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW51
Note that while the above documentation is for AppleScript, it mostly applies to JXA, too.

Related

How to setup and save qemu running option

I'm using qemu to replace bochs (since it doesn't update anymore)
In bochs, I can save the running settings into files and reload it. Furthermore, there will be a listed table of running options while boot up.
I'm wondering if I can do the same with qemu, save running settings such as cpu model, and other stuffs into some files and reload it next time I run emulation.
And if there exists a full listed running option table like thing for me to have a complete view on which options I can set.
Thanks a lot!
For this sort of UI and management of VMs you should look at a "management layer" program that sits on top of QEMU. libvirt's "virt-manager" is one common choice here. A management-layer will generally allow you to define options for a VM and save them so you can start and stop that VM without having to specify all the command line options every time. It will also configure QEMU in a more secure and performant way than you get by default, which often requires rather long QEMU command lines.
QEMU itself doesn't provide this kind of facility because its philosophy is to just be the low-level tool which runs a VM, and leave the UI and persistent-VM-management to other software which can do a better job of it.

localhost refused to connect, after returning from paypal sandbox

Testing with PayPal checkout with Selenium & chrome webdriver.
I have tried using another domain name, localhost and 127.0.0.1
It may be important to note i am running inside a Vagrant machine (homestead)
Also tests run manually work.
I believe the issue to be an environment variable
PAYMENT_SANDBOX_PAYPAL_URL=http://localhost:8000/checkout/, however that is confusing as from what i understand there should be no difference when running automated tests with a webdriver.
Is this a networking issue with vagrant and my host? how would i diagnose this?
I understand this is a pretty specific question to the mentioned setup, however i think other new selenium users like myself will find it useful, especially when using codeception and laravel.
Perhaps it has something to do with whitelisting ip's?
Here is the current command.
java -jar vendor/se/selenium-server-standalone/bin/selenium-server-standalonjar -Dwebdriver.chrome.bin="/usr/bin/google-chrome" -Dwebdriver.chrome.driver="vendor/bin/chromedriver" -Dwebdriver.chrome.options="--whitelisted-ips=173.0.82.77,127.0.0.1"
I would guess chrome is running with different profile when launched manually (when it is able to load) and when launched through webdriver. WebDriver launches the browser in a different profile which may be very different than default profile which may include some settings related to proxy/networking.
From https://sites.google.com/a/chromium.org/chromedriver/capabilities
By default, ChromeDriver will create a new temporary profile for each session. At times you may want to set special preferences or just use a custom profile altogether. If the former, you can use the 'chrome.prefs' capability (described later below) to specify preferences that will be applied after Chrome starts. If the latter, you can use the user-data-dir Chrome command-line switch to tell Chrome which profile to use:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
You can create your own custom profile by just running Chrome (on the command-line or through ChromeDriver) with the user-data-dir switch set to some new directory. If the path doesn't exist, Chrome will create a new profile in the specified location. You can then modify the profile settings as desired, and ChromeDriver can use the profile in the future. Open chrome://version in the browser to see what profile Chrome is using.
Are you sure, that PayPal Sandbox URL should be a local URL, not accessible from outside of your box?
Please provide more details! What web framework/web server do you use? What are libraries you used to get PayPal working.
I think, if the behavior differ when running Selenium, it is an issue completely related to WebDriver settings, or it's work together with Vagrant.

How to quit Chrome process from within app (on Mac OS X)

I have a custom web app written in Angular that is launched from a bash script. The app provides a GUI for the user to enter some information. Once the user is done, I'd like the bash script to continue execution, however I am unable to kill the chrome process from within the app, I can only close the window (Mac OS X). Is there a way to kill the chrome process when the window is closed? A command line flag or some other workaround?
A solution is using the chrome.windows API, by using the remove() function, which will terminate a window and all its tabs. More information can be found here: https://developer.chrome.com/extensions/windows#method-remove
Another solution, you could try accessing the following url in Chrome, but keep in mind that its only for testing purposes: chrome://kill.

Gnome 3 automatic execution of a script that needs network

my old father is using ubuntu-gnome. He has no static ip address. In order to perform remote administration, I need to know his ip. I was using dyndns free account (configuration in the adsl modem), but this will stop working in a couple of days.
I would like to run a script each time he logs in to publish his ip on my website. I have tried to put a script on the boot, but the network is not available. It seems that it is gnome 3 that starts the network, but I do not know much about gnome 3.
How should I do to have my script run automatically as soon as the network is available ?
One possible non-elegant solution for this is to put your script in his cron to run every X minutes :)
Looking to mine /etc/NetworkManager/ looks like there is a folder dispatcher.d that I think it'll do what you want. Just experiment with a bash/perl/python w/e script in there set the permission appropriately. You can find the UUID in the system-connections/ folder. More information is available in man networkmanager.
EDIT: Look what I found: https://askubuntu.com/questions/13963/call-script-after-connecting-to-a-wireless-network. Seems like this is exactly what you want.
The easiest way is to use another dynamic DNS service. I used to use my own. You could also put curl or wget command to cron or create a systemd service that will call that command periodically. As a target you would have to use your machine with a web server where you can see the IP in your logs.
It is not Gnome that connects the network, it is a system service called NetworkManager. It tries to connect at boot if possible. In some cases it waits for wireless signal, in other cases it waits for a user password. I recently verified that in Fedora, NetworkManager properly implements the systemd's network-online.target but it may have yet to be fixed in other distributions, see the upstream bug report.
https://bugzilla.gnome.org/show_bug.cgi?id=728965
If you want to run a system service just after boot, you need to use:
[Unit]
...
Wants=network-online.target
After=network-online.target
You could also just run a script that calls nm-online at the beginning to wait for the network connectivity if you can expect the connectivity to come up in reasonable time, otherwise it times out. Such a script can be run from any environment including a user session.
And, as noted already, you can put a script into /etc/NetworkManager/dispatcher.d that will be called on any network configuration change and such a script can then filter connection up events and start the notification script.

Integration of Selenium Webdriver with Hudson - Unable to open the browser

I have integrated my selenium Webdriver scripts (using TestNG) with Hudson. i invoked my job through ant . My problem is my scripts are not running successfully also the IE browser is not getting opened However Build is creating successfully.
Note -
1) I am triggering build on Hudson from different machine on the same network with administrative access.
2) I have used excel 2007 for developing the script ( data driven framework) however on Hudson server its open office.could that be the issue?
At this moment i am not using selenium grid .please provide any suggestion
The reason for this is because Hudson/Jenkins is running as a Windows service. Recently, Microsoft changed services so that they run on their own invisible desktop. This didn't used to be the case until a few years ago. For this reason, even if you check "interact with desktop" , the desktop that is being referred to is invisble .
So, what you have to do is run Jenkins (not Hudson) as a service only for the master server. For the Selenium tests, you need to run another slave Jenkins server as a foreground shell process and the selenium tests need to be launched from that Jenkins instance instead.
If you think the instructions for setting up a slave are too hard, then you should know that it isn't required that you run as an official configured slave. You can run as a separate slave (make sure port number is different).
Also, if you are running Grids and Nodes on Windows, you might like these scripts I made.