How to distribute Macros via Website: Test Page
Run embedded UI.Vision RPA macros
Embedded UI.Vision RPA macros are a great way to distribute macros to users, for example to help them with certain tasks
on your website. This website contains three embedded macros. You can use your browser’s «View page source» function to inspect this website – and you will see the embedded macros. The macro code is exactly the same as you
can find on the source code tab.
To run these macros, you first have to allow it. (If you don’t allow to run embedded macros, UI.Vision RPA will show a dialog with an error message).
^This macro fills out the input box ↓:
^This macro fills out a Google Docs Survey form.
^This is the same macro as the first one, but now it contains the closeRPA: 0 flag
in the Javascript for this call,
so UI.Vision RPA stays open after the macro run is completed.
Also, the macro runs in a new tab because we use the selectWindow | TAB=OPEN | https://docs…. command
to open page.
^This macro goes to 7zip.org and downloads the software. (7zip is not related to ui.vision in any way).
^This macro goes runs the embedded version of the DemoVisualUITest demo macro (Visual UI testing with image recognition).
The remote image feature requires UI.Vision RPA V5.5.3 and higher.
Allow embedded macros to run
In order to run macros that are embedded in a website you have to first allow it (step 1 in the screenshot below). The default
setting is OFF (do not run embedded macros). Once you allow such macros in general, you will see a dialog box
asking for permission to run such macros. If you want to avoid this warning dialog for certain websites (for example your own internal website), then you can add
this website to the website whitelist (step 2 in the screenshot below):
«Steal» the Javascript snippets directly from this page
You can copy and reuse the Javascript that sends the UI.Vision RPA macro from the page to the RPA software. The code is directly on this page. In the browser, right-click
and select «View page source» to view it.
The only part that needs to be changed is the macro JSON code. You can also give each macro a different name. Macros with the same name get simply overwritten,
so UI.Vision RPA runs always the latest version that is on the page.
For more information see How to create and run embedded macros.
function RunMacro1() { // Embedded UI.Vision RPA Macros V3.61, License: MIT License (Open-Source), (c) 2020 a9t9 //This code snippet checks if UI.Vision RPA is installed, and if yes, tells the RPA software to import and run the macro. //In UI.Vision RPA itself the user can allow/not allow to run embedded web macros (OFF by default) //To run web macros from specific websites without warning prompt, they URLs of certain websites can be whitelisted //For more details please see https://ui.vision/docs#embed
(function (detail) { var isExtensionLoaded = function () { var $root = document.documentElement return !!$root && !!$root.getAttribute('data-kantu') } var openExternal = function (url) { const $el = document.createElement('a') $el.setAttribute('target', '_blank') $el.setAttribute('href', url) $el.style.position = 'absolute' $el.style.top = '-9999px' $el.style.left = '-9999px' document.body.appendChild($el) $el.click() setTimeout(() => { $el.remove() }, 200) } var openWebsite = function () { openExternal('https://ui.vision/rpa/home/getrpa') } if (!isExtensionLoaded()) { if (confirm('UI.Vision RPA is not installed yet. Do you want to download it now?')) { return openWebsite() } } else { return window.dispatchEvent(new CustomEvent('kantuSaveAndRunMacro', { detail: detail })) } }) ({ direct: 1, //If the website URL is whitelisted, run the macro without prompt json: { //Macro JSON code here. You can copy and paste the code directly from the source tab, https://ui.vision/docs#sourcecodetab "Name": "EmbeddedMacro_FillOutGoogleForm", "CreationDate": "2019-11-25", "Commands": [ { "Command": "bringBrowserToForeground", "Target": "", "Value": "" }, { "Command": "open", "Target": "https://docs.google.com/forms/d/11UBhaBf-clTy_EiI6TjlxaAinhae3rvPaPqS14epAfA/viewform?edit_requested=true", "Value": "" }, { "Command": "type", "Target": "name=entry.933434489", "Value": "This is just test data" }, { "Command": "type", "Target": "name=entry.1382578664", "Value": "testonly@ui.vision" }, { "Command": "type", "Target": "name=entry.336178899", "Value": "You find this embedded macro INSIDE the web page" }, { "Command": "clickAndWait", "Target": "xpath=//*[@id=\"mG61Hd\"]/div/div/div[3]/div[1]/div/div/span/span", "Value": "" } ] } }) }
// Macro 2 ----------------------------------------------------------------------------- function RunMacro2() { // Embedded UI.Vision RPA Macros V3.61, License: MIT License (Open-Source), (c) 2020 a9t9 //This code snippet checks if UI.Vision RPA is installed, and if yes, tells the RPA software to import and run the macro. //In UI.Vision RPA itself the user can allow/not allow to run embedded web macros (OFF by default) //To run web macros from specific websites without warning prompt, they URLs of certain websites can be whitelisted //For more details please see https://ui.vision/docs#embed
(function (detail) { var isExtensionLoaded = function () { var $root = document.documentElement return !!$root && !!$root.getAttribute('data-kantu') } var openExternal = function (url) { const $el = document.createElement('a') $el.setAttribute('target', '_blank') $el.setAttribute('href', url) $el.style.position = 'absolute' $el.style.top = '-9999px' $el.style.left = '-9999px' document.body.appendChild($el) $el.click() setTimeout(() => { $el.remove() }, 200) } var openWebsite = function () { openExternal('https://ui.vision/rpa/home/getrpa') } if (!isExtensionLoaded()) { if (confirm('UI.Vision RPA is not installed yet. Do you want to download it now?')) { return openWebsite() } } else { return window.dispatchEvent(new CustomEvent('kantuSaveAndRunMacro', { detail: detail })) } }) ({ direct: 1, //If the website URL is whitelisted, run the macro without prompt closeRPA: 0, //keep the UI.Vision RPA UI open after the macro has completed continueInLastUsedTab: 0, json: { //Macro JSON code here. You can copy and paste the code directly from the source tab, https://ui.vision/docs#sourcecodetab "Name": "EmbeddedMacro_FillOutGoogleForm", "CreationDate": "2020-02-19", "Commands": [ { "Command": "bringBrowserToForeground", "Target": "", "Value": "" }, { "Command": "selectWindow", "Target": "TAB=OPEN", "Value": "https://docs.google.com/forms/d/11UBhaBf-clTy_EiI6TjlxaAinhae3rvPaPqS14epAfA/viewform?edit_requested=true" }, { "Command": "type", "Target": "name=entry.933434489", "Value": "Second data set." }, { "Command": "type", "Target": "name=entry.1382578664", "Value": "office.of.bill.gates@ui.vision" }, { "Command": "type", "Target": "name=entry.336178899", "Value": "This is the 2nd data set. Embedded macros like this can be easily autogenerated. The macro source code is standard JSON." }, { "Command": "clickAndWait", "Target": "xpath=//*[@id=\"mG61Hd\"]/div/div/div[3]/div[1]/div/div/span/span", "Value": "" } ] } }) }
// Macro 3 ------------------------------------------------------------------------------------------------
function RunMacro3() { // Embedded UI.Vision RPA Macros V3.61, License: MIT License (Open-Source), (c) 2020 a9t9 //This code snippet checks if UI.Vision RPA is installed, and if yes, tells the RPA software to import and run the macro. //In UI.Vision RPA itself the user can allow/not allow to run embedded web macros (OFF by default) //To run web macros from specific websites without warning prompt, they URLs of certain websites can be whitelisted //For more details please see https://ui.vision/docs#embed
(function (detail) { var isExtensionLoaded = function () { var $root = document.documentElement return !!$root && !!$root.getAttribute('data-kantu') } var openExternal = function (url) { const $el = document.createElement('a') $el.setAttribute('target', '_blank') $el.setAttribute('href', url) $el.style.position = 'absolute' $el.style.top = '-9999px' $el.style.left = '-9999px' document.body.appendChild($el) $el.click() setTimeout(() => { $el.remove() }, 200) } var openWebsite = function () { openExternal('https://ui.vision/rpa/home/getrpa') } if (!isExtensionLoaded()) { if (confirm('UI.Vision RPA is not installed yet. Do you want to download it now?')) { return openWebsite() } } else { return window.dispatchEvent(new CustomEvent('kantuSaveAndRunMacro', { detail: detail })) } }) ({ direct: 1, //If the website URL is whitelisted, run the macro without prompt closeRPA: 1, //close UI.Vision RPA UI after the macro has completed //Macro JSON code here. You can copy and paste the code directly from the source tab, https://ui.vision/docs#sourcecodetab json: { "Name": "EmbeddedMacro_7zDownload", "CreationDate": "2019-11-18", "Commands": [ { "Command": "open", "Target": "http://www.7zip.org/download.html", "Value": "" }, { "Command": "click", "Target": "/html/body/table/tbody/tr/td[2]/p[1]", "Value": "" }, { "Command": "click", "Target": "link=Download@POS=5", "Value": "" }
] } }) } // ^^^ --- embedded UI.Vision RPA macros above
// Macro 4 ------------------------------------------------------------------------------------------------
function RunMacro4() { // Embedded UI.Vision RPA Macros V3.61, License: MIT License (Open-Source), (c) 2020 a9t9 //This code snippet checks if UI.Vision RPA is installed, and if yes, tells the RPA software to import and run the macro. //In UI.Vision RPA itself the user can allow/not allow to run embedded web macros (OFF by default) //To run web macros from specific websites without warning prompt, they URLs of certain websites can be whitelisted //For more details please see https://ui.vision/docs#embed
(function (detail) { var isExtensionLoaded = function () { var $root = document.documentElement return !!$root && !!$root.getAttribute('data-kantu') } var openExternal = function (url) { const $el = document.createElement('a') $el.setAttribute('target', '_blank') $el.setAttribute('href', url) $el.style.position = 'absolute' $el.style.top = '-9999px' $el.style.left = '-9999px' document.body.appendChild($el) $el.click() setTimeout(() => { $el.remove() }, 200) } var openWebsite = function () { openExternal('https://ui.vision/rpa/home/getrpa') } if (!isExtensionLoaded()) { if (confirm('UI.Vision RPA is not installed yet. Do you want to download it now?')) { return openWebsite() } } else { return window.dispatchEvent(new CustomEvent('kantuSaveAndRunMacro', { detail: detail })) } }) ({ direct: 1, //If the website URL is whitelisted, run the macro without prompt closeRPA: 1, //close UI.Vision RPA UI after the macro has completed //Macro JSON code here. You can copy and paste the code directly from the source tab, https://ui.vision/docs#sourcecodetab json: { "Name": "EmbeddedMacro_DemoVisualUITest", "CreationDate": "2020-03-22", "Commands": [ { "Command": "open", "Target": "https://ui.vision/", "Value": "" }, { "Command": "setWindowSize", "Target": "1024x768", "Value": "" }, { "Command": "visualVerify", "Target": "e_uitest_logo_wide_dpi_96.png@0.70[http://dl.a9t9.com/ui.vision-uitest/uitest_logo_wide_dpi_96.png]", "Value": "" }, { "Command": "visualAssert", "Target": "e_uitest_youtube_dpi_96.png[http://dl.a9t9.com/ui.vision-uitest/uitest_youtube_dpi_96.png]", "Value": "" }, { "Command": "visualVerify", "Target": "e_uitest_share_dpi_96.png@0.70[http://dl.a9t9.com/ui.vision-uitest/uitest_share_dpi_96.png]", "Value": "" }, { "Command": "comment", "Target": "Resize to iPhone6 screen size", "Value": "" }, { "Command": "setWindowSize", "Target": "375x768", "Value": "" }, { "Command": "visualVerify", "Target": "e_uitest_logo_mobile_dpi_96.png[http://dl.a9t9.com/ui.vision-uitest/uitest_logo_mobile_dpi_96.png]", "Value": "" }, { "Command": "comment", "Target": "Missing menu is critical, so we use ASSERT (instead of just VERIFY)", "Value": "" }, { "Command": "visualAssert", "Target": "e_uitest_hamburger_dpi_96.png[http://dl.a9t9.com/ui.vision-uitest/uitest_hamburger_dpi_96.png]", "Value": "" }, { "Command": "comment", "Target": "Check that Share buttons do not show", "Value": "" }, { "Command": "comment", "Target": "At this point, page is surely loaded => reduce wait for (normally missing) image", "Value": "" }, { "Command": "store", "Target": "2", "Value": "!timeout_wait" }, { "Command": "visualSearch", "Target": "e_uitest_share_dpi_96.png@0.70[http://dl.a9t9.com/ui.vision-uitest/uitest_share_dpi_96.png]", "Value": "count" }, { "Command": "if_v2", "Target": "${count} > 0", "Value": "" }, { "Command": "throwError", "Target": "Share buttons should NOT show on mobile phones", "Value": "" }, { "Command": "end", "Target": "", "Value": "" }, { "Command": "comment", "Target": "Restore default wait (not really needed here, since macro stops now anyway)", "Value": "" }, { "Command": "store", "Target": "10", "Value": "!timeout_wait" }, { "Command": "comment", "Target": "Done, enlarge browser again", "Value": "" }, { "Command": "setWindowSize", "Target": "1024x768", "Value": "" } ] } }) }
function RunMacro5() { // Embedded UI.Vision RPA Macros V3.61, License: MIT License (Open-Source), (c) 2020 a9t9 //This code snippet checks if UI.Vision RPA is installed, and if yes, tells the RPA software to import and run the macro. //In UI.Vision RPA itself the user can allow/not allow to run embedded web macros (OFF by default) //To run web macros from specific websites without warning prompt, they URLs of certain websites can be whitelisted //For more details please see https://ui.vision/docs#embed
(function (detail) {
var isExtensionLoaded = function () {
var $root = document.documentElement
return !!$root && !!$root.getAttribute('data-kantu')
}
var openExternal = function (url) {
const $el = document.createElement('a')
$el.setAttribute('target', '_blank')
$el.setAttribute('href', url)
$el.style.position = 'absolute'
$el.style.top = '-9999px'
$el.style.left = '-9999px'
document.body.appendChild($el)
$el.click()
setTimeout(() => {
$el.remove()
}, 200)
}
var openWebsite = function () {
openExternal('https://ui.vision/rpa/home/getrpa')
}
if (!isExtensionLoaded()) {
if (confirm('UI.Vision RPA is not installed yet. Do you want to download it now?')) {
return openWebsite()
}
} else {
return window.dispatchEvent(new CustomEvent('kantuSaveAndRunMacro', { detail: detail }))
}
})
({
direct: 1, //If the website URL is whitelisted, run the macro without prompt
json: {
//Macro JSON code here. You can copy and paste the code directly from the source tab, https://ui.vision/docs#sourcecodetab
"Name": "EmbeddedMacro_FillOutBox",
"CreationDate": "2020-05-15",
"Commands": [
{
"Command": "comment",
"Target": "This macro has just one line...",
"Value": ""
},
{
"Command": "type",
"Target": "id=sometext",
"Value": "Hello World!"
}
]
}
})
}
// ^^^ --- embedded UI.Vision RPA macros above
.
We’ll send you updates on new releases that we’re working on.