Hello and welcome I'm Raghav And today we
will learn how to create a Java project on eclipse for iOS Automation And this will be
very easy and very interesting and I will go very basic step by step So we will set
up our Mac OS for iOS automation We will create an eclipse project and add dependencies and
we will add the code and desired capabilities for iOS Automation in our project set up the
device or set up the simulator and then we will start appium server Go and then run our
tests now here these two things set up Mac OS for iOS Automation and create an eclipse
project and add dependencies this I have already covered in the earlier session. So if you go to my website automation step
by step and go to online courses, and if you go to appium Course here, it will take you
to the Appium playlist on YouTube and here you will find all these earlier videos I will
also copy this link and make it available in the notes, so you can see setting up your
Mac OS for iOS Automation so you can see setting up your Mac OS for iOS Automation and all
these videos You will find it here so you can check that and this is the link that you
can go to and check all the videos and we have also created in our earlier session or
Eclipse project and we have added a added the maven dependency So this is an eclipse
Java Maven project and we have also added testNG now we will start to add the code in
our eclipse for iOS automation So if I go to my Eclipse here and I can show you this
is the project that we created So appium Demo project is the project we created earlier
and this is a maven project I created and if I go to Pom.XML Here I have added the dependencies
for appium Java client the selenium Java dependencies and test NG and testNG plug-in should already
be added to Eclipse all this we have learnt earlier And if I show you the SRC test Java
folder here in that test folder. We have created a base class enter test class
So in the base class, we had created the desired capabilities for Android and we have started
the driver here the appium server we have connected here And then in the test class
We have created a test to go to google.com and add automation Then a second test to add
raghav and then a third test for a log into an application So now I will go back to my
base class and here you can see all these capabilities are for Android now, we have
to create capabilities for iOS and for iOS you can get all these capabilities I will
just put it here And I will show you how exactly you can do this So now I am using the same
project and I will create sections for IOS and Android and in real world This is what
you will need to do Most of the times you will be using a same- the same project And
in the same project, you will be doing automation on Android as well as on iOS and just in case
you want to do specific on iOS and do not want Android You can always just delete or
comment out the Android capabilities and you can continue with iOS So what I'm going to
do is I will create a string variable called platform and I will give it some name For
example, I can say Android or iOS here and then I will say if I will put a if condition
if platform.equals ignore case Android so if it is equal to Android the platform in
equals to Android then use these capabilities and else if platform.equals ignore case Is
IOS then I will use These capabilities so I will just change this to iOS and now it
will go to it will skip this section and come here and here I can give the capabilities
for iOS device So here is what we have to give I can just copy the same command here
and I can just change it So this is caps dot set capability and here so this is because
I have already created caps here You can see desired capabilities caps new design capabilities
and now because this was outside the if/else block I can use caps here as well as here
So I will say caps.Set capability and a key and value So here I have to set the platform
named to iOS I will say platform name is IOS and if you go to Google and search for APM
desired capabilities it will take you to the appium.IO website and here is a very good
link So I can help you with that So here sorry for that noise disturbance So yes, you can
see appium desired capabilities and you can see all this here platform version that form
name device name etc.And when we want to do testing on a native app, we have to say app
and the path to the dot a PP or dot IP a file and here are all the general capabilities
Android only capabilities and if you scroll more down you will say iOS only so this is
something you can refer I will also copy this and give it here in references
So you can refer these links So I have added this and as we have learnt I can also say
set capability And instead of putting a key here I can refer it like capability type is
an interface and I can say platform name and the value is iOS, or I can also say caps dot
set capability mobile capability type and again, I will say value as iOS so anything
should work here This is .Platform name anything should work here and we have also seen this
in the Android session as well So for now I am just going to use the mobile capability
type and I'm seeing here The platform name is IOS And again, I will say caps.set capability
mobile capability type. I am pressing control space bar on my keyboard
for auto-completion and here I have to say that form version as well Now platform version
is will be your iOS version So here we have to give the platform version now at this moment. You can connect your mobile device your iOS
device to your Come through a cable and then you can get the details now in my case I am
going to use a simulator So if I go to simulator app And just in case you get any issues here
You can always check my video where I have explained on how to set up Automation IOS
automation on Mac OS all this I have shown their how to start simulated and everything. So here I have now so similar to app is open
if I go to hardware and go to devices I can see I can use so many simulators iPhone 10
iPhone SE 7 then Apple TV and apple watch as of now I have this I phone 10 and this
is iPad are both our already started. So let me just This so I am using iPhone 10
Now When you connect a real device, you will get a prompt on your device to trust the connection
You can always trust it and then you can go to your settings So if you go to your settings
And go to go to developer here You can see a developer option and make sure enable UI
automation is enabled and then you can also go to General about and here you will get
the name of your phone This is what we will use in the device name You can use the device
name as per your name and then you can see the version So here you can see this is 11.4
and the name is iPhone 10, which I am going to use So I will say that for version is 11.4
and then I will again say caps. set capability mobile capability type and I will say device
name and this is iPhone 10 I will say iPhone 10 and then now you can also give a UDID So
if you want to give the device ID, you can get that and for that you can use these commands
So these are the commands to get the device details or ID And I will also provide them
here So you can deploy this iOS deploy you can get through npm and then you can run this
command It will give you the device ID for a real device and you can also run this command
instruments mine is as devices on your terminal this will give you the details of all the
devices including real devices and simulators So if I run this command on my terminal It
will give me a detail of all the devices including simulators and ID as well so I can get the
idea from here So it will you can see all the devices are listed out and if I see iPhone
10, you can see this is the ID so I can give a udid like this although in case of simulators
You might not need it I have already given the device name So this should work fine and
I will just skip this you can all I will have this commands in the description Option so
you can refer it and then browser name so I will say so this time I am doing it on a
browser We will learn on a native app as well So set capability
And I will say mobile capability type.Browser name and here you can use any browser which
is available on your phone for now I'm just saying Safari So I want to run it on Safari
and that's it And here you have the URL that will connect to your appium server on 4723
port and here we have set driver new Appium driver and URL and capabilities here now here
you can also say a driver equals new Are you S driver and you can pass the URL and caps
and this should also work fine However, Appium driver will work both for Android and iOS,
so I will just remove this and I have also given manage timeouts implicit weight of 30
seconds And then the rest of the things are same as earlier and if I go to the tests you
can see we have these tests here in these earlier test I am going to Google and (do)
then our login test So let us see if this runs fine and before that I have to start
the appium server So we have already done this We have set up the device emulator now
going to start the appium server So I will go on my command and I will say appium In
case I want to start on some particular Port I can say --port and give the port number
and say enter or I will just say appium And enter to start on the default Port, which
is 4723 You can also do it from the Appium desktop client also, we are using the same
port 4723 So this is working fine I will go to tests do a right Click run as test in G
test and now let us see This should start When they should run the automation on our
iPhone 10 simulator, so yes, this is running fine It has opened Safari And let's just wait
if your simulator is not already open, it will take some time But because we have already
started the simulator It has now started our test It is going to the orange HRM and we'll
do the login And this is done and it has it is working
fine until now it looks like it is having some issue in finding the next element, but
that is fine It will be it for the implicit time out and then it should start the next
test And yes now it is going to Google And entered
Automation and raghav and yes, this is fine And if I go back you can see the console So
here there was one failure and one failure and then the rest of the three tests are done
If I go to the results of tests NG you can see there was one login test failure and these
are fine And if I now go and do a right click on my project and refresh and I'll say refresh
and if I now go to the test output folder you can see the reports here So I have index.HTML
and you can see all these reports So there was one failure and there were three pass
So all these details are there if I go to the email able report you can see all the
details here as well And this is running fine So this is how you can Create dependencies
for iOS Automation and you can run your tests on iOS device I hope this session was very
useful for you And if you have any doubts, you can put in the comment section below. But before you do that always try to troubleshoot
yourself, put your doubt or copy or error statement and go to Google and try to search
on your own and then if you are having some issue, which you are not able to resolve you
can always let me know and I will meet you in the next session Thank you for watching.