what up everyone welcome back to the channel Jahmal here and in today's video we're going to continue
our apm series so in this video you're going to learn to use appian within java inside of
eclipse ide that i'm going to be using today and run your very first mobile automation script so
let's hop into it so the first thing i'm going to do is open up my launchpad and search for eclipse
that's my ide of choice that's going to go into my youtube section
all right so i have an old project up so what we're going to do is go to the top and
file you're going to go to new click other and what we're going to do is a new maven project
click next click the check box that says create a simple project use a default workspace location
that looks good and click next for your group id i'm just going to call this rpm demo
and you're going to use the same group id for your artifact id so rpm demo
all right so now that we have that that looks good and what we're going to do is just click finish
now we have our rpm demo project right here and what we're going to do is hop over to the poem xml
file and what we're going to do is go to maven repository and bring back some of the artifacts
that we're going to be using all the dependencies such as j unit selenium and appium those are the
three dependencies i'm going to be using i'm just going to hop over to google open up my
savari google type in maven repository and we're going to click the very first link so within maven
repository you're going to get the search bar and the first one we're going to search for is appium
we got the java client so this is what we need and we're going to download i like taking the
one that's stable so 7.3 and popular so this one's pretty good what you're going to do is just copy
this and within your poem dot file before you can paste that dependency in there you're going
to open up a new line or enter a new line and you're going to open up with the dependency tag so
dependencies so it's going to be plural close it and now we can put our dependency in here so
each and each dependency is going to go in here so just paste and we have our rpm java client
we are version 7.30 so i'm going to hop back over to maven i'm going to look for
selenium java
there we go selenium java again i'm going to use this one the one with the most usage
and we can just copy and paste so we have a little appium client we have our java
the next one we're going to use is junit it's not a must but it's it's a nice to have oh got the g
here we go so j unit as we can see there's some vulnerabilities out there currently right now
so let's go to this one this one seems pretty stable and what we're going to do
is just paste this into a form file as well and to make your format looking a little better
you can do command a and then click command shift f so that should make your indentation
in your formatting a little better and we're going to click save so now if you look over
here to the left you see the maven dependencies so all of these jaws are being brought back from
the poem file and that's exactly what we want to see next what i want to do is make sure that these
that these dependencies are installed so what i'm going to do is just go to run run as maven install
let's see what happens
okay so we can see the bill succeed and this will just happen just scan the project
it did its thing and it's finished so we know that maven is set up right
and the last thing i want to do is just update the project so may even update the project
click okay
oh the gre system library so they say we're running j2se15 but i like to run java 1.8 so
if i go down you can see java sc 1.8 you can click apply and close and then this
is going to look like that um so if i go to maven update the project sometimes it revert
so you see it reverted right back to the 1.5 so in order to fix that we have to add our
properties and we normally add it right after the version so i have a piece of that i can copy
so i'm going to go to my notes and i'm going to copy this little piece of property
i'm just going to paste this here so now
let's do our formatting com command a then command shift f and then we're going to
save that so this is our property so we have the source 1.8 1.8 um our compiler
and this is what we need in order to keep the gre system set so now if i go back into appium and i
go to maven update the project and click ok it's now pointing to the 1.8 which is perfect all right
enough of that all right so now that we have our phone file and maven everything set up
what we're going to do is go into test java and we're going to create a new package
so you can call to a package you can call it com dot i'm just going to say appium appium test
click finish and within this we can do a new class i'm going to call it um appium
demo and what i would like to do is enable i'll bring in the public static void main
i'm going to bring in that method that method
all right so everything looks good now it's time to write our script so the first thing
i want to do is initialize my driver so in order to do that what i'm going to do is
say public static and this is going to be a rpm driver
rpm driver and you have to add this mobile element tag to it and we're going to name this driver
so now all we have to do is import these dependencies to clear up some of these little
red squigglies or errors click save and now we have our driver initialize
all right so what i'm going to do is just create a test method so
i'm going to just say public void in this case we have to be static
static void and what i'm going to name it is going to call it rpm test one
all right save that so what we're going to do inside this method is create our
capabilities create and launch the driver so we can get to our contacts page so that's
essentially what that's going to do so we're going to set up our desired capabilities right now
so in order to do that what we're going to do is type desired key abilities
some people like to call it cap so that's the variable name i'm going to give it
and it's going to be equal to new
desired capabilities
make sure i didn't make any mistakes in my spelling okay that looks good and everything in
perfect so now we have that object so what we're going to do is say caps dot set capability
and we're just going to give it the capability name and the string value so we're just going
to be using this method so in order to find the capability name if you hop over to our apm server
inspector excuse me make sure that you have it launched so we can take a look at all what
desire capabilities that we set earlier and since i'm here let's start the service so start up your
server keep it running and let's hop back here so we're just going to copy these platform name
that's just the capability name that we're going to be using
and you're going to paste this in a string and the value for this is android so let's enter android
and we're just going to copy and paste this for the rest of them so i'm just copy
speed things up a little bit so i'm going to need a platform name i'm going to need
a version i'm going to need automation app package and app activity so we can do
flat form
platform version i'm just going to copy and paste this just for time sake
device name pixel 4
there is another capability that's called ud id
sometime that may be needed i can show you how to get that um
pretty much it's like udid in order to get that where that value you normally go into let's say
you go open your terminal and do adb devices it's going to tell you all your devices that's
connected and this one this is going to be the udi so if you have a real device you do the same thing
it's going to bring up that udi for you ud id you can just paste that in here
that's something i didn't show in another video but i figured it's a good time to
show it now um you can use either one device name or uid you a d id you don't have to use
both just add a quick comment to that for now next we're going to add is the automation name
and i need to copy this two more times for my package and for my activity so you're gonna do
rpm app package
and
i think you can keep the prefix as well the prefix shouldn't bother the script but just
like the code nice and clean so let me update these two values so com dot android contacts
and then this is the com android contacts activities people activity
a mouthful all right boom so that looks good so we have our desired capabilities that's
almost half the battle next we want to now fired up the mobile app so it can go to the
contacts page and what we need to do right now is a url url is equal to um new url
and we can just paste whatever that url is so it's just going to be a combination of the
remote host the port as well as the remote path to set that up let's let's bring in
these dependencies so that looks good new url and we're going to surround this with a try and catch
give us some space all right so the url in this case is going to be http
colon forward slash and we're going to enter the host 127.0.0.1
we're gonna add a colon for our port4723
and we're going to add the remote path so slash wd slash hub and we're going to enter one more slash
and yep that looks that looks good so now that we have our url what we're going to do
is now tell the driver to hey let's interact with this url let's fire
up and talk to the server all right so what we're going to do is say driver equal new rpm driver
so what that's going to be is we're going to put the url
so the url that we're going to be using as well as the caps
all right so now just need to add the argument and the argument it's missing is mobile element
alright so we say driver equal new rpm driver mobile element and missing our parentheses url
you add your karma caps all right so what we want to do to make sure that this is working we
can do a quick test so what we're going to do is just add this method and our main class
so something like that and you're going to right click and make sure your rpm solver
is running make sure you have your emulator up and loaded and we are going to do a quick test
to make sure that it can get to the contacts page so we got some interaction over here on the server
all right so the app loaded to the contacts page and we still have
um the contact jamal richard that we created in our previous video all right so i'm going to end
it right here for the day so in the next video i'm going to show you how you can create a new contact
you're just going to click some of these buttons like cancel and
enter our first name last name and the phone number via automation so if you guys want
to see that in the next video please like and subscribe and i'll see you in the other video