logo

NJP

Robotic Process Automation ๐Ÿค–๐Ÿค– (RPA) | Live Coding Happy Hour

Import ยท Mar 31, 2023 ยท video

[Music] thank you [Music] thank you [Music] hi everyone my name is pranav and I am a senior developer advocate here at servicenow and I welcome you to the first ever apj friendly episode of Live coding happy hour and for today what we got those of you who don't know about life coding happier it's an episode where we go into the nuts and bolts of some of the new functionality we have a lot of fun as you know and we have a lot of same kind of content available on our YouTube channel so make sure you check out that and also we are in the middle of the Utah release and there is a lot of content that is available in Utah so make sure you check devlink.sn slash Utah it will come on uh on your left side of the screen and now without further Ado let me introduce you to our guest for today it's Daniel hi I'm doing great how are you doing well thank you for joining Daniel and as we do live coding happy hour those of you who are already already watched our previous stream you guys are familiar with that we start with drinks it's like 2 p.m in India so I am drinking uh regular sparkling water I don't know whether you are able to see it or not but this is sparkly water that I'm drinking for today what about you Daniel yeah it's 2 p.m for you right it's 11 A.M for us it's morning hour so it's a kind of similar situation and I'm actually in a physical service now office today I'm not working from home so it's a really boring kind of Coke but it has to keep me awake and do that get through the day yeah and a lot of people in community plan of drinks water yeah today I'm drinking sparkling water yeah that's there so so that's about the drinks so Daniel exchange is only all let's see what you have planned for us in RPA oh yeah absolutely you mentioned it RPA is today's topic right and Utah brings uh quite a set of new features and I thought we'll go and build a robot that does some gaming for us so I want to do some gaming robot let's see how that works out and and what we can do please use the comments and chats pranav will be my monitor for the chat and if you have some great ideas what the robot should do in addition to what I do I will go for it we'll try it um as you know live coding heavy hour is something not pre-can not recorded not practiced in that case so what we're going to build today I haven't built before maybe it works maybe it doesn't let's see how far we get all right and yeah your problem if you help me with any questions that come around I didn't plan for introducing RPA we had to create a toolbox lately and things like that right so let's assume you know a little bit about RPA what it does um and let me introduce what I want to do today so I did find a nice little website called textadventures.co.uk maybe some of you know that if you have spare time play some text Adventures um it's a website with some couple of games on it and there's one game which I kind of sounded funny to me the world ends today I think right so that that caught my interest and said hey let's play that game or let let's have my robot play that game for me right so the game works we will have the robot go here look at that game there's how it works and then we just click play online I'll do that in a moment and that's how the game works right you get a web page there's some introductory text and you get a couple of buttons to press and I I will try to make the robot press randomly any button to see what happens right you click that button the page refreshes you get some other text you get some other buttons some more text sometimes you have to wait a while for a button to appear um so right we won't read all the text every time that'd probably be boring there's the buttons that we're gonna wait for um and then you click through and eventually the world ends like here right or light turns off and often so things like that and I want to make that robot in terms of dynamic to find the things eventually if I click through that there's one button at the end okay as well we get a button where it says restart that's kind of when the game ends right and until that point I want to take the robot when you click restart you actually get a score so I want to capture that score and record and see how good was my robot is he that's the idea so let's get started with it and that's so nice idea like I was thinking we'll do something inside the forms and all but this is something it was super funny and super fun also let's let's get into I'm super excited all right let's do that yeah I thought something different right not not just the regular forms and lists and getting data from A to B so let's close out the tab and maybe even close get to a fresh new oops full screen is a bit different you have to refresh new Chrome I have launched already Design Studio our RPA Studio we are on the Utah version so everything is updated for Utah and we will see some of the new user features I'll Point them out as we go through so let's say text how the world ends I think that was it right the world ends today but that's the part we're going to be building and it will be an unattended bot it should actually do the whole thing without us doing something well let's generate a new project here we are that's good and let's use one of the first new features we have in Utah it's our recorder you might have seen me on the create a toolbox using that one launch a recorder there we see it's a recorder side panel here that tells me I am recording or I can record let's say so let's navigate to our web page that's the page we want to work with and if I now start my recording we should hopefully we get a little help on that screen let's scroll down to our game and see if it there we go you see the red bars or the red squares coming in saying that's that's our recorder saying hey do you want to do something here um I want to actually get onto that image oops and come on move over hold Ctrl and I want to click on that image so I'm recording a click function we are moving into the description of the game scrolling ah that was the wrong one Victorian detective why did I do that that was the wrong game let's go back maybe stop the recording and try that again do you want to exit no just stop uh throw that away delete all we do that again that was the wrong game let's try that again text Adventures record and now let's make sure we get the right one here it is the world ends today this is the one we need wait for it to capture my mouse movement it's basically waiting for the page to completely load and uncheck the code there we go command move over now ah wrong button that was my problem not command control okay come on here you see it's life it's the whole idea of it right there we go click this one that should get us to the world ends today yes that's where we want to be now let's scroll up there's the play online button that's this one we need and wait for it to kick in foreign this page loads a lot of advertisement and commercials as you see so sometimes it just takes away there we go to react where we get the click here we go and we are in the game that's basically the start of the recording and even the start button is the first one I actually say is kind of one that we can capture dynamically so I'm gonna stop my recording we can see we have here the two steps in here let's save this recording into my project and call it launch game we create a new global object which will have the click features and let's call it just text but when choose something like that that's our new global object save this recording and that brings us to desktop Design Studio what it did now for us it actually created a new activity called launch game it created that global object that we said text Adventures where we have the different screens and buttons and I created this activity with a little flow in Audi labels are a bit long so it doesn't look that nice let's rearrange it a little bit so we see what it's actually doing or you can see that it's doing it's waiting for that page to render when the page is there it checks if it's there if yes it's clicking on our image on our game image waiting for the next page to render if it's there it's clicking the start one so that is easy let's try that out um whoop let's copy the URL because we need that one as well does it copy and that's I like to call out one thing Daniel like that's the power of universal recorder like that we introduced in Utah because initially before uh Utah it was we had to manually Define those things right so now with Utah like it's super simple you just you don't have to do anything like the system is doing everything for you so that's so cool absolutely the only thing it didn't we didn't capture was kind of navigating to the web page so I will add that now when we get to our main routine I'll take text adventures and just say start function put that here we'll start that and as parameters we'll just use the URL of the web page you can go here onto the application type say this is actually we want to do that in Chrome you could use also Edge right and then we use our launch game and put that up just on the back of it I said we want to put it on the back of it so let's do that no it doesn't okay there we go and we'll connect it like this so that is our first start of the robot let's try that out right so Chrome is closed we have no Chrome open let's just play and see what happens there you go it's loading Chrome it goes to the web page waiting for it to load then it should go into our game it should at least there we go it moves into the game waiting for that page to load and then it will actually start the game the bot finishes if we go here yes we are at the start of the game yay that's where we want to be right now let's make that logic yep sorry then just let you add one thing like even after so many ads and all these things that are running on the website it was able to detect the right tag or something so that's some that's something new that I'm seeing after a long time such Advanced AI that said in the bracket yeah and we will see how we do that with the randomizing of the button how clever it can actually be to find these buttons so that'll be the next that's an interesting piece of the challenge right so let's go back to Studio I could now basically use a recorder and record as I click through the game but that's not the part of the idea right we want to randomly click buttons and I cannot record random clicking so we'll have to do a little different approach I'll go into the Chrome connector or the universal app connector that we have so far uh let's see we have already captured the world and what uh what's the page we are in the world ends today I think that's the title ah wait uh and we have URL let's capture a new page just make sure we have the right one um refresh refresh maybe the world ends today I think that is the right one I would say at the screen Ah that's this one now add screen then it's already then it's this one okay let's refresh it's all green yeah so it's this one so let's capture an element on that screen capture element it moves over now see it was the wrong screen that's why hey let's stop that was the wrong one uh flip in that case it's down this one caption element here that's not there okay so what's happening refresh that's the one we want add screen all right such as my mouse not clicking the button maybe the screen is off yes let's make sure this is the URL we are on is that you're only on it we are okay so let's take this one that has to be the right one uh ah I see what it is it's this one index zero we'll take that one off we currently have two tabs open right and index zero means the first tab that matches the criteria in my case it's not the first tab it's the second one I should be able now to capture an element full screen away um I should capture yeah we go I can capture elements here okay now I cannot okay let's close this other tab for a moment move on over here Studio and now let's do that again caption element that is not there okay capture element you see that's why we do live Coatings refresh that's that let's I was messing around with it he didn't like that it looks one more time configure refresh the screens can't click the button so I can they're a little bit off screen it looks like maybe the screen sharing messes up my mouse clicks can't get there okay let's say for a second close it and reopen maybe there's something with a screen share that messes this up as you might know we on servicenow work with Mac laptop so for all windows stuff we have to use Virtual machines and virtual machines then screen sharing through different zooms and whatevers sometimes behave a little weird yes maybe it doesn't detect the right screen and that might be a issue but yeah that's the fun part about life coding APR CS troubleshooting yeah well exploring we'll find out let's try again the world ends today we have our bots so far there we go let's do that one more time zip acceleranger configure get in here I can't click that refresh button can't seem to find that the Chrome okay so I'm gonna close Chrome and restart Chrome we know the robot can do that so we'll go to the game let's play it online close the other tab so we know where we are and try it one more time configure I can't click refresh let me get out of full screen maybe full screen is an issue let me know if screen sharing is still good yeah now I can I can oh can I no listen get internet screen why not and this usually was working before right [Music] I restarted the Chrome extension let's see if that is causing an issue but I I have to feeling it I can't click on it because somehow it's not getting my click which seems to be odd Chrome no there's nothing happening when I click these two buttons that one works and I can navigate here refresh that this one is obviously not live that's okay it's not there but we can continue try to modify this one URL equals let's maybe take the title off would that work refresh no ah there we go maybe it just took a long time and I'm too excited to move forward refresh okay let's slowly let's keep it if that's okay let's go back full screen a few more come on I was there a second ago choose from the window there you go there we go that is it the world where it wants to end add screen now it works okay maybe it was just really not patient enough capture element here we go that's what we need yeah there we go so we are back on the get back on track we can capture elements the one we want to capture is the start button and as you see the tag it's actually highlighting is an attack so it's a link that's good so let's call that just a oops button if I can spell that correctly we captured this specific button and I go back to Studio we have this button now the way we typically identify buttons on web pages is or elements on web pages basically is by a locator right and ideally a locator would go by ID we find an element with a very specific ID IDs don't change they are unique so we can always find the elements wherever they are on the web page if we don't have an idea the default fallback if you want to put it that way from our recorder and studies using a CSS selector so it's moving through the Dom tree finding a certain path of elements like in this case a diff with something squiffy another div a ends of type three so it's navigating that Dom tree to find that element which is fine in in a lot of cases if the page doesn't move if the content doesn't move to different places in our case that would not help well it will help for that initial Button as that one we captured it's there but in the next screen it won't be there so what we can do is I'm going to change that locator to tag name which means I'm actually searching for any element called a or so any attack a hyperlink on that web page if I would refresh that now we might have more than one that's only one on that specific page but if I move on and there are more than one buttons and other things and there might be different links on that page I can be a bit more precise by using these match attributes on the bottom saying I need an a tag that actually has let's say a CSS class of typescript Link I can have a equals Superstar or roll equals link so we have the different attributes that have been extracted by the capturing that I can use to find elements on the screen now I checked that web page before and I've seen all buttons actually ask with the links so that's why I say let's attribute class with your link is what I'm gonna need um this one is using a comparer of equals you could also expand on that side here come on if you highlight that one you can see different properties and you could use different comparers like starts with end with reg X and stuff like that to make your um your match attributes even more precise or less precise however you want to have that right so let's use it like that for a moment and that is a button that we have so we can use in this case go to our newly captured button is this one and as buttons do they have a couple of methods one is column b a click I'll move this click over and let's execute that to see if we can click that button run from here and our web page yes it moves on it moves to the next one now as I said we use we I'll try to find a links with that class tab so this one supposingly has the same class tag so I could use the same click run from here again I have a I have a quick question for you sure about like you said a tag so these are like the a a tags right in HTML that you are referring to correct that's the same thing right that's correct you can basically like would you go here to inspect that element on that page what that button here is get that Chrome help and you can see it is an a tag we just with a class so the class is rendering the button but basically it's just an attack with the text and we have to try me I bet I can understand that's the text on that button it's just an attack for this particular website and we can also like fetch why class also right or is it just a tax maybe like the class that's there is there any possibility we can do it with class uh so what the class is always attached to a particular HTML tag and that's basically what I did here right we have the attack and the class I use as a match attribute I'm matching this class as additional parameter to our locator that's that's cool yeah I just wanted to see that like how it's working sure perfect good so let's have that click again until we are on a page where it is more than one button I want to see what happens then okay well actually I can click a few times myself so we get more than one button yeah sometimes the page is like a bit funny there we go we have more than one button that's the part I need so now if I use the same thing let's go into our configure dialog and say I'm going to refresh that button I I did expect me to say me it finds three but it doesn't Okay refresh only okay so let's inspect what the different buttons are maybe something wrong here with my logic so we can inspect we can see the first button is this one's query Link Link section exactly what we expected height and the next button under here is the squeeffeelink link section also and the third one is quick filling set so we have three different a tags with the same class that's what I would expect our connector to find so why doesn't find that what do we do we say the tag name a and squeaky Link Link section refresh come on refresh listen and highlight which one do you see highlight should actually put in a red square around the button it sees it doesn't do that okay something is weird with my connector today maybe I'm too hectic again let's see knows that we are in live coding happy hour it's behaving a bit weirdly it is okay let's recapture that and try again capture element let's take let's say we take the third one just call that button two for the time being that's good Plus move over we got our button two which is this one we'll move to attack name selection as I refresh one come on there's more than one a tag on that page we know it there is no name that we can use there's no idea and I didn't select any attribute that is behaving weird okay let's let's do something else let's see maybe it's just a dialogue and doing what it's supposed to be doing so let's see we have that initial button that we captured first and usually we can have here a get instance count to count how many of these are on the page let's see what we get here three that's what I want to see okay so it's a dialogue that doesn't work for some reason um what I would have expected to show you that and maybe that works then in your instance as you maybe Replay that when you do a Refresh on that one it's evaluating all the criterias on that page and will tell you in square brackets behind that a red three in that case saying hey I actually find three buttons with that which is exactly what I want so why it's not showing up in that dialog I don't really know for a moment but we can see it's working here right I do here an instance count on that element and if I do here the preview data of the output we see this is three so we say yes there are three hits of buttons exactly what we expect if I would now do a click like before it's just taking the first button so it will always hit the first element and do that that's not exactly what we want right we want to have a randomized clicking of different buttons so what I can do is I can do say I count how many are there if there are more than one well then we do a randomization randomization and click on whatever all random function tells us so let's build that go for in for a decision I'll take a decision after instance count let's say count is bigger than one so we find more than one this decision box is a really smart one you can type all kind of different criterias evaluation criterias right and formulas now I get an input for everything for a variable I just put in that count say hey that's my count so we get more than one and if we have more than one I need to randomize right I need to find a random number glad our robots do have something like that we can have random numbers random passwords random strings so in my case we'll need a number and we'll need that number at the true Port that's the true Port so when we have more than one we actually need to randomize and you see the random is saying we needed random number between one and one thousand well actually I need it not to one thousand it's only three buttons right and you guessed that we'll just take the count from there say this is the random stuff we actually need I'm just trying to make it a little bit nicer you can see where the lines are going to so we generate a random number between one and the max number three awesome we have that now we need to tell that button saying okay this is the button you actually have to press and for this one we have set element index right so on the button yep sorry to interrupt you like one question that I think I am getting is like when you selected one two three will it will it include one uh like the first one or should we do from zero to three something like that a very good question I don't know exactly let's try a few times right let's just run that function a few times and see what we get run and we see the input was now the three so we do one two three and we did get a two let's run it again This Time Again a two okay maybe you're right it's always a two now yeah so you're right you're probably Hey Okay so let's start at zero that's the first thing and I think it's not taking the three also so we have to put zero to four yeah you're probably right now we got a one which is good and we get a two let's see let me get two three no we don't probably right yeah so what we can do here is in that case we just transform the data coming in here as the Max and we're actually saying it's not the value it's actually Value Plus one which would make it to a four right so that's a little transform that happens on that data Port so the value that comes in will be increased by one and we are zero to four let's run and see if we get also three there's the three yeah good color therefore enough there's a two so you can run that as often as we launch and we get different numbers very good and I love this preview feature like you just click of a button you just check that particular action that's so cool it's really helpful as it develop your robot right absolutely all right so we got this return now and I said that that button has the feature of get instance count so we know how many are there and there's that set element index which element out of that count you actually want to modify default is zero so in this case it's not zero take the value off and move oops our output of the random function here say that's the one we actually want to modify and after that we can do our click so that would compose our Logic for if there is more than one button if there is only one button we could straightly directly click it now as we modify that set element index sometimes I would just basically say you know what just to be really sure I'll also set that element index down here but down here I'll set it to zero because I want to make sure I'm on the at the very first element right as we run a running a loop later on we don't know if that index is still from the previous screen somewhere else now we can go into the same click move connect click so that would be kind of our logic saying count if there's more than one get me a random number set it click if it's only one set it to that one and click so that is our logic to click these screens so let's see what's happening right now and maybe we want to do something else a console for the time being no that's in the toolbox to see which buttons we actually clicked because we won't see it on screen right so let's take a console console a lock and put that right before that click feature and we output which one we actually clicked uh but now I in this case it's zero in this case I don't know it's the index so I'll need only two of them only to make it separate copy paste put that up here no the other one this one move that up and say you know we just take this one the output of our random that's the one we clicked and I'm silly I could do a proper message and stuff like that right but just put in the numbers in the console log to say that's the button we clicked so we can actually see what it was okay here we go uh and the console we'll have down here so open that up pin it here and let's run that for this particular page we see it's going through and it says I clicked zero which is the first button page moved on we only have two buttons now I could also as we just run one not in a loop yet I can still do preview on the data right we see the zero here we see the count of three here so I can rerun it it's running again this time I got a count of two it was again clicking zero yeah random is not always random but yeah this is only one button so that should also work right it was still going in in the current execution it still went up here we had two buttons it randomized that it randomized it to a zero yeah awesome let's run it again there's only one button that is again a zero and we are here at the restart feature so that's where where we want to build in to stop and actually take the score it's not there yet but it's also a button so we can also run this one it's obviously a zero button we move here so it actually works right we get there let's see it's a three it should have maybe a different button and zero at one point zero our random is awesome today we have more than one button we do let's see if we I I want to see it do a different button no it doesn't like us okay run more buttons restart okay let's navigate this three again let's I want to see more pressing something else there we go button two I wanted to see that so we did press another button now yeah and it's a different screen something went wrong with the game it looks pretty awkward in the picture but that's our logic to basically go through randomly pressing buttons it's not that difficult is it finding the objects counting them and go through them how are we in time halfway through oh we get still plenty of time that's good so let's build that logic in and make sure we get the text of the button we want to know what's the name of that button what was the button sequence and if the text is restart we want to stop right because that is basically where the game ends so I asked just after that set element index all these buttons if I take the filter off here also have different get features and in our case let's use get Inner text just before we click the button that will tell us what is the text on that button or on that hyperlink come on actually I could do that before the console a log and I could put that into a lock yeah that makes more sense let's make it a bit more robust let's create a variable variable click call that button index and say our random button uh the output of the random is there we go I'll use now the feature of called Data teleportation the output of the random I'm storing in my variable so I can use it more than once like I'm going to store it here push it in here to the set element index let's re take that debug out we'll do that debug differently come on move away yes then we need this variable here to be set to zero and that didn't get into the line as I wanted because we use the index 0 here so I'll do a zero on that one and then I want that text first come on get away can't okay I don't want this first I'll need to redraw the lines here a little bit reordering a bit on the robot and clicking these elements is sometimes a bit here we go I want to take that one off maybe put that to the click so we want to get the text which is good we have the text here come on you get the text and then we'll do a format toolbox let's format the output what we want to have format that is this one formatting text element a very handy tool to concatenate strings do all kinds of formattings I'll put in two inputs one is the text of it and the other one is the index that we have pressed on let me click here on that little gear I can just say what to do with these two inputs and now let's see if I get the right square brackets that's another thing that's always funny in remote desktops here we go zero that's the button ID and that's the text of the button it could even be a bit more nice button ID button text so we concatenate that a bit I have some nice output and say once that's formatted we use this text for the console lock not a simple number anymore get that message here and we had that that actually looks good let's run it once we are somewhere where are we there is one button called restart okay so run come on run from here and it failed okay why did it fail web element couldn't be found let's click restart and try again there it is and now it says button zero button text was YouTube really loudly so we get information from the website we know which button we press we know which text we press and that's kind of what I wanted to capture to see okay that that's the text we could capture the whole text and basically record everything that was happening on the page if we wanted to but that is that's a good part so we're here and now we would want to have say if that button name is actually restart we need to do something differently because restart is ending the game and restarting the game right not just go back into the loop so again we can do a decision back here just before we click and they um button text equals restart what's that capitalized or not done somebody somebody that took notice on that only to click through if it was capitalized no it's not okay so we say button text equals actually that should be in quotes probably had the wrong quotes because it gave me a variable which I didn't want to yes please change it there we go that's what I want so the button text is this part so let's pass that in here and move this line up here say if that button text is restart if it's not if it's a false Port we can just click it and say that's good but if it's restart we actually don't want to click it we want to record some something else first or change our flow something like that so that should be doable and we have currently the restart button on screen so let's see what happens if we if we run that piece of automation run from here it runs through and come on move back here you can see that it actually came to the decision point but it didn't execute that one that was from before we could actually clear the lock so we can see that really that makes more sense I'll try again run from here you can see it run through and it's at that decision it stops it's not moving into the click because it actually yeah that decision is matched it's true right the input we get here if we want to preview that data is actually saying restart so we are matching that restart saying oh that's where we need to do something differently so and the different thing I want to do is actually click on that restart and after it capture this code score will be updated once I click on it if I click that you can see the score up here there it was there before and I think it's different when I choose a different path through the game whatever that path might be we get different scores now that was the same score just trying to get where we have a different score come on and then like one thing can we add delays also like for example there is a text that comes up absolutely restart yeah see there was a score 200 after the restart we get the score and I'll show you the delay in a moment anyway because when we have the loop I actually want to put in delay so we can see what the robot is doing right it's not like running through all everything right so on every page just have it sit there a second or two so we can see exactly what's doing absolutely that's a good very good suggestion so we are here now what we still need to do yes that's correct we still want to press that restart button which is the same button so we can use that same feature and after that we capture the score so we can use that button I know robot gets a bit bigger and let's capture the score configure that we are still on that page so we capture a new element which is that score piece up here and call that score which is a p-tac which is fine okay let's capture that close it and we have that score here and you can see it's using the CSS selector this pass we see section 82 diff I think for now that's fine there should only be one right so let's refresh and see if it finds it it's green so that should be fine I think you can even sometimes with some of the elements you can test here like get text days it get text and you would see what text it is but on this element it doesn't that's okay what we will do is go back just do no not here go back to Studio click on your new score and get use get Inner text because we want a text that's in between the tag right we have that P tag we want to part the text that's in between that P tag so if I move that one over here and if I would run that now you should hopefully see the text score some 200 or whatever it was score equals 200 exactly what we want awesome right so let's put in another console element so our all robot can say how good it was put that in the output and here we are so are we done yet is that all we need I guess we need a loop so it actually runs through the whole exercise more than once right so let's do a loop in our toolbox we have different forms of loops we get a for each Loop a for Loop or while loop so that's kind of the different programming Technologies you can basically do right my case I will do a while loop it's kind of do until right we do a while tube while loop while let's say game running that's a variable we'll be using that's not there yet so let's create a new variable here it is how did I call it game running game running so at the beginning we need to initialize that variable so we do that before the while loop come on here we set that variable to true it is we start with true move in here and now this while has two outputs one is the control port for looping so yeah that happens within the loop and the other one is what's happening once the loop completes so when the loop completes we actually go to end and then we can take this one back down here after the game launched we say when we're done we end we could close down the browser and things like that and inside the loop we do what we do best clicking buttons the only thing it's missing now is we need to set that variable to false at the time when we're done and now that we already have that message here we know that's the place where we are done so we'll take our variable here put that here and name it to false okay this will actually tell the variable to be false and once it moves back into that while box here saying hey are we still in game no we are not then it will stop that's the idea of how it should be working and now let's add the delay as you said print off let's say just before the click of that button where do we have the clicks if we find that we have these are as a click and this is a click every component in studio has properties when you select them you see properties on the bottom right there's a delay after execution or a delay before execution so in this case I would just want to say let's keep it in two seconds before it clicks so we can read what's on the screen and maybe also for this one keep it for two seconds before we do that and you can do that on any element on the on on your canvas right if that's a format text component or the debug component all of them have these delay options it's just a standard option any component has in Design Studio that helps also if if you're working with remote systems that are maybe a little bit slower they can't take the input or the processing as fast as the robe can do you can use these to slow down your robot that I I thought there might be some kind of activities in the middle that will be added but it's already defined in the action itself so that's that's great yeah that's a default set for every action yes we don't have a pause component like so if you would go here like for a toolbox say I need a pause we don't have that but these delays is basically the pause it it is a bit hidden as if you look at your canvas you don't see it you actually need to know go on to that click component here is it yeah so you could argue if you would want to see a pass and or maybe some color coding to see yes that might be an enhancement we can do and then you like I I as we are seeing lot of component on the screen that's there is there any way we can group certain components now like how are we doing flows we have actions we have inputs and outputs is there any possibility we can group certain things in this yes absolutely we have these what we call activities and you could see them as subflows if you want so right and you like I had that launch game which is a activity that launches the game I can have multiple activities and I could move some of these components into the new activity over so that my main activity stays clean and lean absolutely yes perfect that's that's great so let's we look at like 10 minutes left awesome let's have it run and see if it works right I would say We'll close down our browser no not here close down all our browsers because the robot is intended to actually launch the browser go to the game and then run through let's see what happens if we start it maybe it works maybe it doesn't that's the fine part like maybe it works maybe it doesn't you can see already we knew that this part would work right it's actually finding the game it's launching the game there we go and now it's in the game now that's where we have the two seconds pause so we can actually read what's on screen oh we did click something two seconds wait it clicks the next oops and it failed so the first two buttons worked we said it clicks so whether it's start start talking about clouds and then it fails saying I couldn't find that button that you want me to press what's that page maybe the button came too late maybe we need a delay here for the page because actually yes that's true every time we run back we don't wait for the page to be refreshed that that's a very good point that we should add right so so let's take this page and say wait for create wait for all elements make sure the page is actually rendered before we click the next button that's a very good thing we should add into our Loop yeah you see I just dragged it onto the connection line and it's automatically connecting to the right place I can just move it around a bit to make it look nicer and it's right at the place where you need it so okay let's try again close that one clear locks clear and rerun that's one of the elements or scenarios we've seen we have been too fast we were trying to click the buttons as they were not there yet we saw when I played through the game a little earlier that sometimes it renders very slowly that's line by line text and stuff like that so uh wait for all elements didn't help okay that did not help to get here so let's go here and say our button that we want to actually have let's wait for create on that specific button instead of the page make sure that button is there try that one so we can add more delay also Daniel right we can also add more delays I I try to avoid delays as they are kind of not really um deterministic right it's always two seconds but you still don't know if the page is ready so I try to work with these weight Force because they are really trying to wait on the events of that web page gotcha okay one more time launching the game there we go and the wait for create is actually really smart right the default setting is it you might have seen that quickly that there was a 30. so it means it weights up to 30 seconds for that element to appear on screen but up to means whenever it sees that element it moves forward it doesn't need to wait that 30 seconds so yeah we were at the button restart which is great and then we tried to get to the score and he said it couldn't my score couldn't be found and that is probably the same thing we didn't wait for that score to render right it's a new screen so we need to wait for that to render same thing underscore make a little bit of room here you used to wait for create from the score and it's important that you use the correct weight for create right if I drag that but there we go you can see it's called score so it's waiting on that score element I'm running out of a bit Converse base here because you have these weight force and any of the elements you capture on the web page if it's a button if it's a text if it's a link whatever it is so you can wait for that specific element to render and that makes your robot more resilient to change clear that log restart launching the game takes quite a long time we could probably navigate directly to the game URL instead but I I thought it was kind of fun to record how to get there there you go we get that restart button with the score and I'll expect our robot to come back now it's still somewhere here okay let's do its magic because we are at the restart right now it's still running I'm not sure where it is running but it is running could be such a wait for create minus up to 30 seconds so there we go I actually did it move somewhere no okay so where did it fail it failed at get instance count of the button it couldn't find the buttons again sometime it looks like we have some problems identifying the buttons every now and then element button couldn't be found if I probably rerun that now it will find it okay so maybe let's as you said put a delay here come on get instance delay before execution get it another second here to wait for that as we have some issues with this one and maybe also okay the featured what was the last say nothing so there was the button we had before okay let's run it one more time see what happens from here no it doesn't find that okay we don't have a button on this page or what kind of button do we have is it looking different inspect that page scruffy Link Link section so it is you see basically it is fine right security Link Link section that's the configuration we have made to find buttons if I'm not mistaken are we are putting like a tags right uh like a tax to find buttons right so yeah it's exactly it's the attack and I said squiffy Link Link section that's the attribute we're gonna use to identify the button somehow it couldn't find that refresh or is the page different you oh maybe did the URL change good good reason yes the URL changed look at that it's now called index.html which is we are looking for games Pub oh it actually no it's the same so the page is fine yeah but the button inside the page is not there anymore that's weird if we'll take that off and search for a link it doesn't find it so something seems to be wrong with the connector not finding the elements it's a bit weird let's delete that when we don't need that I'm going to delete yes the score can we find that no it doesn't find anything on that page that's weird done let's do a save let's try one just two turn that one on and off okay reload the page and try it one more time nope doesn't want to find it that is weird o okay oh okay something I guess we have to spend a bit more time in our connectors but that's the way it should be working let me see Eastern new version maybe that I would need to update my connector that I might not have updated that one to you just still running old version tensions go to the Chrome web store but I would think that Chrome actually tells me that there's something new yes that's it yeah it's added so it is there and where do we see the e-version 1.2 and I have 1.2 yeah so that is up to date that should do it okay close the previous tab does it find it then was it looking at the wrong tab Maybe let's show run from here no that is weird Okay what we could be doing is I closed it already okay [Music] this one I think is still open right that's the other page we could do a map that doesn't help I I don't think it helps we can close that other tab which is probably this one yep okay so we can do here is as we launch the game we can use this tab and say close to make sure we only have that one tab open that we need close the other one okay let's try that I don't think it will do a big difference but no no stay here clear run so relaunching the game as usual that's good getting there now clicking the play button and now I would expect the other tab to close yep there we go it closes the other tab now it's trying to click three different random buttons it looks like it's working at the moment we get our 102 seconds delay and it looks already too long again some I have some issues really getting to that page yeah it's probably again down here trying to find I assume we'll see that in roughly 30 seconds and I will stop there somewhere there we go maybe we need to have another part of this episode but yeah continue that yeah continuing this thing I didn't find a score now we did find the button and uh yeah you see it wait for create actually returned after 30 seconds with a false you can see I I hope you can see the pop-up I can also do a preview here I can see default so it says I couldn't find that element but we don't respect that right we actually just move forward trying to get it still get the content of it which doesn't work so we could do a decision here like it didn't find and have some proper error messaging but the interesting part for me is actually why doesn't it find it it's up here right so that that's something a bit weird to me at the moment um certainly something I will spend some more time in debugging and figuring out how it works yes and I think like for the for our viewers who are looking into it they got a lot of elements like to play around with there are a lot of things that they can try and uh maybe we can have a part two of this and in which we'll go and figure out what's wrong with it absolutely I'm happy to come back be on the show and do that again you see I'm curious I'm still inspecting here so it's a bit or maybe I find the reason in the next 10 seconds actually yeah this one doesn't it's now section 98 okay that's weird Okay so that's why you didn't find the score that number here is changing so I'll need to find a different way how to identify that score element the scruffy section is not what I need okay regex or something like for example then if the number is changing if you just keep it like any number if it's in the particular tag so that absolutely and that's something we can do I can show you where but I'm running a bit out of time but yes we can do that and that was the part we I think that's where you're referring to right if I get that Diffie section here I can actually move that down here as an attribute and have here the comparer to change to regex and stuff like that so I can get more intelligent here how to find the elements and that's probably what I would need to do to find the score if I can take that all four to time being then it will find probably anything but not what we need I just find something let's let's see what we get in a text run from here what did we get score 300 okay so I did find it so I just took that squeeffe section off and it seems that is it maybe that was it we're lucky probably take some more testing now to run through a couple cycles and see um if that actually released what we need or if we get some wrong text in some occasions I think we got all the things like we we were able to get exactly like we were able to run the game truly from end to end so that's that's cool and that shows the power of service no RPA you can have fun with it it's not just about yeah doing it whatever in service now you can use it for other activities also so thank you very much Daniel for showing us uh the school RPA live coding happier demo and um yeah it's time to rate our drinks so I was thinking this so we can't go wrong with water what about you well the coke is warm by now and you know how warm coat tastes right so it's not a five for five anymore [Laughter] it's probably maybe two or so yeah yes success yeah thank you partly success it's that's great all right I think folks thank you very much for joining anything Daniel you want to plug in before we go off or a shout out to your background knowledge is coming around the corner it's about six weeks off right mid of May uh in Las Vegas um you can meet Mo a lot of people of us life I'll be there not your Prana will you be there I'll be there also in knowledge so we'll catch up absolutely if you are if the audience is there come and find us see us talk to us yes absolutely all right folks thank you very much for joining and we'll see you in the next episode bye bye thank you [Music] foreign [Music]

View original source

https://www.youtube.com/watch?v=s-Qtne3WpZQ