hey everyone welcome back so in the last video we saw how we just kicked off the script
and we made communication with the rpm server as well as the android emulator so in this video what
we're going to do is just simply add a new contact and we're just going to do this very
caption element ids and xpath so what we're going to do is pretty much you're going to
click on this add new contact button and then you're going to get this prompt what you want
to do is just simply hit cancel and then once we get on this page what we're going to do is just
enter our first name last name and phone number and then simply save so let's hop into it
let's start the session
all right so let's start capturing some more elements that we're going to need to interact
with so the first one is going to be the floating button so this is this resource and we can use
define by id or expat and we have the two selectors on the values we can use for that
i'm going to be using the id the expat is very long you can use on both but when it comes to
readability it's way too long so we're just going to stick to the nice and easy id and expats are
not really reliable if something were to move object move things could could shift that object
and then the x-pac would be like broken so having a safe and reliable id is always good practice so
first thing we're going to do is let's call this button so you can call this web element
i'm going to call this add contact button is equal to driver dot fine
element and we can do by any of these so we have by this is gonna use the selenium
um library we could also use any of the css custom id image link name what we're gonna be
using is id and we're going to paste that id so go to your inspector you're going to copy command c
and we're going to paste that right there add your semicolon to the end
and then make sure you import this the selenium web web element
all right so now that's there what we want to do is just simply click so we're going to copy the
button and you can do that there's a click action so you say dot click and it's going to click it
all right i always go to add comments so what i'm going to do is add a comment and just call this
add a new contact button
all right so now we can do a quick test to make sure that
that's happening so you can do run run as a java application
and remember since i ran it as a java application i can no longer just refresh it
that session no longer registers with the inspector so you just have to click the
quit session um and then start it back up so i'm just gonna go step by step all right so now what
we need to do is capture this cancel this cancel button so now we're gonna do is just hit refresh
on the inspector we can see this element as well as any of these elements is here
so we have the cancel button so let's let's put that here we can copy this
and paste it as well
and let's call this button click kens click cancel button
so now we're telling it to click the cancel button so what we're
going to do is change the name hit cancel button
and cancel button that click also what's a good practice is every time that you click a button
that makes you switch to another screen you should add some type of weight or make sure the element
is available before you try to interact with it so add some weights
and what type of weights i like to use i like to use this way color web driver
weight so that's what we're going to set up and you know i'm going to set this up
at the top right after my driver so i can set i'm just going to type web driver weight
i'm going to kind of wait equal new web driver wait and what we need to add oh
what we need to add is the driver and the time so let's do 20 seconds
so web driver wait equal new web driver wait and let's close that up import just clean up my syntax
sorry about that there we go so now we have our weight element so what we're going to do is say
after we click the add contact button wait for either this text or this cancel button to display
before you try to click it so in order to do that we're just going to say wait we're going to put
it right here wait until and there's a function and the function is called expected condition
that presence of element by locator
and in this case by we're going to say id so we're just going to grab
let's grab the id of the cancel button
so just simply copy that and we're going to paste that id and we're going to
add our semicolon which is nice so add the contact button we're going to add some wait so wait until
the cancel button displays once it's displaced we're going to
initialize or set that variable and then we're going to click on it looks good so far all right
next we want to do is once we click this so let's click that button good and let's refresh
perfect so now we're just going to copy these objects these elements and we're going to
interact with them into our first name last name phone number click the save button and we're done
so what i'm going to do is just copy this a couple times well this once
so now we're going to say
click and enter
data for first name
okay so we're going to call this first name and i like to tell it what type of elements edit box
all right make sure take out this old element and we're going to do a search
so in this case it seems that we have to use the xpath which is a good example to use
so what we have to do is just copy this long string command c and instead of by id we can do x
path and then we paste
long expats so now we have oh what i will do our element set so click and
enter data on the first name so what we did is just going to click on it and now
we have to enter data in order to enter data you can do send keys
and the send keys in this case i'm just going to say j
um jamal's already taken i'm just going to copy this because we're going to do the same thing for
the last name so let's call this last name edit box copy that same thing
click and then send you're going to say last name rich and let's take this long
and i think this case it's just a two so it's the same thing but in this case it's two so let's
enter the two click save so now we're going to enter first name
last name and the last thing we have to do is a phone number so let's oh man i hate those
x passes so long but let's copy that one more time and bring it in
all right so we're just going to call this phone num
edit box and change everything here so phone number edit box and just remove this long expat
i don't think this one is like a three
it's grouped differently so let's see all right so if i'm here now we
can see it's definitely different note three so copy and just paste
all right so done so all we have now is to click the c button in this case what's the number
number is going to be one two three four five five five nine eight seven six
give me a call alright so change the comment from these first names
click and enter data for phone number and enter data for last name
and last but not least is to click on the save button so i'm just copying a
piece and you're going to do a lot of that when you're developing and this is going to be save
button copy paste click and to get the save button oval nice this one has an id perfect
copy find element by id xpath x5 expand okay good and this one is the id paste and click save
so far let's see what we have so we have click add to contact add a new contact button we add a
weight because then we change to that page um we click the cancel button so we should add a week
because we switched to another page so copy this and what element can we find let's see let's do
let's see what i can use something that has
yeah let's say account name so i'm gonna go back and with my weight right here
okay so now we're gonna wait for that to appear once that update you're gonna click first name
enter j click last name enter rich into phone number we're gonna click the save button
and let's see what happens after that that's a good this is a good time to run a test
and just click run run java application
nice so we see we have a error
it didn't like something could not locate an error so let's see what it didn't like
so i'm saying click add some wait wait for the left button i'm telling it to click on
the float oh well yep that's not that's not good need to click the cancel button
see just what happens when you copy and paste stuff like that happens
but as long as you know how to fix it it's good so let's clear this and let's re retest that
there we go now let's enter in j enter in rich enter in the phone number and wow and
it's saved jay rich save boom test complete so that's a quick way how you can get started with
with appian inside of java and right now quick script sometimes as you can see that
the keyboard was propped um sometimes you may not want to have the keyboard open while you're
running your tests so there's some way we can avoid it so i'm just going to add that quick
capability to this so you can see so let's say hide keyboard show you how it is when it's hidden
so all we got to do is pretty much copy like this type of setup
and what i need to type is we're going to type
is unicode keyboard so uni code keyboard and this is going to be true
we can copy this because we have to do one more and this one is going to be called reset keyboard
and that's going to be true
all right so make sure you don't have that contact save still it is safe so let's just delete that
because it's going to interfere with the script you don't have no logic to
handle anything that pops up unexpectedly so
just going to remove that and we're going to run a test to show you how it looks without the keyboard
so now you can see it's just running the red phone number no keyboard popping up
and it's save working flawlessly just as we expected on
so now that's pretty much it the last thing i wanted to show you is just going to hit
this back button how you navigate using some of the native native buttons head
back you're going to see two of the items in the list and i'm just going to use the quit
so the web driver can be closed and terminated successfully and that will wrap up the script i
will wrap up our testing so let's just delete using junit as your your test tool right now
we're just using simple java but if i want to let's say remove static because java don't like
j unit don't like static and i add the annotation.test
i click save let's import that test from junit
go into your main void make sure that's commented okay just gonna run directly from
the test and if everything goes well we should see junit test
and we have rpm tests here running so that's that's pretty good and if it fail you're going to
see a big red failure if it passed you're going to see a green and here we could just add different
like assertions so if something were to be true we can write you know jamal first name enter
true you know that person that was able to get to that element and able to send text you can write
as are true i start false any type of other logic but i can show you guys more details about junit
and testing with junit and different assertions but in this video just wanted to make sure you can
get started with your first rpm script and having all the tools you need if this video definitely
was helpful please smash that like button continue to show support subscribe to the channel if you
haven't already and i'll see you guys in another video if you have any questions or have any issues
please feel free to drop them in the comments and i'll see you in another video good night
you