How create message box in Puppeteer? - puppeteer

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.

Related

pywinauto: accessing chrome gui

I am trying to select a printer and print on chrome browser, using pywinauto, but I am not able to access the gui components. I can see the components in Microsoft Inspect.exe in UIAutomation mode. (See screenshot).
I have started chrome with --force-renderer-accessibility flag.
I tried several things but I am not able to access anything in the chrome window. Is it possible to access the chrome gui components using pywinauto?
screenshot: ]1
Probably you use default backend="win32" which is used when you call Application(). To use MS UI Automation you have to set backend="uia" when instantiating Application object:
app = Application(backend='uia').start('chrome.exe <other params>')
My student wrote example script dragging file from explorer.exe to Google Drive in Chrome. Is it working for you?
P.S. If you already use backend='uia', please provide more detailed description with some code and output.

Debug tampermonkey script

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.

Expect to send the Ctrl+A to the browser

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.

Automate Chrome console from Desktop app?

I'd like to be able to send info to the Chrome developer console from my application.
For example, my app has some json. I'd like this json to show up in either an existing, or newly created instance of the chrome dev tools console.
Is this possible? If so, any pointers to examples? Note that the platform should be any language, not just javascript. And definitely not a site already running in Chrome. I'm interested in implementing this in another process.
Do you thought of running your app in an environment which is pretty much like a browser?
Node.js
or (this is a whole webkit browser)
phantom.js
Otherwise you could call Chrome directly via commandline and try to simulate the dev tools key stroke like explained here:
Is there a command line argument in Chrome to start the developer tools on startup?
The command of displaying something in the Chrome console is e.g. console.log and it is at the end Javascript. All Console commands are described here:
https://developers.google.com/chrome-developer-tools/docs/console-api
The closest I've seen so far is this library:
https://github.com/ccampbell/chromelogger
which seems to allow logging to the Chrome Console from lots of other server side apis, but no desktop APIs.
This can be done on Mac using osascript. Save the following as a script and run it:
#!/usr/bin/osascript -l JavaScript
var chrome = Application('Google Chrome');
//chrome.activate();
chrome.includeStandardAdditions = true;
var currentTab = chrome.windows[0].activeTab()
currentTab.execute({javascript: 'console.log("Hello")'})

Debugging JSON using Chrome's Dev Tools

How do I access the results array from the following page using Google Chrome's console?
twitter.com/search.json?q=stackexchange
I keep getting this error:
ReferenceError: results is not defined
If what you really want is to browse this result set in a convinient way, just install one of JSON viewers for Chrome (preferably JSONView).
If you don't want to install any plugins, just run this:
JSON.parse($('.webkit-line-content').innerHTML);
in the console on page:
view-source:https://search.twitter.com/search.json?q=stackexchange
You can use console.debug() function in chrome console tab.
example:
console.debug(results)