Advanced Citrix Automation 4.2

Advanced Citrix Automation 4.2


Hello. As you’ve seen in the previous video, automating
virtual environments has its own set of challenges. So in this episode we’ll cover a few tips
& tricks, and good practices. We’ll focus mainly on keyboard actions because
they tend to be faster and more reliable than clickImage and similar actions. An often overlooked issue with image-based
automation is knowing when to perform certain actions. Also-known-as waiting for a specific state. Whether you’re waiting for an application
or web page to load, or waiting for a certain process to end, most of the time you will
need to know the state of your application, so you can perform further actions. The solution for that is actually quite simple
and it involves imagining how a human would evaluate the state of a certain app, and mimic
that. Let’s say we’d like to automate going
to the SAP homepage and logging in, by clicking this button. On a desktop you wouldn’t have any issues:
just record your actions and that would be it. The UiPath actions themselves are smart enough
to wait for each element to load before interacting with it. But on a virtual machine, it’s a different
situation: all we have is an image, and no direct access 2 individual elements or their
state. So we’ll look for visual elements that tell
us the page or app is done loading, or ready. you could wait for a specific element on a
page – like a picture or button – but a better and more general solution would be
to wait for the loading icon to disappear and be replaced with the FavIcon. Each site has its own little logo or graphic. For that, we have the handy FindImage activity. So let’s quickly make a new sequence and try
it out. We’ll add the find image action, and indicate
the image you’d would like to detect, by dragging a selection marquee like so. And that is actually all there is to it. Findimage stops the execution process until
that specific image is found or the {timeout} is reached. Whichever comes first. Now let’s add a message box to be notified
when the image is found. And before we run the workflow, let’s leave
the Sap page so we can clearly see the findimage in action. So run and… hmm, that’s earlier than expected. Maybe it somehow got confused. Let’s try to find the problem. We’ll add a highlight action to see what
was detected. For that, we’ll create an output variable
for the findimage action. It will give us the element that was found. We can highlight a clipping region, an element,
or a selector. We’ll just use
here the element generated by the findImage action. And we’ll change the color to red and the
time to 2 seconds for better visibility. Now let’s see where the problem is. Well, don’t I feel silly. Didn’t even notice it there. Let’s remove this and try again. Okay! Looks like this time we’re in the clear. So let’s go to the SAP page… here’s the
loading indicator… aaaand When the page loads the highlight appears for 2 seconds,
and the message box is displayed. So there was nothing wrong with it after all. This means we can delete this message box,
but will leave the highlight for now in case we need it later. So from here on, it’s familiar territory:
add a clickimage to open the login window… and indicate the button. And run. Right. Looks like it’s working. Normally you could use clickRelative for the
{text fields} and another clickImage for {the button}, but using keyboard navigation is
faster and a bit more reliable. Which brings us to the next section: automating
Virtual Machines with keyboard commands. Carrying on with our example, we notice we’re
pretty lucky, because the focus is already on the first input field. So all we have to do is type the email and
press tab once to go to the next field. Here, we can type the password, and then we
can press tab once, twice, and the third time we are on the logon button. So with that information we can start automating. Will add a type action after it, and use it
to type in the two fields, and navigate between them. First will create two variables to hold the
email address and the password. And we’ll give them some initial values
for testing. Since the email field already has focus, we’ll
start with: email, then tab to go to the next field, then password, then 3 tabs because
we want to reach the login button. And add an enter to activate it. That should be fine. So let’s see. Nothing happens while on this empty page,
but when we go to the SAP homepage, the findimage is triggered, and the rest of the workflow
follows. It was pretty fast but apparently it worked. obviously it couldn’t log on the with this
test user, but you get the idea. You might notice that sometimes the type command
fails. It might be because the login window doesn’t
have enough time to open. An example of bad practice in solving this,
would be to add a delay between the click and type action to give the window some time
to open. It’s a bad solution because the modal window
might take longer than the delay you set, and most of the time less. Either way, it’s not optimal because you’ll
have to cover worst case scenario, so you’ll end up with a long delay that needlessly slows
down your workflow. The optimal solution would be to add a new
find image to wait for that window to load. I’ll let you do that yourself. Ok, next up, starting apps. Starting apps is pretty trivial even on Virtual
machines, but we will look at a few methods, from the simplest, to the most demanding situation. The first and most obvious one is double-clicking
a desktop icon. You can use a regular click image action to
perform a double click on a certain icon. Just change the click type from a single to
a double click. The problem with this method is that it’s
can be a bit fragile if you’re not careful. For example even selecting the icon can make
it break down, if the selection was not precise enough. As you can see it cannot find and click the
icon because it is not selected so it has a different background. But that can be easily fixed by making a better
image selection – one that does not include any portion of the background, because that
is what was different when the icon was selected. Another better method of opening an app is
by assigning to it a Windows shortcut key. You can use any shortcut you like, but it’s
safer to use more complex ones, as it will be less likely to interfere with existing
ones. Once a shortcut key is set, simply add a sendHotkey
action to your workflow and assign to it the correct combination. And of course indicate the window where to
send the hotkey, in our case, the virtual machine window. And when we run, we see the application starting-up
flawlessly. This should probably be your first choice
for starting apps as it’s fast, reliable and super easy to implement. And the third method is for special cases
where you need to run apps with parameters – or arguments. For example, let’s say you wanted to open
various text files with this notepad app we’ve been playing around with. How would you start the notepad app itself? One way of doing it, is to use the windows
Run command, and paste the application’s path, that we can get from its shortcut. So we’ll copy this file path, and press
the Windows-key and R – the shortcut for the Run command. Hmm, Looks like it actually triggers my system’s
Run utility, instead of the virtual machine’s Run. That’s not very helpful. Maybe you could avoid that by using the remote-desktop
app to send special commands. But looks like this version can only send
a {Start menu} command. That is very useful too, since we can type
CMD and have a command prompt, from where to start our app or use other low level commands. Those are all fine, and very similar to the
method that I’m about to show you, so make sure you try them out if they’re more suitable
for your situation. But for now let’s come back to opening the
notepad++ app and passing it some parameters – or arguments. If your remote desktop application – like
mine here – doesn’t support sending special shortcuts, like windows-R, you should be able
to send the special key when the window is in full screen. You can tell it belongs to the virtual-machine
from this “gorgeous” color-scheme. So let’s quickly see how to do all that in
UiPath. Starting with an empty sequence, add in a
click action for the maximize button, and a sendHotkey action for the Win-R shortcut. Let’s see if that worked. Cool. Next, let’s type the command to open a certain
file with the notepad app. We’ll make two variables, one called App,
to hold the path for the application we want to open; and the other called Arguments for
the file and arguments we may use. For the App initial value, we’ll just paste
the notepad path we copied earlier. And for the file we’ll just put a dummy
path. In the type action we’ll build the string
to be typed in the Run utility. So: app, plus a space, plus arguments. And an enter key at the end to run it all. Not bad, it opened our test file successfully. And that’s all there is to it. If you need to, you can add another click
action to exit from fullscreen. And this brings us to the end of this episode. I hope you now have a better understanding
of how to tackle more advanced issues in virtual environments: using findImage to wait for
a specific state of an application, and performing various tasks – like navigating text fields
and starting apps – using almost exclusively keyboard actions. So I’ll see you for the next video! Bye!

3 Comments

  • Junior Fumi says:

    00:00 – Introduction
    00:22 – Advanced Image-based Automation
    04:04 – Keyboard Shortcuts
    06:21 – Starting Apps
    11:26 – Resume

  • Rajesh devan says:

    Thanks for this video sir and you telling very fast which is very difficult to understand so please explain patiently and slowly reach and every step.

  • rajesh makam says:

    Citrix Automation: From our Windows OS machine Can we Automate few actions in a Citrix-Remote Desktop having Ubuntu OS (Opening some folders and Extract Zipped Folders) ?

Leave a Reply

Your email address will not be published. Required fields are marked *