Appium Beginner Tutorial 16 | How to create iOS automation testing project in java

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome I am Jeff and today we will learn from scratch how to create iOS automation testing project in Java and this will be very easy and very interesting and we will go very basic step-by-step so we need a ID and we are going to use Eclipse in this video we need a p.m. Java library that we will get from maven we will get selenium Java library we will add desired capabilities for our device and we need our iOS device or a simulator so let's get started and the first thing is we have to open Eclipse IDE so I will just go and open my Eclipse and you can see my Eclipse is here and you can see this is the earlier project we created for Android and you can continue on the same project or you can create a fresh project I am going to create a fresh project so that it is easy for everyone to follow so we have to create our new maven project and here I will just go to file and go to new and I will say others and here I will search for maven and here I will get even project I will click this and say next and here I am just going to select create a simple project and I also want to add to a working set because I'm using a working set now do not worry about this this is just because I do not want to show all the projects in this package Explorer which will be look very cluttered so just for that I'm using working sets you do not need to do this and I will say next and I have to give some group ID I will say group dot i OS test demo and here I will also say our us demo and just say finish and you can see it has come here iOS demo project and here in this project you will find all these folders already created so you can see all this is here and then I will go to form dot XML and here I have to add that dependencies so then step is we have to add the maven dependencies for APM Java client and then selenium Java so for this I will go to Google and I will go to maven repository here and this will take us to ambient repository comm I will just go here and search for APM Java client and this is the item Java client I will go here and let us take the latest version which is seven dot 0 dot 0 and here I will click this it is copy to clipboard I will go back to my project and just before the project and tag I will create or tag for dependencies I will press command spacebar on my keyboard to autocomplete and inside this dependencies I will copy this from the maven repository which I have copied from here and now I will search for selenium Java and here I will get the selenium Java libraries I will go here and here so we also have selenium for now which is in alpha so I am not going to use this let us just use the version 3 which is the latest version 3 and I will just copy this from here and again add it into the form dot XML file and save your project and once you have saved and build your project you will find the maven dependencies here so I have just saved my project and you can see all these libraries are now added so once you have done step number 3 let us go to step number 4 where we will create a class and then add our code so I will go to the folder SRC test Java and right click new class and I will say this is first us test and I will also use a public void main method and say finish and you can see our class is here so this is our class let me increase the font I'm pressing command + + on my keyboard yes so now here we can start writing our code I can write everything in the main method or I can also create a new function so I will just say public static void first test and then I can call this from the main method like this and in case you use test ng we can put all this code in the before test and test and after test methods but as of now I am just using a simple class without using any other framework so I will do all this coding here in this function so now what we have to do is in case of iOS we need all these desired capabilities and we have seen the desired capabilities when we were doing automation on Android as well and if you go to if you search for iOS desired capabilities on Google it will take you to this appium website where you can see the desired capabilities so you can see these are the desired capabilities we need so like platform will be iOS platform version we have to give the iOS version the device name the automation name and in case you are using any native application you have to give the location of the dot a PP file or dot IP a file and you can see all these desired capabilities are here you can also see if you are using browser you can give something like this browser name and you can give this Safari or Chrome or any browser that you have and all these us here this is for Android only and then if you scroll down you will find all this iOS only desired capabilities are also here so UDID is the device ID in case you have a device ID you will give it here and this is what you can therefore I will also copy this link and make it available in the notes so that you can refer this and now here I have to use this code so I will just say here desired capabilities and I can give any name gaps equals new desired capabilities and then I have to set the desired capability so I can say now I can use this variable caps so I will say caps thought set capabilities and I can give the capability name and value so this is a key value pair as we have already seen in the Android session so here I am just going to give the platform name as iOS so just copy this and I will increase the font also here so you can see it properly so these are the desired capability so this is what I am giving here the platform is iOS and then I have to give the platform version and the device name now here you can if you have a real Android real iOS device connected to your system you can get the name and the iOS version from there and for that we have already seen in the earlier session how to get all these details so the earlier session where we looked at how to set up is automation on Mac this is a prerequisite for this session so in the earlier session we have already learnt how to set up iOS automation on Mac OS and if you go down here we have the commands to get the devices so I will go to terminal and I will run this command which will show me all the devices which are present on my system this will show me all the real devices as well as all the simulators as well so you can see all these simulators are here and you can also see all this in Xcode as well so we have already seen this in the earlier session how to see that in Xcode and if you are having a real device you can use this command to get the details and this command I instruments as devices will give both that real device and the simulators so I will also add this here in this notes as well to get device ID we can use these commands so now here I can select any of this simulator so let us say I have this iPhone 8 + which is using iOS 11.4 so I'm just going to use this in my code here so let me just copy this from here so the device name is this iPhone 8 and the platform version is 11.4 and then now here you can see we have these new capabilities so I will show you both of these so in case you just want to open the browser like Safari you just have to say capability type browser name and Safari or in case you want to open some application or native app then you can say app and their location of the dot appr dot IP a file so I will show you both for now I will just show you how to do with the browser which is Safari and that's it and here now I will just have to open the appium server so now here we have two options if you are using the appium desktop like this you can open your IBM desktop and then start the server or you can if you are using a PM command line that you have got from npm you can just say IBM on your terminal and hit enter and this will start the appium server and by default it starts on port 4 7 2 3 so you see this is started this is areum started on four four seven two three so we have to give the same port here and this is what I'm going to use here and then finally I will say iOS driver driver equals new iOS driver and here I have to pass the URL so this is the URL that I am passing here and the capabilities which is gaps I will pass here and here I also have to import it so you are Ally will import from java.net I will import from java.net and this iOS driver I have to import from IO am Java client iOS so I will just use this I will save my project and here there is some errors let me just see what is this I will say capability type and yes this is working fine now and here it is saying that I have to either added throws declaration or surround with try-catch I will say add throws declaration and here also I will have to add the throws declaration and I will save my project so this is the IBM desktop client in case you are using IBM desktop you can start the server from here or in my case I have just used the command line or terminal version to start a team server so now this is done I can run and test my project so I will do a right click and say run as java application and let us see and if I go to my terminal where my IPM is running I should also see the commands here so yes this is working fine until now it should open the iOS iPhone 8 simulator and yes you can see this is getting open here so this should open and run the Safari application the Safari browser and you can see this is working fine as of now so simulators are a little slower than real devices if you use real devices it will be a little faster and this is the first time we are adding this application or this automation so this will take some time initially so do not worry if you are not getting any errors here on the appium server locks are on the console locks on your Eclipse this is fine it can take some time which is ok let us wait and meanwhile I will also open Xcode because the next step is I have to show you how to do it on a native application so yes this is working fine and this should now open Safari so this is fine until now and yes it is in connecting which is all fine and here there is some issue I think all the disease working fine until now there are no errors let us wait so this is working fine until now and yes this is it is installing yeah it's installing the driver agent that means it is able to work with automation on this system and this should now open the Safari browser and yes it is opening the browser and yes you can see the message let's browse here and you can see the message harris also let's browse that means everything is working fine so this is working fine I can also just put our message here completed successfully and you can see this is fine and the project is completed the test is completed now if you are working with a real application so for example let me open the webdriver agent reject that we created in the earlier session where we option on Mac OS and in this project we have a test app so if you see this is a integration app if I go to the project folder and I see under credit ups folder on the products folder we have this integration F dot app I can get its location I will say show in finder and this is the application I will copy this location and I will go to my notes and here I will just paste this and also the name of the file which is integration AB dot app so in case of iOS native application you will have a dot IPA file or a dot a PP file that you will mostly get from the dev team that you can just use and start the application and do automation in our case we have a dot a PP file that we have got from the sample that driveragent reject and I will just take this and now this is the I will put it in the desired capabilities so this is the desired capability for the app and I just have to give the location here so I will give the location of this integration AB dot a PP so this is the file and now I will save this and I will run my project again so I will do a right click run as java application and let us now see what happens so yes you can see the locks coming on the appium server and we already have our iPhone 8 started so let us see this should open the application the native application and yes you can see it has opened the native application and now we can also do any kind of testing with this application by adding our actions and we can also use the appium inspector like we have seen in the earlier session so if I go to the browser and just go to the online courses on my website automation step by step and go to IBM and here it will take you to the YouTube playlist and on this playlist I already have our video where we have learnt how to use the remm inspector so it should be here a PM desktop inspector this is the video where we can give the desired capabilities in a PM desktop inspector and then we can find the object locator so you can use this also we will have a video on a PM studio so you can also use the item studio to record your actions and then you can get the code from there so you will have that video in this playlist well while you are searching here you will have that video so this is how you can start and this is how you can start with a project on iOS automation in Java I hope the session was very useful for you if you have any doubts you can put it in the comment section below and I will try to help you as soon as I can and do subscribe to this channel to receive more videos on automation testing DevOps in CI and I will meet you in the next session thank you for watching
Info
Channel: Automation Step by Step
Views: 32,617
Rating: undefined out of 5
Keywords: ios mobile testing project in java, eclipse java appium ios testing project, ios mobile testing beginnner tutorials, ios java eclipse maven project
Id: eVfVacefiGo
Channel Id: undefined
Length: 20min 1sec (1201 seconds)
Published: Thu May 23 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.