Best way to integrate UI.Vision RPA into Cucumber

Hello,

i dont see how this can be used with cucumber in a effective way. On the website it says " *This allows UI.Vision RPA to integrate with any application (e. g. Jenkins, Cucumber, CI/CD tools,…)
But how?

Example:
Given I`m on the homepage of UI.Vision PRA (){
-> run html-file from command-line
}
When… (){
-> run html-file from command-line
}
Then (){
-> run html-file from command-line
}

This is not very effective. Do you know how this can be done in a more efficent way?

To clarify, you do not need to make an HTML for each macro you want to call. Any generated HTML file can be used as “dummy” file, and then you use the &macro=macro1 command line switch to select the test case (macro) that you actually want to run. The local HTML file itself is just used to start the browser and the UI.Vision RPA extension inside it (that is needed because the RPA extension lives inside Chrome/Firefox).

Does this solve the issue? If not: What exactly do you consider inefficient about this process?

Given I`m on the homepage of UI.Vision PRA (){
→ run &macro=folder1/macro1 from command-line
}
When… (){
→ run &macro=folder1/macro2 from command-line
}
Then (){
→ run &macro=folder1/macro3 from command-line
}

Thanks for the quick reply and the clarifications regarding the macros Urlich,

but how do I tell cucumber whether or not a maco run was succesful?
Open the txt-file and check the status?
Like that; https://github.com/A9T9/Kantu/blob/master/command-line/powershell/run-and-check-result.ps1 ?

Best regards and thanks

Best easy way is to check statusok internal var

https://ui.vision/rpa/docs#!statusok

1 Like

thanks for your reply.
I tried it but now I don`t know how to access this variable from the command line, while the macro is running. How can this be done?

You can manage all with RPA, command line you use to run the macro only

When first macro completed, start a sub macro with second work

1 Like

thanks for your replay. I think I didnt explain that very well, have a look at the following example:

Given(“the input {string}”) do |string|

system(’“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” “file:///C:\Users\NBA\Desktop\calculator\DemoAutofill-1.html?direct=1”’)

end

When(“the calculator is run”) do
pending # Write code here that turns the phrase above into concrete actions
end

Then(“the output should be {string}”) do |string|
pending # Write code here that turns the phrase above into concrete actions

end


how do i tell cucumber in each step if the macro run was successful? use the .txt file?

Hello it is very difficult to understand what you want to accomplish but integrating different software with ui vision is always a long and difficult operation.

With ui vision can start with the command xrun software in the pc.

For example I needed to update some files after starting a macro, so my macro first completes the work, after the xrun command starts a batch file that performs some work on files that the macro could not run.

For example I have a macro that first performs the job and then restarts the pc, but to do this was not enough a macro, so the macro completes the automation work, after completing automation the macro runs the command xrun starts a batch file with commands for reboot PC and so I merge web automation with other functions that are not provided in the automation program.

Unfortunately I do not know cucumber and I do not understand what you should do but it seems something very difficult often to find a simple way to create an automation it also takes weeks of testing and study to figure out how to do it.

There is another solution ui vision allows desktop automation and simulating the keyboard can command any program in the pc but it is very difficult to run and you need to be very experienced so you need to study a lot or find a good programmer, I through desktop automation of ui vision I automated some firefox addons but it was a very long and difficult job because it all works to image and emulation of the keyboard.

After macro completed, you can open cucumber and with keyboard and mouse emulation you can control cucumber (write into cucumber and click button in cucumber) using the macro.

This is the very hard part to automate, here the infos

https://ui.vision/rpa/x/desktop-automation

So what here is what i want to do:

I have three functions, in each one i call a macro and i want to get the result of the macro run, so i can compare it.

Example:
function1(){
–> call macro1
-> check if macro1 run was successful or not
}

function2…

So i need to get the result of a macro run and store it in a variable in the win powershell. Normally, after each macro run you can generate a txt-file, but i need to save the result of a run in a variable without downloading a txt-file. Do you know if that is possible?

Best regards

With ui vision you can automate all but need to study and desktop automation is the hard part.

Powershell it’s useless, I automate everything and I don’t use powershell.

To create an automation there are many solutions but they must be studied and if you do not know the ui vision language you cannot automate anything and you would not even understand when it is explained to you how to do it. With ui vision desktop automation you can do everything, absolutely everything, you can control any software / app / pc.

This part of your automation is probably useless, it complicates a lot, there are other better solutions to achieve the same result. I repeat I have automated hundreds of different sites and I have never needed powershell or even cucumber, ui vision is already very powerful and allows you to perform any automation.

So i need to get the result of a macro run and store it in a variable in the win powershell. Normally, after each macro run you can generate a txt-file, but i need to save the result of a run in a variable without downloading a txt-file. Do you know if that is possible?

function1(){
–> call macro1
→ check if macro1 run was successful or not

  • The principle is that UI Vision writes a log file after each macro is done, and in the first line of the log is the status (= successful or not). So the first line either has the text “Status=OK” or “Status=error message”. That is very easy to parse.

  • The name of the log file is set with &savelog=abc.txt when you start UIVision via command line.

  • What the code below also does is the throw a timeout error in case it can not find the log file after X seconds. This can happen if UI Vision or the browser crashes. Or the website opened a modal dialog box (which hangs UI Vision as well).

  • See also: How to run UI Vision RPA 24x7

This is how you do this in Powershell. Same code in Python.

    #############Wait for macro to complete => Wait for log file to appear in download folder

    $status_runtime = 0
    Write-Host  "Log file will show up at " + $path_log
    while (!(Test-Path $path_log) -and ($status_runtime -lt $timeout_seconds)) 
    { 
        Write-Host  "Waiting for macro to finish, seconds=" $status_runtime
        Start-Sleep 1
        $status_runtime = $status_runtime + 1 
    }


    #Macro done - or timeout exceeded:
    if ($status_runtime -lt $timeout_seconds)
    {
        #Read FIRST line of log file, which contains the status of the last run
        $status_text = Get-Content $path_log -First 1


        #Check if macro completed OK or not
        $status_int = -1     
        If ($status_text -contains "Status=OK") {$status_int = 1}

    }
    else
    {
        $status_text =  "Macro did not complete within the time given:" + $timeout_seconds
        $status_int = -2
        #Cleanup => Kill Chrome instance 
        #taskkill /F /IM chrome.exe /T   
    }

    remove-item $path_log #clean up
1 Like

Thanks to @ulrich

To store result of macro/command there is more solution i suggest some

  1. Store the result in !clipboard using Status=OK value after from !clipboard you can paste it inside software/app

  2. Store the result in csv using Status=OK value after with csvread you can extract it and you can paste it inside software/app

  3. Store the result in a multi copy and paste addons and after you can use the result (multiple or single) pasting it inside software/app

  4. Store the result in txt document, after open it, with OCR you can read and save the content and after you can use the result pasting it inside software/app

There are more and more solution but need to combine web automation with desktop automation.

1 Like