I want to start google-chrome and then send the Ctrl+A to the chrome process, to begin recording with ScreenCastify. I have set the shortcut key for the ScreenCastify to Ctrl+A.
Following is the code snippet I have used:
!#!/usr/bin/expect
spawn google-chrome --new-window <url>
send "\x01";
interact
The Ctrl+A is not triggering the recording on the browser.
Expect cannot work with GUI programs like Chrome. So, I used xdotool.
Related
I currently manually open HTML files using Brave Browser and print the files to pdf files. I want to automate this process in the command line. Is there a way to do it? Since Brave is based on chromium, solutions based on chromium and google-chrome are also welcome.
This is a common use for calling the executable in headless or kiosk modes.
Your milage may vary compared to running heads up with a robotic puppet to press buttons for you, but more often than not is so much simpler for every day basic use in a batch file for multiple uses it is a second or so for each pdf generation.
Edge is not different to Brave or Chromium's so find the executable and append here using windows user folder
--headless --enable-logging --print-to-pdf="%UserProfile%\Documents\Demofile.pdf" --disable-extensions --print-to-pdf-no-header --disable-popup-blocking --run-all-compositor-stages-before-draw --disable-checker-imaging "HTTPs://url"
So darn quick I did not know it had run until opening the result, however note it needs the target to not pop-up blockers like google does, hence next step up is a button pusher to replace you by eating cookies.
I am newbie in Puppeteer and i am trying to rewrite my Autohotkey scripts. I cannot find yet how create message box in Puppeteer as in Autohotkey. Is it even possible?
Something like this:
Sleep, 300
MsgBox, Its finded!
WinActivate ahk_exe firefox.exe
WinMaximize ahk_exe firefox.exe
puppeteer is a node.js package that uses a headless (invisible) Chromium browser, so by itself it is unable to show a dialog box as that browser has no GUI.
However using another package like node-notifier in your script you can send a system notification:
And to run a program at the end of your script you would use a package like execa.
I am using geo-location for a site running locally on my machine using HTTP on Chrome. However this does not work as I am running on HTTP as opposed to HTTPS.
On the console it says:
getCurrentPosition() and watchPosition() no longer work on insecure origins.
To use this feature, you should consider switching your application to a
secure origin, such as HTTPS. See https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-powerful-features-on-insecure-origins
for more details.
Accoriding to Deprecating Powerful Features on Insecure Origins its says to start chrome using --unsafely-treat-insecure-origin-as-secure="http://example.com" flag. The command I ran was similar to:
chrome.exe --unsafely-treat-insecure-origin-as-secure="http://hello.app"
However, the same error message still appears.
How can I fix this issue.
None of the solutions worked for me.
I achieved this by following steps.
Type chrome://flags/#unsafely-treat-insecure-origin-as-secure in the address bar.
Add the origin which you need to treat as secure as shown in the below image.
Relaunch chrome.
You must have missed some steps. Try to follow this
Go to File Explorer then paste this to address bar >> C:\Program Files (x86)\Google\Chrome\Application (or just go to where you can find your chrome.exe)
Right click chrome.exe > send to > Desktop (Create Shortcut)
Go to your desktop then find the chrome shortcut you've created.
Rename it to ChromeForTesting (this step is optional)
Right click the shortcut, then Click Properties
At the "Target", paste the following at the end of the link
--user-data-dir=/tmp/foo --unsafely-treat-insecure-origin-as-secure=http://example.com
so Target should look somewhat similar to this
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=/tmp/foo --unsafely-treat-insecure-origin-as-secure=http://example.com
Click Ok..
During testing close all of your opened google chrome browser.
Then double click ChromeForTesting shortcut (the one you've created), when a prompt appears, just click ok..
EDIT: If the steps above does not work for you, you might be using Chrome V63, update it to V64 above cause this flag is messed up in V63.
P.S. If it's still not working follow these extra steps
At your drive C, create a folder and name it "ChromeTempFiles".
Then in your --user-data-dir= you change the value into "C:\ChromeTempFiles"
Add these to your target as well
--allow-running-insecure-content --reduce-security-for-testing
so your target should look like this now
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=C:\ChromeTempFiles --unsafely-treat-insecure-origin-as-secure=http://example.com --allow-running-insecure-content --reduce-security-for-testing
You should also use a temproary fresh profile for that session. something like this:
chrome.exe --user-data-dir=/test/only/profile/dir --unsafely-treat-insecure-origin-as-secure="http://example.com"
Just an update to this for Chrome 70. This works perfectly
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=C:\ChromeTempFiles --allow-running-insecure-content
Now does anybody know if there is an equivalent for firefox?
For Chromium 44 use
--unsafety-treat-insecure-origin-as-secure=http://192.168.0.101:3000
instead
--unsafely-treat-insecure-origin-as-secure=http://192.168.0.101:3000
See that bug
In Google Chrome, you simply type into the address bar, "chrome://flags", and search for, "--unsafely-treat-insecure-origin-as-secure", enable that flag, and enter into the field below (multiples may be entered separated by a comma) the domain you wish to treat as secure. This may or may not compromise your security, but I would assume not as getCurrentPosition() and watchPosition() are somewhat recently deprecated features. this works for publicly served domains, as well.
With Chrome 79 this setting doesn't work no matter what.
What I ended up doing was to configure the domain on a VPS to show some test webpage and then generate a valid certificate for it using Let's Encrypt's certbot.
Then I copied that certificate to my machine and it's now valid.
I would like to debug a Tampermonkey script with Chrome's console, but I can't find my script in the list..
Am I doing something wrong, or is it just that the Tampermonkey scripts don't appear there? And in that case, how can I debug it?
Tampermonkey is simply an extension that injects boilerplate scripts to evaluate your custom scripts, so you can debug any of these scripts if you can find them..
The trouble is that it is evaluating userscripts as if someone called eval() on them, so you will see VM### instead of something nice like myscript.js and you can't normally navigate to them like permanent scripts.
Instead, add debugger lines:
Settings Checkmark:
TamperMonkey Dashboard -> Settings -> General (Config mode: Advanced) -> Debug scripts
Or, in your userscript add the line:
debugger;
like so:
(Doing this at the top of a userscript is equivalent to the Tampermonkey setting)
When you have a console open on a page using the script it will pause when the debugger lines are hit and show you your source file (surrounded with some tampermonkey boilerplate).
Which should look like this:
You can then instrument any other lines you need to from within the debugger.
If you run into trouble, you can also debug the main logic of tampermonkey itself by opening the background page inspection in chrome://extensions. It prints nice messages to let you know what it is up to which you can use to jump around in its code.
Is there a way to ignore the confirmation dialog box of chrome when press ctrl+p (Version 31.0.1650.63 m). I tried adding "--kiosk --kiosk-printing" flags to the end of the “Target:” field. But It gives an error msg.
"The name 'C\Program Files\Google\Chrome\Application\chrome.exe --kiosk --kiosk-printing' specified int the target box is not valid. Make sure the path and file name are correct."
Any one can help?
Check this and follow the steps:
Launch Chrome and check that the Chrome Version is at the latest version (18.0.1 or higher )
Type about:flags in the address bar and ensure that the Disable Print Preview flag is NOT enabled (Print preview must be enabled for Kiosk Printing to work)
Close the browser
Find the browser shortcut on your desk top, right click and select 'properties'
Append the following text to the end of the target field: --kiosk --kiosk-printing
Save, and launch Google Chrome. It should now load in full screen (kiosk) mode
The print preview will appear on your screen, but will instantly print a receipt to your default printer.
Reference
You need to make edits to the target when Chrome is completely off, Chrome is not enough to close.
Open task manager, go to processes, find Chrome, end the process, then do your own edits, and when you open Chrome the way you want it to work.
So :
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-print-preview
Or
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk-printing