Appium-Mobile Automation Testing from Scratch in 2 hours

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome guys welcome to 15 step-by-step instructions to configure and run mobile automation test cases using rpm so in this section we will complete whole the installation which you need to run your mobile automation test cases right so you know what's the most challenging part in learning rpm the setup okay so one setup is neatly done without any errors you are almost there okay the rest is very easy because it's not easy to run if you see a web automation tools like selenium it's you just need a browser to run but to run mobile automation test cases you need a lot of infrastructure but i made that very easy in my 15 step desktop instructions so if you follow my lectures carefully and just follow with me then you can neatly complete your installation okay so it's not a big deal so that's why i charge it down into an word document so that if you misses any of my lecture or saying you can just go through the word document and complete the installation okay so let's start it step one download java okay so first let's go through it before we actually do it you know blindly let's see first of all to run your mobile test cases you need some android device right so physically you you can get have a real device you can plug into your system and test the app in your real device so apart from that there is a virtual device where you can run tests in the emulator okay just like an android mobile but that will be available as a browser in your mobile in your laptop okay so if you want to run your test cases web test cases using selenium you do that in browser right in the similar fashion there is one mobile emulator for sample available in android sdk okay so if you download the android sdk you will get that mobile emulator sample so you can run tests in that emulator just like you know running on real device so for that reason and also to support that android platform and everything you need to download android sdk or android studio it comes in complete android studio from their official site okay so once that is done and android infrastructure is ready now you need rpm to test you know that android apps for that you need to download node.js because rpm comes as a node module so i'll explain you what is node.js when we are talking about that specific lecture okay you will make sure you setup node.js in your mission and thereafter you will download rpm server client which is necessary to run the test okay once everything is ready what else you need you need an editor to write your code okay you have an appian jar to test in mobile you also have virtual mobile at the same time you also need to have an editor to write your code and that happens here with eclipse installation okay you will install eclipse and configure the rpm jars and then finally you start the ipm server and write your test cases okay that's what i said i'll set go at this point once you're done with the 15th lecture so 15 point right so to make it happen all this first of all you need java in your mission because underlyingly all the softwares need a java right if you don't have that and this doesn't work somewhere you will come across the problem so better let's start with downloading java first just to make sure everything runs as expected so i hope you already have java if not just go and say jdk download it's better to have entire jdk not only jre so okay go to their official website oracle.com and here you need to say jdk download right so click on jdk download yeah so if you are working on windows 64 bit you can select this if it is 32-bit then this if you are working on mac os then you can select this okay just accept the agreement and you can click on this so that it will be downloaded in your machine okay so once it is downloaded you can just run that dot exe file so it will automatically install files and java is ready in your machine okay right so once the java is ready your job is not yet done you have to set java home path in environment variables so let's see how to do that okay so go back to your c drive this pc once you install java it will automatically be in program files so when you run the dot exe file it will complete all the setup and then come to program files you will see java here go to java and go to this jdk and copy this path now so you can right click on your this pc or my computer if you are working on windows 7 okay and then click on properties and here select advanced system settings environment variables okay yeah here you go so these are the paths here you need to create a new path new say java underscore home and paste that path here okay and click on ok so i already have in my mission you can see it here java home i said that right so that's the one and you also go to jdk bin directory and copy this path again and then come back to your environment variables check for path variable yeah here it is so double click on that basically you can add one click on you and add that path here right and just just say okay so that bin path is also added here i already have so i don't add this maybe if you are working on windows 7 you might see something like this in this fashion so if you see in this fashion come to end give semicolon and add that path here ctrl v okay that's it so two parts you need to add one is java home this one and in the path variable you need to provide the bin path and then just say ok right that's it so java is successfully configured in your system and now your system knows where exactly java is located so that's the power of environment variables if you mention the path in environment variables and your system can easily identify the java location right let's come back so that concludes the step one downloading java and set java home and next and the most important download android studio okay so for that you need to go to this link or maybe tomorrow it changes so i would better prefer you to go to official website and check maybe you can say uh download android studio and you see that developer.android.com if you hit on this link you will be navigated to this page yep here you need to hit this link to download android studio it's 1876 mb that's a huge data but you should have good wi-fi to download it okay so there's no other option for us it comes as whole bundle so once you download this android studio it might take a while based upon your internet speed so once it is downloaded and you will see something like this let me go to downloads and you would see this icon so double click this dot exe file and it starts installing the files okay so it will take a while it might take up to 10 to 15 minutes to complete the installation so once it says the installation is completed and it will ask to click on finish with that android installation is completed in your mission okay it's very simple just go to their official website download this and run this dot exe file that's it so it will take a while and you can just relax but in 10 to 15 minutes you will complete your installation so thereafter we need to find where exactly this is located okay for that first you need to check android installation path so once you know android is installed where it will located in our mission that's the tricky part so java will be directly in program files but android doesn't come in the program files it comes but not sdk so i'll explain you here so this whole studio comes into two parts one is android sdk okay so it comes as a two parts once you download android it's one sdk and another is as an android studio so we need to identify both those locations first of all let's go and see where exactly android sdk is stored okay let me go back to my explorer yeah you can see it here come to see users your name about your system name and from here there will be slash app data this app data may be in invisible mode okay so by default app data will not be displayed in your folder in the users in your specific folder just don't get panic go to your explorer and say slash app data you will be navigated to another folder okay by default app data will not be there in your mission of course you can make it to visible too right so in app data go to local and here you will find something called android and here is the sdk right so we need this sdk to run our mobile test and we need to configure that in our environment variables too okay so this is our sdk folder and if you go inside and these are the necessary folders which we need to run our android emulator okay android emulator is nothing but a virtual device where we run our mobile tests i'll show you in the coming lectures how it looks right so we need this path and we need to set that in our environment variables because our system need to know where exactly sdk location i mean sdk file is located so by default if it is in your mission your system cannot detect it you need to explicitly mention that in environment variables so that system identifies okay so just copy the path like this and go back to your environment variables again advanced system settings so here again let's create one more new system variable and say android home just like java home right and provide the path of that sdk that's it click on ok so i already have in my machine and this is my path and draw it home so by default you will not see this folder in this path so you have to make some changes to see the tools folder so that you can give this path in your system variables okay so this folder is important we have this it have so many dot exe files inside it so to make this folder visible in your folder so first of all come back to your android studio so on successful installation you will generally see that android studio dot exe file in program files android android studio so this is where by default your android studio will get installed right so go to the bing directory and launch the studio because you need to make one setting and download this tools from this studio and then only that folder will be visible in your sdk folder okay so for the first time when you open this is how the window will open select any basic activity or empty activity it's up to you because we are not going to create any project here so we just need to land on that landing page so that we can make some settings change so to move to that home page you have to either select any project from the templates and then you will land something like this so you have to wait until the build got finished okay so right now some loading is happening so hold on until everything is finished and then we need to open this tools folder right there is a menu option called tools right so there will be an option called sdk so right now it is not displaying here because the build is not yet finished so just give me one or two minutes i will pass this video until the build got finished and we will see the magic of options showing here all right you see that it's almost done and now when you select this menu option you will see this avd manager and sdk manager so i will soon come to this avd manager concept but before that click on this sdk manager and then you have different options display here select sdk tools tab i told you right you need to have tools folder in your sdk folder okay so to make that folder visible there so come to this tab and uncheck this hide obsolete packages and then you will see one option called android sdk tools select this check box and click apply okay so it will tell you that following components will be installed so make sure you have enough space accept the agreement and that's it so this will take some time to install those tools right so i'll pass the video until this download is done all right so installation is finished it clearly telling that now your sdk tools folder is present in android sdk tools okay so come back and then you will see this folder okay so this is how you have to make this folder visible and then come to sdk tools and bin you need this location as well so copy this entire location tools bin and come back to your environment variables go to the path which we have seen in the previous lecture add the new path and copy it okay so you can see that i already have and apart from that let's have one more path yeah you can copy till here as well so wherever you see some kind of dot exe files you can copy that so you have done two till now one is sdk and another is tool spin and you can also take up to here again copy this go back and paste it you see i do have that as well come down till tools and tools slash bin okay these are the two parts you need to add and that's it these two are enough so if you want you can also have that's not mandatory uh platform tools yeah so that is not that necessary but just for the time being you can copy this and paste it here right i already have it so totally there are four system variables you need to mention one is android home and another is platform tools and next till tools folder number three and bin number four you can see that all four i have in my mission so one is android home and come on path two three and four that's it so you need those four system variables in your environmental so that your system detects all these dot exe files and this is must if you miss doing that you may not invoke the necessary softwares in the later lectures okay so that's it with that you have successfully installed android and set your environment variables path okay you see here set android home to sdk location and include bin folders folder paths in path variable perfect so five points are done so as i said whole android bundle comes into two parts one is sdk and another is android studio okay you also need android studio just to create all these virtual devices i'll let you know where exactly you need to use that but in general we will not use this tool much it's just to set up some basic infrastructure okay but testing purpose we will not use this android studio much but yeah you need that to do some configuration because you can set a virtual device android emulator from the studio only okay now let's see where exactly this android studio is located in our mission yeah so once you download everything you will see that in program files just like where you have seen java remember see program files and this is the java which we have seen in the previous lecture and now find out for android and yeah here it is so this folder will be automatically generated once you run the dot exe file and complete the installation and go here android studio and pin directory and here if you are running on 64-bit studio 64 is the location so double click it to open so that android studio will be open for you so it might take a while to open okay again i'm just you know telling you upfront so you need not panic again so it in my mission it take approximately 45 seconds now yeah now it started open so it it needed to install some stuff in the background so allow that to complete that and then android studio will be invoked let's wait till that is open okay so we just need this to create a configure let me write here a virtual device just to not confuse where is it yeah so for the first time when you open you might not be seeing the screen what i am seeing now loading project it's loading some dummy project but for you on the first time when you launch it will ask you do you want to create a sample project or do you want to import the existing project you will have some different windows okay just click on the sample project and just say next next next keep on clicking next okay so that you will be navigating to you know this kind of ui page to create sample project so basically android studio will not allow to use that features until you start creating project no that's a headache with this so we need to be serious in creating a project that's what android studio feels so we you will have two windows open when you open for first time like import the project or create a basic project so select that basic and just say next next don't worry about the content so finally after two to three minutes work you will be landing to this page okay so once you are here and once these toolbar is available for you you are good so because we just need this tools and android tools from this icon that's it apart from that we will not use any android studio okay yeah so once you reach this window here you need to configure virtual device so you need to create one virtual device so if you wonder why we need virtual device it's just to run our automated tests on that device okay so that you can visually see on the screen how the automation is happening okay so let's start creating virtual device in this lecture so go to the file if you have not already started new new project so just click on basic activity click on next and we are just again creating the base new project click on finish so trick here is if you want to open and create virtual device you can click on these tools but you see that right now it's not visible because you need to wait until the build is finished here so gradle sync started and you can see that two processes are running until unless all the processes completed running you will not see an option to create a virtual device okay so you have to wait you see that it's still going through some indexing resources perfect so once everything is done you will not see any process running here and you will also see that build is finished and then try to open tools again and now you see that avd manager sdk manager these two options are displaying now okay so this is one of the common question i get from students they will not wait until all the process have been run here and waiting for a message build is finished and then when they try to open this they will not find this option but hang on wait for a few seconds once everything is done then click on this avd manager what is avd manager avd stands for android virtual device so if you are still wondering why we are using virtual device this is the place where you automate your rpm test cases we create a device virtually on our machines and we deploy the app which we need to test on that device and we automate it using our rpm tool perfect so when you click on that avd manager for the first time you will not see any devices here you are seeing this because i already created but when you start creating this for first time you will see empty window here so click on create virtual device and so this is the first screen it will ask you on what type of screen you want okay so select any one screen or mobile device for android and then click on next so basically it creates you a virtual device based upon the device you select here okay that particular size ratio and density based upon the selection what you made here so select anything click on next and now so these are the different system images basically android operating systems which you want to deploy into your device so these are different things available select any one of the android target nine or nine plus okay and then when you click on next this particular image that means this particular operating system will be installed in your virtual device so it have an option to download because right now we don't have any operating system of android present in information so simply click on download and that will help you to download the operating system and once it is done you can successfully use that operating system and click on next so which os to select it's up to you okay you can see the versions so right now we are somewhere on android 9 plus by the time you are watching this video you might see some android 14 or 15 because every month they release new versions so that really doesn't matter what version you use use whatever the latest is available okay so i'm just passing this video instead of waiting till 100 is done perfect it's done so click on finish so that that particular operating system is ready in your machine and you can use that in your virtual device click on next and you can give the any name to your abd so i can say rahul emulator something like that give one name but remember this name because with this name we will invoke this virtual device in our later lectures okay so this is the screen width dimensions pixel 2 and this is the operating system version and when you start you are saying that start in portrait mode now there is something called advanced settings so here you need not worry about much factors but if you want to change any hardware skin something like that you can do it here but i don't suggest you to change any of the setting okay so this looks good so we will quickly go back to height advanced settings and click on finish and that will create you the new android virtual device that is rahul emulator so you can start the device by simply clicking on this play icon you can see that launch this avd in the emulator so select this icon and that will invoke virtual device in your mission let's see that you can read the console here starting avd and that's it the device is open um where it is here you go you see that it's booting up for the first time it might take some time to boot operating system in this avd give some time for this to load up and within one or two minutes you will see that everything is set on this emulator okay so this is how you can create android virtual device from android studio hang on um it's trying to boot up you can see that there is one screen one line it's representing that loading all the operating system into the simulator now so going forward if you want to open this emulator either you can open this android studio come to the tools click on this abd manager and you can simply start it from here this is one way and also android guys have given us some commands where you can start this emulator directly from your command prompt you need not open android studio every time okay because this will consume some memory in your machine so opening virtual device itself becomes your system little slow because you are booting up another complete whole mobile in your system right so ram takes that effort and that makes your system slow so you can open this emulator from command prompt as well so let me show that how to do this meanwhile emulator also booted up you can see that it's just the same what you can see in your android mobile okay so we have simultized everything as a virtual device and we will deploy the apps into this device and we will try to automate them so that's the idea okay so now remember the names of devices you created in my case it's emulator hyphen triple five four and rahul emulator these are the two different emulators i have in my machine okay so now close everything close your emulator close your android studio and now go back to the command prompt from command prompt with a command we can also invoke the emulator so whenever you want to do automation with rpm as i said you need not open android studio every time first time it is mandatory to create virtual device there is no other option but once you create virtual device thereafter you need not open the studio you can directly do it from command prompt if there is something wrong with commands then feel free to open the android studio and then open your emulator okay now go to your android sdk installation let me take you there as you know that android studio sdk specific sdk will be stored in the app data this app data may be in invisible mode in all our systems so go to this specific url box and type this app data after your system name and then you will be navigated here so click local and then android sdk and then you have a folder called emulator so this is the dot exe file which help us to invoke that specific emulator here virtual device and emulator both are same don't confuse in android terminology it will say virtual device which is nothing but avd and it may also say as emulator okay both refers to same so do not confuse on that first go to that path wherever the emulator directory is present in your system thereafter you need to provide this command emulator and what is that virtual device name avd okay avd stands for android virtual device and you need to give that virtual device name okay so whatever you created so i have two virtual devices in my machine one is emulator hyphen triple five four and the rahul emulator which i just created so if i want to open this emulator hyphen triple five four so give the command emulator hyphen id space give the name of your emulator that's it click enter and that will open you will get this message that hacks is working and you see that the device is open so this is one way and here we did not interact with android studio at all okay you can close this and you can again close the simulator and if you want to open it again emulator avd and the name of your emulator spelling mistake for the first time it might take some time in your missions to load thereafter it will be fast okay so this is how you can open your android virtual device these are the different methods available it's up to you which one you choose so we will start with downloading node.js so you might be wondered to download ipm why i need node.js so appium is a no comes as a node module okay so if you want to get node module into your machine you need to have node.js software right so node is world in itself and you see that angularjs all those are you know node modules in the same way even rpm comes as a specific node module and to use that rpm in our missions first of all as a prey request we need to have that node.js software just like a java how we have if you want to work on android and eclipse because they run on java mission at the same time uh if you want to work on with this rpm you need node.js okay so let's go and say download mod.js go to their official site and yep if you are working on 64 you can download this if it's in 32 this okay and once you download you can run that the dot msi file and click on next next it will take a while and complete node installation in your mission so once installation is completed you can find that node.js module in your program files let me show you it's just like when you see java and android studio see program files and once you click on finish button with that node.js installation uh yeah here you go node.js okay so yes we have successfully downloaded node.js and now we need to set environment variables path just like how we have done for java copy this path go back to again system settings environment variables create a system new system variable saying node underscore home and give that path you see that i already have in my mission right and apart from that you also need few other files let me show you more modules npm and bin yeah you need to have this as well npm so what is npm here you need to know the difference between note and npm so node is in software in that node you have a command line installer called npm so with this npm you can download any node module now ipm is one node module angularjs is one node module protractor that is for you know just like selenium but for angularjs web application and that is one node module so there are different node modules available over the net which are widely used across the globe okay so if you want to download all those node module you can download via npm only i'll tell you how to download appium with this npm okay so in node modules go to npm go to bin folder copy this path and place it in your path folder so just follow my lectures you will understand when i start downloading ipm okay the real usage of this npm okay for now just accept it go to path folder and create a new and add that npm slash pin this is must you need to add this i already have in my mission okay so let me click on ok you can okay right now go back to your word document you see that we have successfully set node home by going till this path and we have also set npm environment variables path by just going to the bin right all set now go and download the rpm so as i said in the when i when i'm explaining architecture ibm comes as a two packages one is client rpm client and another is rpm server okay so appium client in the sense you can write your rpm code in multiple languages so if you watch my initial lectures when i'm talking about capabilities of ipm you can write it in java javascript python c shop ruby okay so it's up to you you can code in any language that's specific using that appian api so that jars which support your language is called appium client now for example whole this tutorial runs on ipm java client okay you use java apm to talk to your mobile test cases so that is client jars so if you work on c shop you need to say appium c shop client jazz so it's up to you in what language you write your test cases you need to have that specific client jars so we need a fpm client charge the rpm java client jars and that is a client set and server side you need you need to have an ipm server which is common across any client okay ibm server is a unique and one thing which actually listen to your client code so when you write your java code here and hit and run and ask you to execute that this client will communicate with your rpm server and then execute test cases in your mobile that's how internal architecture works you need to send the code from your client side and from your editor tools maybe then eclipse and then code goes to the server and server interprets your code and then triggers the execution in mobile devices so that's the reason appian comes into two different components rpm server rpm client so when you run your test with rpm java code so it should send to server right so so server to listen to your client it should start we should download that ipm server in our machine and we need to start that rpm server then only whenever you execute something code server is ready to listen if you download and if you don't start your server when you are working for your rpm test there is you know there is no execution because server is no is not listening to your tests so rpm server invocation is the mandatory and the first before you want to run the test okay so theoretically it looks some difficult but when you start working practically it's very easy you can simply start the server with one click okay and then run your tests that's all so why i'm explaining this concept means now we need to download server separately and client separately in our machine okay maybe i used to get a lot of mails from my students asking so i already downloaded ipm why again we are downloading a game okay that's why you know in my next lectures this is the remake of the previous lectures okay so i want to now clearly differentiate between client and server here we need to have it separately so my earlier lectures are an ipm 1.1 one year back now they are updated so even i updated my lectures with all the latest installation so there is no android studio when i start teaching appian it just come as sdk folder and now they have provided us neat ui to you know create virtual device earlier you know there used to be a lot of comments from command line it's a big work now they made it very easy okay hopefully they'll make more and more easy in the future right now let's go and download ipm server first so this ipm server comes as a node module okay this is the node module so node modules can be downloaded via npm only so let's go back to our command prompt and let me create one more so how to download rpm in your machine so you can down first of all note down this point so just to avoid confusion for you you can download any node module only using npm npm is a command line tool you can google it what is npm it's a command line installer which helps to install all your node models so appian is node module let me download it with the command npm install iphone g yeah so you need to say npm install hyphen g in the sense installing it globally in your system right so we are just asking our npm to go and get me the rpm that's it this npm is responsible to connect to the server node server and check for this rpm node module and it downloads into your mission so all that npm takes care we need not very like where exactly it is located and from which site you need to download okay for example in the previous lectures if you want to download android home we we went to their official site we brought that we click dot exe file no it's a long process right but that made easy when when it is a node module okay with npm we can simply say npm and go and install rpm that's it you need not worry what happened it back end but ultimately once the installation completed rpm will be in your system that's the beauty of npm and the node module right let me hit and enter so it takes a while to download probably two to three minutes i guess based upon your internet speed and your ram configuration just be patient okay so it takes time to install it's still running so maybe for the first time it might take i just uninstalled yesterday to demo again how to install it freshly so just be cautious and patient till it get installed probably it might take four to five minutes it's up to them so let me pass this video i don't want to just waste the time waiting for that so once installation is complete i'll resume it again okay you see that installation started it's extracting all the files you can see that into that node module right it's done so it successfully installed all the dependencies which is needed to run rpm server in your machine you can see that so it took me five to seven minutes to complete maybe in the same in your case when you are working okay so these all are the dependencies you need to run that rpm server right so once the entire rpm is downloaded so now you can start the server simply by typing the word rpm and hit and enter and that's it apim server will start immediately you can see that with this message you can confirm that rpm server is successfully started in your mission now you might be wondered that you have given this word from some random path but still it identified where exactly rpm is present in your machine and it started the server so the reason behind that is while installing you have given like this g stands for global keyword as i said this is helping us to identify this rpm in your system anyway wherever you install when you make it with hyphen g global that is applicable to every part of your system so that's the reason you can simply provide this rpm word and that's it you can start the server it's very easy right so once you install going forward when you want to practice just open the command prompt and hit this word that's it wherever it is installed it will go there and it will start your server you can simply confirm by reading this message called welcome to appian and if you want to stop the server click on control c and then you will get like this terminate bad job select y and hit and enter so that your server is now stopped you can restart again by just typing this word called appium and your server will start again okay so this is how you can install rpm and start the ibm server okay so let's do the final steps 13 14 in this lecture and can wrap the entire installation so let's get the java client library so you can go to um and just say download rpm you can hit on first link and these are the client libraries i told you right rpm client libraries okay select the java and it prompted to maven website so from here you can download the jar just click on this download icon and say jar and that will helps us to download this java client jar in our mission and this is client-side java jar which you need to support your appear methods and you need to import that into your project that's all this can be done with just one simple click now let's go and download eclipse which is an editor to write all our code and now you need to create a project here okay let's create the project right click new project and then click on java project because we are going to use java client libraries of appium right so click on java project say next and you can say uh and say tutorial some random name to create a project okay click on next and say finish so this is the project we created so in this project we are going to write our test cases so how do you write a test case for that you need to create one java class so in that class we will actually write our rpm code so let me create a java class in the source folder right click new class and you can simply say some base and select this public static word men so that by default it gives you that java template and that's it here is where you need to write your rpm code okay so this editor supports the api execution so you just need to create one project and in that project just create one class it's nothing but a test case so just see in terms of testing terminologies class can be treated as a test case and project name can be treated as test to suit so here we are in tutorial test suit and base is our test case so in this test case we will write our rpm code which satisfy the requirement of this base test case okay but so if you write rpm code will this eclipse recognizes it no because it doesn't have knowledge of ipm right it's simply plain java class but how would it identify appian java client libraries so this tutorial project need to have knowledge of java rpm client libraries then only if you start writing your api code this project can recognize and execute now we know where integrated our rpm jars into this project okay so that's the reason so whatever the code you write system will not execute first of all you need to provide that knowledge to this project we can do that by configuring our jar which we downloaded rpm client jar okay into this project you can do that simply by right click on a project properties select java build path and in the libraries path say add external jars select the java client jar which you have just downloaded click on open and that's it click on ok and now this project have knowledge of your rpm code because we have brought the jar and configured into this project right apart from this appear client libraries we also need selenium jars so you might be wondering selenium is for web right why do we need it for mobile yeah but still there are some web elements handling in mobile as well so for example when you are dealing with mobile app sometimes it connects to web app at that time if you already have selenium jars in your project then you can those stars support us to continue execution without any heart okay so just make sure you also have selenium jars in your build path not only appiam though you are working for mobile apps you may also need that web apps okay it's because sometimes if you find an element with xpath css selector even in mobile so selenium apis are more strong and even though supports mobile also so not that consistent like ipm so better if you have those jars as well in our project so let's go and get the selenium jars as well just like how we got appium java client libraries just say selenium download and go to their official website as we are dealing with java client on front and side for rpm so just go here and click on the download these are different languages available for selenium to automate you can automate your selenium with c sharp ruby python just like how can appium does with different languages as we are interested and this course is specifically taught on java just go and download java specific selenium jars okay you need to unzip them once you download into your machine i have already have the unzipped folder so i'm not doing it so you can unzip it with your favorite uh jib software like win jeep or seven zip all right so now let's go back to our eclipse and we will import selenium jars as well just like how we have imported rpm java client libraries okay so let me i deleted ipm java client again let me install it freshly so this is the java client the rpm one click on open and then again click on add external jars because this time you want to import another set of jars which is nothing but selenium so you should see selenium java give me a second yeah here it is so open this first of all there are two jars in this folder import them carefully and again click on add external jars because there are few more jars in this lips directory as well so open this folder select all these jars and that's it hit on this apply and close your tutorial project is more powerful because it have a knowledge of rpm mobile as well as selenium web now so whatever code you write now will be executed by the eclipse because you have provided sufficient information regarding those charts okay so that concludes our setup so from the next lecture we can directly start hitting and writing our first basic program on ipm okay it's done there's nothing more so i think we have probably taken one money forward to wrap up everything so let's go and reback if you have done all the correct we have java with us we have android studio we downloaded that and it given us in two separate folders we have set android home environment variables in sdk location we have opened studio and configured this device okay and then we have also made sure our emulator is working and from command prompt also i have given a command right once everything is done android setup is completed with infrastructure we switched to node.js and got our rpm server from node and you can see how it is listening and we also brought client libraries and you may also say download java and selenium we need both so we got also client libraries we downloaded eclipse to write our code we have successfully created a project and configured appium libraries into it and we also started ipm server with just rpm command so that's pretty much about installation and setting up infrastructure in our machine right so now let's start writing our code first of all let me explain from where we need to start when we are building the code for mobile automation test cases the first is you need to talk to your appian server and then ipm server invokes your virtual devices or real devices whatever it may be which are connected so firstly to that information you need to pass from your client to code to your server code yeah if you see that appian server is started and it is listening at four seven two three port now you need to send the information to this server and rpm server interprets that information okay now my you know requirement is my desired information i will say my desired capabilities so what are the capabilities i am expecting my rpm to launch okay that is my desired so which i like the name itself says so i want to open an emulator i'm going to open rahul emulator because my name of my emulator is rahul emulator if you go and check here you see that travel emulator okay so i'm working on this so when you are creating your virtual device i i told you right how to give a name for it so whatever the name you have given for that emulator will display here so you can use that your emulator to launch okay so and testing should happen in that emulator that is my first desired capability and next i want to test one a one app maybe some xyz app i am going to test so initially that app might not be in your emulator because at the first time emulator comes as a brand new right with few of the built-in apps so you want to tell i want to let install this app in this emulator so that i can test it so these are the basic information you need to pass so so that server knows where exactly which emulator to invoke okay right so let's say there is one ios in uh simulator is open and one android emulator is open at the same time in your system and when you talk to a rpm server to invoke it definitely confuses if you don't provide this information okay first of all it listens what are the active devices right now connected to my system so if there are two devices and it do not know what device to it it should root to test so from your code you need to clearly tell that open go and work on this specific emulator and next it cannot directly start testing it should invoke that app in that emulator so you need to also tell what app you need to invoke so that once it invokes then you can start testing okay so these two information you need to pass so earlier in earlier releases there is one more capability which you need to also pass like which platform you need to work like android or ios okay but the latest releases that step was depreciated so internally they are taking care okay so earlier there was no that mechanism so you need to tell to your ipm server on are you working on android or you want to execute this test on ios even that information you need to pass but thanks to them they made our work very minimal by asking us to provide these two information and and thereafter one more important information which you need to pass from your code is first of all you need to talk to your apm server right so how do you connect yourself to your ipm server that's the question okay so that's all fine we thought that these are the two information we need to pass to our appian server that's fair enough but first of all how do you connect yourself to server and then you can pass this information so you need to also write one connection step to connect yourself to that server so once you write this three steps and hitting your from client side it goes and first of all connects you to server and thereafter it opens it gives this information to server so that server opens the emulator and invokes that app so after this whatever you code you write that will be executed on your emulator for that specific app this is the concept this is how it works internally right now and this code this template is common for every test case so whatever the mobile test case you write in a separate class so you need to pass all this information okay you need to tell what is the emulator what is the app connection to server and this is the common template for every test case maybe if you write all those test cases in single file it might not required but if you maintain separate files for each and every file you need to pass this information okay and before you do this make sure you work i mean before you run this test these are the prerequisites make sure you your um rpm server is started i'll give again need documentation from resources tab i'm just giving a rough now make sure your ipm server is started before you invoke this test see all these are one-time efforts so once you have done this thereafter you will you need not again reinvent for every test you can just copy paste i'll show you how can we do that in the later lectures okay so you need to make sure your rpm server is started and you need to also make sure on what emulator you're working that should be open okay so when you hit this execution server will try to identify this emulators okay that should be open if not it will say emulator is switched off and i cannot work on it okay make sure your emulator is open that's it you need these two conditions to be satisfied before you hit this test case okay we are we did not actually start automating the code this comes at here okay before that step one make sure server is started and go to your command prompt if it is not started just hit rpm and wait till you see this message welcome to rpm and it is listening on this port number so that means server is started and at the same time make sure your emulator is open okay i am working on android 7.1.1 as i shown in my previous lecture when i'm working on virtual device even you can use the same emulator it's up to you yeah so both these are open and now okay then step one is completed let's start building the step two so how do you pass this information from the test let's see that okay go to your document and say desired capabilities we need to create an object there is a class called desired capabilities which actually takes the information in json structure and gives that information to the server okay this desired capabilities class can do all this stuff and we are interested to complete this thing right we need to gather all of information and send it to server and capabilities for that rpm and selenium guys have created one class called desired capabilities where we can pass the information from this object and send it to server okay so move your mouse onto this and you will get some suggestions for importing package and you can see selenium dot remote you see that this package actually we are importing from selenium so that's the reason i asked to import selenium jars as well perfect error is gone now cap dot this is an object right i just created an object so with that object i would start cap dot and you will get all the methods related to that and we need this one set capability okay so in this we are setting now capability the first capability what we need here um emulator right so you need to pass capability name and that value i'm pretty sure value is rahul emulator because we are passing the emulator information but what is the capability name for this it's mobile capability type this and say dot and check for emulator seconds just check dot device name yeah this is the one so we need the device name right perfect you see that so we have successfully added this capability so we are saying i need a device name called rahul emulator to open so that i can work on it so you can send this information right next cap dot again set capability and what next we have this is done we need to send the app information right to be invoked same thing you can copy this mobile capability type and say dot see these are the different capabilities you can send from your client to your app server there are lots of things but all these are optional so for you to basic for the script to execute you just need device name as well as the app okay you can also pass rpm version which rpm version to run okay for example there are three servers open in your mission like this server version is 1.6.3 and you can also download one more version and open that version 1.6.4 so from your system how do you ask to connect to specific version you can say dot rpm version connect to 1.6.4 server okay but in general let's stick with only one version in your system okay so and when you are working with browsers you can use browser underscore name on which browser you need to invoke so right now we are only working on nato apps so i'm sticking to app if you are working on mobile browser you can see browser name you can hit that which we'll see in our next sections okay so all these are and you can say which orientation with which orientation you should start your emulator if it is in fact uh landscape or portrait okay and platform name platform version so but and for as apm guys minimized it they just have done a fix and from this version it's just two desired capabilities enough for you to invoke app okay so dot app and here you need to provide that specific app path where exactly it's located right so you can simply copy paste the location where exactly you place the app but better to write in a perfect coding standards so first of all let's copy and bring that app into know this path okay let's bring that app into our project and we can copy that path into here yeah so let's get the app from my other folder ipm space tutorial so yeah here it is copy and i'll copy it here in the source folder perfect now i have my app here so which we the app name is api demos which we will be using in our next lectures to test and understand the mobile automation from this app because this app was officially provided by rpm guys it has lot of lot uh ui functions you know which it's a good practice for us to you know start with because you know uh if you want to scroll down if you want to swipe if you want to zoom and if you want to what else the native events we have in mobile as the mobile gestures if you want to specifically long press if you want to open the right click or context menu so there are a lot of mobile gestures available for you and we will see all of them in our coming lectures and this app supports all of those gestures so this was a perfect example to pick and to teach because i have taken lot of apps but few apps doesn't have few gestures to explain and few apps missing some other gestures but this api demos app have everything so this is the best example for you to explain all the topics so that's why i have picked this if you want to see that api demos app in my emulator if you see that api demos yeah this is the app so you can see how to handle with media graphics preferences views you know there are a lot of things to explore which we'll be seeing in our coming lectures okay so this is the app which i need to install and invoke in my raw emulator right you can simply right click on it go to properties and pass this path exactly into this so that you know we are exactly showing that where the path is located but as per coding standards we cannot directly hard code the entire apk path so better way of doing it is using a file method in java it's nothing a weird thing all this is all one time effort okay if you write this one time and in every test you can simply copy paste you need not reinvent the wheel all the time by defining this capabilities okay import file java dot io okay so file fs let me complete this two steps and explain you uh f s copy this refactor okay f perfect now so what i am saying go to source folder first so that i have taken that into f object so in source folder again i'm asking go to this specific path i mean that specific name of that apk and i'm storing that entire path into fs variable and here i would simply say fs dot get me the absolute path that's it so in this way you can avoid hard coding of writing paths here so that you can take this project and place it in any system it will work okay but rather than that if you hardcode saying c users rahul something like that and if you take this project into another machine and they will not have raffle folder right it definitely fails so that's a reason we are using file method file class in java where first of all we are going to that specific source folder and from there after we are pulling out that file name from that source folder and we are assigning it to object fs and i am calling this entire path with fs dot get absolute path and this is the best way of handling it because when you are working in real time there might be more than four to five people working on this automation and if you have created a test with your local path and if you push into your git or svn and someone takes the code and that doesn't work for them because it's in your local right when you say user slash rahul and his name might be different and that doesn't work but in this manner it works in any system so that's the best practice of giving the absolute path right so let's go back to our document we have sure our rpm server started emulator is open we have sent a desired capability of opening emulator and we have also said app information okay that's what i told that where exactly app is located so that my server picks the app from here and go and installs it in this emulator right so the last step which is left is connection to the server now so first of all to send a connection to server you need to create and invoke an android driver class as you are working with android driver you need to use android so when you are working with ios you will use ios here android driver a t let me create and explain you so this is how fast we create a basic driver for android that is id move your mouse here and import ipm.java client android okay so here it was saying that you need to send some parameters so in this driver method driver i can let me run driver here okay so this driver object helps us to automate all our tests okay from the next step maybe if you want to automate each and every test scenario in the app you will do with the help of driver object because this driver object have capability of handling android os but in this you need to send two arguments to this class first argument is connection to server link and next when you are sending connection to the server at the same time send this capabilities entire capabilities you need to send to server right now this cap object have these two capabilities if you see cap dot set capability cap dot set capability so this object stores cap object stores all this information so that you can now simply send cap object that's it so server will retrieve this object and get that all the information okay so you need to send these two parameters so to server we would only this step goes only this one step will be connected from your entire test to form a connection so in this step itself as a first argument you have connection to server so that it connects in this step itself you have second argument called cap object and it will open the cap object and gets all these capabilities and then it invokes in the mobile okay and in this step itself you have driver object which is responsible for executing your test cases from the next step okay so this was the key step in your rpm test case so all these steps we have written to just send us an object for this step right and here you need to pass server link so that can be done let me copy paste it here yeah so there is a url class where you can pass the entire string so you might be wondered from where exactly i got this ip address so server is staying at the specific ip address so i'm asking to ping here if you go back to your server it says i am listening on four 4723 port three port zero dot zero dot zero dot zero that's nothing but your local host in your local machine it's listening on four seven two three okay that local host ip address is 127.0.0.1 so that is common to every windows machine okay not only windows machine any machine any network machine have their local host as 127.0.0.1 not only in my machine it's in every mission so that's how their ip address runs so if you are familiar with networking you will understand that okay so we know that it's in our local host so this is our ip address for every local host in every mission so i have given that instead of four zeros and four seven two three is the port where app aim is listening so column four seven two three and this is like web driver wd web driver hub so that is where we are actually invoking and setting up our connection to our rpm server that's it so this is the step you need to write there are some errors in the step let's fix that firstly move your mouse into that url and import this java.net okay people confuse and import the first one all the time and they keep on saying that we are not able to run the test so please use the second one okay and then you will get one more error like this move your mouse again and say add throws declaration perfect now there is some yellow line here warnings let's see that okay so from the latest version it is expecting to have some you know references you can say like this i'm going to work on android elements right again you can import this import android element and same thing you can do here perfect so the error is gone so what all we have learned from this lecture the single step does everything we need to work on our android ios so i have created android driver class in that class i need to send two arguments one argument to form a connection to my server i know that my server is listening at four seven two three port in localhost so same thing i have given here localhost ip address colon 4723 so slash wt slash hub which actually connects to my server right first argument connected to server after forming connection i need to send all these desired capabilities so my server have knowledge to like what emulator to invoke and what app it needs to work that knowledge i have used capabilities class and have thrown entirely entire information into cap object and i am passing that cap object so that it opens and get this information that's it that's what we need to do so why can't we run at this test case and see whether the app is invoked or not right let's run this test case okay just before that make sure your appian server is started yeah and then your emulator is open perfect now right click run as and say java application okay so you can quickly open the logs to check what's happening and you see here a app will open in this emulator and you can see the logs you see that api demos app is open it just got invoked congratulations we have successfully invoked an app with the help of rpm okay so you see that 200 which is a success and these all are the locks and make a habit of watching the logs and find out the actual you know error or success okay so the log says everything if something goes wrong by seeing the logs you can understand where exactly the problem is okay so that's how you can start your testing you know this is the first step to begin with so see that i told you right initially infrastructure setup is the only hurdle in rpm so thereafter from next lecture it's just a cakewalk you know we have taken up to two to two and a half hours to reach this point starting from a blank installation and we do not have anything in our mission we got sdk vdac emulators the infrastructure took itself one one and a half hour for us and thereafter we need to know what about this capabilities how to form connection how to open the server so finally once everything is set up in our machine we were able to invoke an app in our emulator which is our first success stone okay now i need to tell you some tips before you start with a testing here you need to once you run the test it says script is completed and execution is done with the 200 status okay that's point number one thereafter connection is not immediately closed it will take some time to close the connection now you see that it will wait at least 60 seconds to close the connection if you run if you try to run the test again before the 60 seconds of finishing the previous test it fails saying connection is already opened in another test it will give you that error okay so what you need to do is you need to wait 60 seconds before you run another test so if you don't want to wait for 60 seconds if you want to quickly run another test you need to close that connection so how do you do that so before that just read out the commands here we have done till here our test is completed and after 60 seconds shutting down because we waited 60 seconds for a command okay you need to wait one minute before rpm shuts down and then it's shutting down android driver it close the session okay so once the session is closed you can start working again but if you don't want to wait 60 seconds till that session is closed you can forcibly stop the connection and start the connection again right don't confuse between the words connection and session i need to give this tip before you begin because you know people will face problem in running the test so once the test is completed this session takes 60 minutes oh sorry 60 seconds to close so once after session is closed you need not start the server again just a session is closed but connection is still open you can run your test but if you don't want to wait the 60 seconds and you want to run the test again you need to forcibly close the connection rpm connection and then start it again so let's say we are in scenario one here i have waited for 60 seconds in explaining the concept so it finally closed that session and you can see that moving to state stop the connect uh the specific session is closed and you can run the test again without tweaking anything here but before 60 seconds if you want to do hit ctrl c to close the connection okay one moment and you will get something like this receive sign it shutting down eliminate bad job save y and hit and enter so that rpm connection is fully closed now start the connection again with the rpm command hit enter yeah you see that and now again new connection is open so just keep the step and once you hit and enter it will not quickly open that specific rpm server it might take some 15 to 20 seconds to open this okay based upon the system ram and everything and when you start testing and if you still if you hit this run as java application and if you don't see any locks here and if it is hanged to this point just click on enter and see so that program begins so all these are little bugs here out here out and there for this version maybe they'll fix in the later okay these two are not the bugs these are what they set a general default timeout okay so but programmatically you can start this server and you can close it okay right now manually you are starting the server and you are closing it right you can do it programmatically but i would tell you that all this in a later sections okay again that involves a little code i don't want to you know mess up everything in single shot so first of all let's learn some rpm let's learn some automation and if you see something is automating in apps we will get some confidence so thereafter we can slowly come back and i will explain how to start and stop rpm programmatically okay so we need you know some kind of encouragement and confidence and that we will definitely get if we start automating something right so from the next lecture we will actually look into those parts so right now we are in this place api demos this got invoked and now from here i want to click on something and we need to swipe we need to scroll so all those we will start it from our next lecture so now we begin with one two learning that is android ui automator now my purpose is to click on this link or scroll down so whatever it is first of all if i want to click on something here i need to know objective of it right if you are familiar with selenium we have a tools called firebug fire in firefox and inspector tools in chrome and internet explorer to identify the objects of this all the ui options okay so if i want to click here let's say on preference i need to know the object of this preference so how do i get object of this preference so in web we have a specific tools to do that but in mobile how can we get that so that's an interesting question so for that android guys have came up with tool called ui automator tool from that you can actually get the objects of all these now in this lecture let's try to get the objects of these options with the help of that tool so where exactly the tool lies let me show you go to your sdk path slash app data okay sdk right so in sdk go to tools folder and bin and you will see it here ui automator viewer okay just hit this link first of all one window prompt will open like this thereafter within 5 to 10 seconds you should see the ui automaton viewer invocation here you go so this is the tool which helps us to identify the objects in our mobile app so how to do that now i want to get the objects of all these for that first of all you need to take hit this link which takes the screenshot of this app okay make sure that your mobile is open before you invoke this ui automator viewer okay so if you invoke this first and then next you might not see the properties properly so as for my experience you need to open emulator first and thereafter ui automator viewer now if you want to objects of this page if you hit this link it takes the screenshot of entire your device and it gives the objects of it let me do that you see that obtaining device screenshot and here you go so these screenshot whatever you are seeing here is replicated in this ui automata viewer and observe it if i hit any object here so all the objects properties attributes related to that specific os button are displayed here like index text id class name package and at the same time you can see how that xml hierarchy is displayed you can see that view as well like text view if you hit on nfc you see that it changes if i hit on hardware it moves up and it displays all the details related to that hardware so basically if you want to click on any object in mobile app or if you want to perform any operation on specific ui icon you need details of that ui icon okay with that details only you can click on it now for example if i want to click on app so i need the details of that app so that i will pass those details in my script which you will be learning in the next lectures okay by passing the details in that app and i will say to click on it okay to get the details we are using this ui automator viewer so with this tool if you spy on any object here you will actually get all the details about that object here like what is the text what is the id given by developer for this hardware what is the class given by the developer for this hardware so we need all these details for our automation okay so without these details we cannot automate that's pretty sure right we need those attributes so that we will pass that in our script and try to click on these links so to get this details we are using ui automator viewer so in our every test to identify every step of automation we will be keep on depending on this ui automata viewer to get the object details okay so this was the tool which we use in general when we are working with firefox for web automation we have a tools like firebug firepath and developer tools even in chrome in chrome to identify the objects for automation we have right click you have inspector tools if you work with a tool called qtp and they even have one window to identify all these objects okay they say it is object identification window at the same time if someone ask how can you do that in rpm with android you can say that with the help of ui automator viewer okay so this you need that before you start the steps okay and thereafter so this is the one and let's go back to our code and i told you that for every test case these are the common for at least next six to ten lectures probably i'm not sure based upon you know our wavelength our understanding that might take up to ten lectures so up to ten lectures at least i will be using this api demos app to explain all the concepts of ipm okay so for all those steps for all those test cases opening an app and emulator connecting these are common steps right so what i'll do i'll place it in base class and i'll create separate test for all my rpm test cases and i will you know call this function there okay so that i don't want to write for every test case rather than duplicating i'll call this function in f in every my test with a single step so that you know it's easy for us to avoid this writing all the time so let's do that in this session before you know we begin with automation let's actually wrap it up in separate function and use it right so let's write that in function rather than public static wide main static capabilities okay so move your mouse here set return tip to y and add thrust declaration basically i'm wrapping all these steps into a function and in my every test from the next class when i start doing for example in my next class i'll start on automating one end-to-end scenario or clicking on this link and some validations so however i need to call this all that these steps before i do that so rather than i'm writing every time i'll wrap it up in one function and from in the next test i will just call this capabilities method that's it so i can avoid the duplication of work and time as well so in the capabilities method it actually sets file name capabilities and then i need to return this object i will say return driver that's it and move your mouse because you need to change the method return type to android because when you are writing driver you need to set return type to this because this return type data type is this one right so same you need to set it here okay we have one base class in that base class we have one capabilities method right which actually does everything now let's start with our one more test class here which we do actual automation here we'll start with the basics of you know identifying an objects with the help of ui automaton base basics yeah so if i want to create one more test rather than again copying all the stuff i can simply first of all inherit the properties from this base class i can do that with the help of extends keyword okay so with the help of extends keyword i can actually use the methods defined in the base class into my basics class so more about this you can learn in my code java tutorial which you will find at the end of this course at the end of this course you have separate dedicated section explaining core java concepts okay but for now please don't go there let's continue the rhythm only in this single lecture you will see this kind of related java because i am reusing the stuff but for next lecture you will not come across any core java stuff okay just don't waste your time again into switching java let's keep momentum going so if you have not heard about inheritance in your life till now i'm just going to explain what it is so with the help of extends keyword whatever the methods defined in this class you can reuse in this class if you use this keyword that's it and that we say as inheritance inheriting the properties and methods of parent class to child class perfect now so now you can just call capabilities method okay so move your mouse and say change to capabilities the method name and natural declaration yeah so what does oops sorry yeah here in our capabilities method we are written in this driver object because as i said in my previous lecture this driver object is responsible for all your automation okay so when you have defined all these steps and you have defined driver method make sure you send this driver object to your basics class okay so if you don't send this there's no point of writing that in separate function we need driver object here to continue our execution from this a specific point okay this step will reach us to till this point okay from here after you need a driver object so the driver object we already having defined here right so we are just writing it so this method will actually return the capabilities nothing but driver so unless i need to drive it yeah so in java you cannot leave any variable blank without defining so for the first time you are defining driver object into this class right you need to tell this class what is the data type of this driver go back to your capabilities method carefully and see what is the data type this is the data type right copy it come back and give it here that's it so you're all set okay now run this test it will again invoke all the steps which are present in this capabilities okay it basically executes this capabilities method so what we have in capabilities we have till the method invocation that app invocation we have right and that executes in this basics as well now you see that i have avoided all those code in my next class by just calling that specific method so here after i can start directly with driver dot and the rpm related code to automate my stuff i need not worry about that all desired capabilities all server apks and everything i will carefully define for single time all these and i will keep on inheriting and using in my every test case okay till i use the specific emulator and specific apk i'll just call this step in my every test case okay so now if you run this test let's see what happens okay make sure your server is on okay so run as java application click on ok you see that it's running let me go back if you see see that ap api demos got invoked with success 200 result and i don't have any step here just because i call this method that's it so we are all set we know how to get android ui automator objects also in our next lecture i'll take one end-to-end test case a scenario like how to click on preferences how to click on that link and how to go to at the end page okay there is some set of scenarios for every lecture we will pick one test case end-to-end scenarios and we will automate it like that we will know all rpm related concepts with this api and one more thing uh so once these lectures are done from next lecture count on till 10 to 12 lectures so once those are completed you are good to start you know updating your resume because you know you need not wait till you complete the course you can start when you are parallely running with course because you know all the basics right by the completion of 50 of course you will be knowing how does appian work what how does it invoke and what are the methods you use okay at the same time you can actually update your resume with the appium skills which you are keep on learning okay just don't wait till you finish the course completely so if you want any inputs in resume as well please drop me an email i have good resumes on rpm template like how to put all those in the project i can give you so that you know you can use that in your resume so all the resume inputs which i am giving will be related to this course so it's easy to you for you know compare and use that skill in your resume so that if someone ask a question on that you can clearly answer right so if you want anything that you can email to this gmail address okay that's pretty much and we'll meet in the next lecture with a sample test case and we'll take from there okay thank you [Music] you
Info
Channel: Rahul Shetty Academy
Views: 49,493
Rating: undefined out of 5
Keywords: appium, automation, selenium, mobiletesting, rahulshetty
Id: Fx3ud5wMHYc
Channel Id: undefined
Length: 106min 2sec (6362 seconds)
Published: Tue Aug 11 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.