_ap_ufes{"success":true,"siteUrl":"www.jucktion.com/tech","urls":{"Home":"https://www.jucktion.com/tech","Category":"https://www.jucktion.com/tech/c/mobile/android/","Archive":"https://www.jucktion.com/tech/2017/11/","Post":"https://www.jucktion.com/tech/pushbullet-notifications-automated-browser-testing/","Page":"https://www.jucktion.com/tech/about/","Attachment":"https://www.jucktion.com/tech/pushbullet-notifications-automated-browser-testing/pushbullet-web-test-complete-notification/","Nav_menu_item":"https://www.jucktion.com/tech/3985/"}}_ap_ufee Use pushbullet to get notifications for automated browser tests - Tech Junction

Use pushbullet to get notifications for automated browser tests

By | 2nd November, 2017 | 0 Comments

Pushbullet has been around for a long time now. It can be used for secure notification mirroring, notification channels, file sharing, and notification sync. It has clients for almost every device you can imagine from browsers to desktop computers. One of the pushbullet features I use the most is messaging from device to device. And since I’m into web automation, thought this would be a great way to incorporate notifications to let me know about the progress or completion of an iMacros test on a remote server.

Pushbullet web test complete notification

Pushbullet was once considered as one of the best apps on the Android enabling communication between desktop and smartphone easier. The features made workflow more productive and removed the hassle of having to check the phone every time a notification arrives. Then came the subscription model and the community backlash. While I only miss the Android actions while working on a PC, the free version is not very stripped out.

Here is a simple iMacros code I created to notify me of what’s happening during a test or to notify me when an analysis is complete. You can even send yourself debug logs or messages if you want. So it depends on your requirements.

The pre-requirements of this to work is you need to log into your pushbullet account on the browser, then grab the link which represents an account or a device to send the message. Pushbullet has unique URL for every friend and device you own. This URL makes it much easier to navigate on iMacros. You can just go to the person or device you want to send the message and then copy the link from the browser navigation bar.

Just replace the code of your URL on the first line. If you are using standard iMacros syntax without javascript, edit the 3rd line to reflect your message.

push.iim:


URL GOTO=https://www.pushbullet.com/#people/<[email protected]>
WAIT SECONDS=1
SET !VAR1 "THE TEST IS COMPLETE!"
SET !VAR2 EVAL("var msg = \"{{PUSH}}\"; msg = (msg == \"__undefined__\") ? \"{{!VAR1}}\" : msg;msg;")
TAG POS=1 TYPE=TEXTAREA ATTR=ID:message
EVENTS TYPE=KEYPRESS SELECTOR="#message" CHARS=" "
TAG POS=1 TYPE=TEXTAREA ATTR=ID:message&&TYPE:text CONTENT={{!VAR2}}
TAG POS=1 TYPE=I ATTR=CLASS:pushfont-send

The code here checks if the macro is initiated by a JS where messages can be dynamic. Making the check for undefined variable makes the code usable in both situations. And also it’s great for checking the code right away.

If you want to initiate the notification macro through a JS script in iMacros use the following code in your file. The push.iim files is required for this to work.

push.js:

var msg = "Testing is complete on ASUS";
iimSet("PUSH",msg);
iimPlay('push.iim');

The msg variable can be dynamic with the use of javascript to notify you of different events while you are testing with iMacros. So you will have to know some JavaScript to create macros in iMacros to implement this.

Let me know if I can improve on this or if something is off.

Tags: , , , ,

Category: How To's, iMacros