Spectron: how to test Electron `shell.openExternal('some url')` - node.js

I'm writing and E2E test for an application written in Electron. I need to test a button which calls in effect shell.openExternal('link') where link is an external website. I've been looking in the webdriver docs for something which allows the test intercept this call, but it doesn't look like anything like that exists in the API at all.
1) if something like this does exist an I missed it in the docs, please enlighten me in ways of the light side of the force,
2) if not, then does anyone out there in stackoverflow land have a fancy work-around?
Thanks so much!

I came up with an answer. Instead of trying to intercept the click, I added an env var in the main app such that when set, the click will put an entry into the log instead of actually opening the external link in a browser. Then I use the API in spectron to slurp up the render process logs: https://github.com/electron-userland/spectron#clientgetrenderprocesslogs
Then I can just look for a custom string in the logs and I can judge the proper text is present.

Related

How to run server.js on client-side?

Can anyone explain me how I can run the server.js on client-side. Like I have index.html page and I've a button in it and I want to generate PDF on button click event and pass dynamic data to PDF. I've literally no idea about node.js. Any kind of help is appreciated. Sorry if the question is duplicate.
The simple answer is you don't. Node.js is a back end and the server.js file you have should not run on the browser. If you need the functionality on server.js after the first load you need to use something like ajax to communicate with the server. Or you could try to get your server code to run in the browser, but that may not work for all browsers and is probably a bad practice.

How to pass message from chrome to extension to developer?

I have a small chrome extension that helps users to quickly search for Pokémon Content and I'd like to know if there is a way to pass a message from my users to me...
I'd like to do this to get data from my users, data like what is being searched most, the most used options, things like this for curiosity...
Is there any way to do something like this?
I thought about creating another extension to pass message, but as far as I know, Chrome Extensions can only pass messages to another extension the user has...
So, is there any way to do something like this?
You could send the information to a server and store it in a database, or a log file of some kind. I know I've used multiple chrome extensions of some kind in the past that use a connection to a server hosted by the company/developer that created the plugin.

How to launch Boxee's web browser?

I am building a Boxee app and would like to, in response to certain user actions, open Boxee's web browser with a given URL. Boxee's documentation is a little light here (by my eyes).
Is this possible to do and if so how?
Check the API here http://developer.boxee.tv/JavaScript_API#browser
I guess navigate is the thing you re looking for: navigate(url:String):Void
browser.navigate("http://www.yourpage.com");

Can I capture JSON data already being sent with a userscript/Chrome extension?

I'm trying to write a userscript/Chrome extension to capture JSON data being sent while using a web service so that I can reformat it and display selected portion on page. Currently the JSON is sent as the application loads (as I've observed from watching traffic with Fiddler 2). Is my only option to request the JSON again or is capture possible? As I'm not providing a code example, a requested answer is even some guidance on what method / topic to research or if I'm barking up the wrong tree.
No easy way.
If it is for a specific site you might look into intercepting and overwriting part of a code which sends a request. For example if it is sent on a button click you can replace existing click handler with your own implementation.
You can also try to make a proxy for XMLHttpRequest. Not sure if this even possible, never seen a working example. You can look at some attempts here.
For all these tasks you probably would need to run your javascript code out of sandboxed content script to be able to access parent page variables, so you would need to inject <script> tag with your code right into the page from a content script:

Automatically saving web pages requiring login/HTTPS

I'm trying to automate some datascraping from a website. However, because the user has to go through a login screen a wget cronjob won't work, and because I need to make an HTTPS request, a simple Perl script won't work either. I've tried looking at the "DejaClick" addon for Firefox to simply replay a series of browser events (logging into the website, navigating to where the interesting data is, downloading the page, etc.), but the addon's developers for some reason didn't include saving pages as a feature.
Is there any quick way of accomplishing what I'm trying to do here?
A while back I used mechanize wwwsearch.sourceforge.net/mechanize and found it very helpful. It supports urllib2 so it should also work with HTTPS requests as I read now. So my comment above could hopefully prove wrong.
You can record your action with IRobotSoft web scraper. See demo here: http://irobotsoft.com/help/
Then use saveFile(filename, TargetPage) function to save the target page.

Resources