Web Automation in Power Automate for Desktop (Full Tutorial)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today's exercise is something that we often face as rpa developers that is browse automation we want to log into an area using a username and password and we want to click buttons take screenshots and the likes so what we will do is to open up a google and then search for the internet login like this and take the first hit that is the login page the internet this is a sample page which we can practice on here we need to fill in username password and then click login this is not truly compliant because the username is up here tom smith and the password is even here too so let's create it in power automate for desktop and talk about the best practices and how we can improve the robot so if i go to power automate for desktop and then click new flow so here i will say browsers you can call yours whatever you want so now i open up the flow and let me maximize this so this is our blank canvas first we will need to open up a browser and if you haven't installed the browser extension you need to do that you can click the video up in the right corner that will take you through that process but i assume you already have installed the browser extensions then we can just open it so if i go over here to actions and then search for a launch i can either choose chrome microsoft edge or firefox don't go with the internet explorer that is outdated i prefer chrome but feel free to take the edge as well here i'll launch a new instance and i need a url so i go back to my browser and up here i will copy the entire web address ctrl c go back to my power automate for desktop now i can paste in the url here this launch new chrome will produce a variable called browser so then i click can click save this also means that i can refer to this variable if i want to do something in this window let me show you so if i close down this page here and go back to my power automate for desktop and run i will open up a new browser that will take me to this page so we already created the first step that was easy wasn't it now we need to store the username and password obviously we would in real life we would store this password a bit more secure but you'll get the intuition and we can easily store it in for example cyborg later so if i go back here and let me just copy this user name first so mark it ctrl c go back to your power to made for desktop we can create the username as a variable in two ways we can either use the set variable as we did before or we can create it as an input variable we'll usually want to do that because we will store the credentials in some kind of a secure way so if i click this plus here i'll say input so now i give my variable a name i'll not call it new input i'll call this username the default value well i just copied that so ctrl v paste it in the external name i will not use but i'll just use the same one as the internal name you can give it a description that's fine then i click create now i have my username variable and let's go back to the browser here and take the password so if i mark this ctrl c i'll do the exact same thing almost i'll go back here and create a new input variable so click the plus sign click input here i will say pass word like this i'll give it the default value super secret password i'll give it the same external name and here i can mark as sensitive and look what's happened so if i click create here it will not get shown up here that is clever if for example other people come to the robot they cannot see this sensitive value they will however be able to see it if they click here so now i'm launching new browser and i stored these two username and password as variables now i can use them to type them in here so first let's fix the username field so if i go back here what i'll need now is a public text field on web page so go search for that make sure you take the one on the web form filling and drag it in so here you can see i refer to my browser instance variable that was the one we created up here now we need a ui element a ui element is everything you'll see on the web page so if i click the drop down here you can see i can add a ui element so if i click here all the elements that i can choose let me move this a bit is available in the red ones so i want to type something in you can see i can i can even send text to these fields for example of course nothing will happen but i can do it i can send it to all the ui elements on the web page since we want the username i find that press ctrl left click with your mouse and our ui element is created now i need to say what do i want to fill in well i wanted to fill in the username that we just created as a variable up here so to do so i click the x here then find the username you can double click it that one will get typed in here you could also write it out yourself percentages signs and then username but it's more easy and you'll reduce the risk of misbuilding things by just choosing it automatically then i can click save and let me just close this browser window again we can see that we can make it work so we launch a new chrome and we fill in the username it's that easy let me show you a bit of the background around this how we can create these elements and how we can edit them so if i go back to power automate for desktop you can see that this public text field input text username that once that one originates from the ui element so if i go over here click the ui elements you can see it here so this is our ui element inside of this web page first of all do rename all your ui elements so you can easily come back to them what you will do is to go over here and then you can press either f 2 like this or you can just right click click rename here i'll just say i'll call this username field this one will make it easy to maintain in the future to inspect the address let me just double click here and you can see here the address is input hard brackets id equals username let me show you how a power automate for desktop got this address so if i go back to my browser one thing that i'll introduce you for you don't have to completely understand it just know it's there i'll be more elaborate in later lessons so if you press f12 here and this works whether you got google chrome or edge this one will open up the developer tools this is a very very powerful tool and it's free it's in the browser you need to have it docked to the bottom you don't need to but it's more efficient if your ones look like this it's over here to the right you can click the three dots duck to the button that's here we can inspect everything so if you go to elements and click this arrow we will inspect the username field so if i just click here you can see here that we have the input section and in there there's the id username that was exactly our address here so powers made for desktop just referred to this field by the address here in the developer tools we could have created this one ourselves and you can see i can even say that i want to have the input and then i want to change it to name username that will also work just let me show you how to do it so if i double click again untick custom i can just change this one here to name wasn't it like this and then we'll click update and we can run it so if i just run it again this one will open up a new one and we typed in the username be aware that if we got duplicates let me go back here say that we got several input fields with the same name then we will have to specify it further that one will be a more advanced lesson but you will not imagine that there will be several input fields with the id username the web developers from this webpage would have thought of that what do you think about the quality of this lesson please post it in the comment below that will help me a lot thank you so now you know how this originated so i closed down my browser again with the challenges and here we have now filled in the username we will do the exact same thing with the password so either just copy this or drag in a new one here again we go to this drop down we will not use the username field of course we will add a new ui element and we will need to have the internet login opened o i for some reason closed it that was not the purpose so i'll open it again here so here i'll find the password and to find the password again just find the field click control then left click with your mouse this one will create a ui element so what do i need to fill in here well that was the value of the password variable so i'll just refer to the password variable click the x here find a password like this then click save now let's try to run this automation to see that this works so now i can fill in the password let me just verify that we can actually log in we can i'll log out again so if i go back to power automate for desktop let's also fix the name of this ui element so again go up here you can right click now rename or press f2 f12 sorry so here is the password field we have fixed it so now we need another thing we need to click the login button that one was this one here and to do so we'll find a click link on web page here drag it in underneath so here we'll again refer to the browser instance variable we'll create a new ui element for the button let's try to create it another place that's possible so i'll save here this one will give us an arrow that's fine because it says we need a ui element we can create it over here in the ui elements so click this stack click add ui element and this one will also open up the ui element picker i want the login button we have two different choices i think it will work whether or not we choose the big button that one will work but it will also work if we click here i just choose the big button so control left click with your mouse we have now the button login i can click done here so i'll press f2 and here i'll say login button like this and have it renamed now we use this ui element over here in our click link on web page so double click to open it choose the drop down and find the login button like this then i click save so now we have all our three actions we can now open up a browser and log in so let's try to run the automation to verify that it works username password click login we're now logged in second part of the exercise is to take a screenshot of this area so what we will do here let me minimize this is this this is that will create a folder on our desktop for the screenshots you can place your photo whenever you want or wherever you want so i right click new folder here i will just say screen shot like this now i will get the address of this folder so hover your mouse over shift right click copy as path then i go back to my power automate for desktop i will also create a new variable for this folder make it a good habit of creating variables for things that can change that is best practice when you develop so what i'll do here is that i'll go over here to input output variables input here i will say folder path like this i'll give it a default value by pasting in the value that i just copied remember to move the quotation mark in the end and in the start i'll also call this folder path by external name it's not we don't use it now but if we did it will be called photopath then i can click create so now i can use this folder path when i take a screenshot find a take screenshot of web page here on the web web data extraction and drag it in so we'll do it right after we click the link on the web page so i i'm referring to the browser instance that's fine i will capture it by taking the entire web page i can either save it to the clipboard or to a file here i'll choose my image file and the file format i want a png so first i click the drop down in this file format and then choose png now i can use my address that i want to refer to when i want to save and i just created a variable for that that was the folder path so if i go up here select the variable that will be the folder path then i'll say i want to go inside it and then i can name it so i'll just call mine screenshot dot png then i can click save now let's try to run the automation again so i'll run it launch a new chrome login take a screenshot there you go let's inspect the folder on our desktop to see that we actually have a screenshot here we have a screenshot of the webpage so far so good but if i run the robot again this screenshot will be overwritten over and over let me show you a nice trick where we can do dynamic naming we will use this trick a lot so if i go back to power automate for desktop we will use the date when this robot starts we will take the date down to the seconds and use that in the file name that is dynamic naming i'll find a get current date and time here and i'll pick it in in the beginning of the robot this one will just produce a variable called current date and time i'll click save now i will convert this current date and time into a text variable so i'll find a convert date time to text here and drag it in just after i will take my current date time and transferred into a text variable so date time to convert click the x here and then find the cue and date and time we can see that the variables we produce is a formatted datetime named this one will be a text variable i can use the standard format this one will give us some really standard one so you can see it here but since i want to use it in the file name i really want it to be nicely formatted so i choose custom here here i can put in a little bit of code it's really really easy for example if i put in 4 y's this one will put in a year of course this is 2022 when i make this video so it will be called 2022 in this text variable if you want to learn a little bit more about that let me show you where to get it from in 10 seconds but first i'll just create a custom format i want a year then i want the month that is two big ms if you press small ms it will be minutes so here i will say days then i want hours i want the 24 hour format because that is easiest when i read when i name my files then i want minutes and that one was the small amps i also won seconds i can even go with milliseconds and the likes but this is fine we will not have the same robot run in the same seconds so this will work then i can click save and back to where i got let me just open it again where i got these ones from so let me open up a google and then i can search for date.net custom datetime format and you will pick this one here custom date and time format strings click it this is the microsoft so here if i scroll a little bit down you can see that here we got the codes so for example i use the four wise so i'll scroll a little bit down it's alphabetically you can see here four y's that is the year as a four digit number similarly i use two s's four seconds that one is here so you can just save this for a reference you will be using this in the future always check the microsoft documentation to use it in our flow i can click save here i will just use this text variable in my naming so open up the take screenshots of web page and then just before the screenshots use the variable so click the x here take the formatted date time it should look like this then i can click save let's try to run the robot again so now we will do dynamic naming and if i go back to my folder out here you can see that i have now created a screenshot with the name of the date and time when the robot ran isn't that clever so here you learned how to automate browsers use variables and do dynamic naming click the link on the screen that will take you to the next lesson
Info
Channel: Anders Jensen
Views: 50,560
Rating: undefined out of 5
Keywords: web automation in power automate, web automation in power automate desktop, anders jensen, power automate desktop browser, power automate desktop browser automation, power automate desktop browser instance, power automate desktop web browser instance, power automate for desktop, power automtae desktop, browsers in power automate for desktop, web automation, web automation in power automate for desktop, automate browser tasks, microsoft, microsoft power automate desktop
Id: wm7B_N2eSYY
Channel Id: undefined
Length: 18min 50sec (1130 seconds)
Published: Tue May 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.