What's up, guys, this is all and today we will continue with our APM Test Automation Framework Design
Process.
OK, so let me pull up the framework goals.
So in the last video, we looked at the alternate design without using the Jawa inheritance concept
and then evaluated the pros and cons of using the alternate design.
Then reimplemented, the exception handling using the Tricare option as well as drug testing is another
option.
I also explained why Pettengill is not should be the preferred option as compared to the track at.
Then we added an abstraction layer for our test data using the Jesson file, and then we added another
abstraction layer for our static text using the XML file.
OK, so in this video, we will update our automation to support the Irish platform, until now, we
were automating only for Android, but going forward, we will start supporting Iris as well.
Usually whenever an app is developed, it is developed for both the platforms, Android and iOS.
Most of the time, the app design and the app functionality is the same across the platforms.
So it is very important to have an automation framework that supports what the platforms by using the
same codebase.
And this is where APM helps us to achieve to that it provides a common API which we can use for both
the platforms.
We will then add another test class and automate Capalaba DISCUSES.
This way, we will see how we can execute multiple test classes using the same driver, for instance,
this way.
We will also get to know how we can leverage the page object model design to add a more test classes.
We will also see how we can define the UI elements, which are common across pages.
So let me open our simple application.
OK, so now observe this particular part in the application.
So this is the top bar, so this part of the application is common to multiple pages.
So it has the logo, the brand name, the card icon and the settings icon.
So if I click on it, it opens another page.
And from this page I can perform various operations like logo.
I can go to the about section.
So basically, how do you define the elements for this particular part?
Because you need to make sure that the other elements are defined only once.
So you when you finally get to some other page, for example, if I go to the product details page,
the elements on this part of the page remains same.
So let me add this to the card and then go to the card.
And I can still see the same elements if I take out and go to this particular page, then again, I
see the same element.
So if we do find these elements for each of these page, for example, the checkout page, article page.
RZA Products page, then basically we are defining these elements multiple times, so we need to avoid
that.
So in this video, I will explain how to avoid that using the page object model design.
Then we will have a look at how we can recover from failure so that our next desk is executed successfully.
For example, you fired three test cases and my second test case fails.
Then I need to make sure that for my third test case, the application is in clean state and my third
test case can start from there and execute successfully.
So this way, my test cases will be independent of each other and I will be sure that the application
will be in clean state before my test case starts executing.
Then in the end, we will also see how we can scroll using EPM so they will do this for both Android
and iOS.
OK, so let us begin let us get back to Eclipse.
So before we proceed, we need to do a couple of changes, so if you on this program, it might happen
that the AP model might be null.
This could be because the app is not at the root folder.
That is, it is not under the resources folder.
We have a folder called App and we are copied the insoluble in this folder.
So it's a relative path and we are defined this part in the config properties file like this.
We can quickly check this by executing the program.
So let me bring to the AP, Warren.
So the AP, Worrill.
Is.
Have you ordered.
And then quickly on this program.
OK, and as you can see, the approval is not.
I realized about this issue after the last video, so basically we need to correct this and the way
to correct this is to not use the GED class method.
So what we will do is instead of defining it as a Eurail, we will define it as a string like this.
Happy warrior, equal to get class.
Not likely to get resource material like this get.
Get resource.
And then we will read the file part from the properties file, so I will copy this.
And paste it over here and then I will say dot file, get fined.
Like this, so let me comment on this and a little later on the program note.
OK, so this time the approval is not null because now it is able to rewrite the part.
OK, so this issue will not occur with the conflict or properties, because we are defending it at the
root location and we are treating it as a get a resource stream.
Similarly for things, TotEx email, even though it is under the relative path, that is even though
it is under the strings folder, we will not have the issue because we are using this method, which
is get a resource stream and it works just fine.
But in case of the application file location, since you are defending it in the conflict conflict DOT
properties, and since we are using the get resource method, we are having this particular issue.
So the only thing we changed is we are not using the get glassell order method and we are defending
the IP as string instead of the usual.
OK, and the other minor change that we need to do is in the logging test class or the before class
method, we are catching the exception, but we are not throwing it again.
So we need to do that, because if we don't do that, then what will happen is even if there is an exception
in the before class method, since we are getting it tested, you will think that it is successful and
it will continue with the test cases.
So we need to avoid that.
So I will just type through exception.
So this way, the exception will be thrown.
OK, so the sample application, which we are using in our automation.
We are downloaded it for Android, but now we need it for us also.
So in order to build it for us, we have two options.
We can build it for the real device or we can build it for the simulator, but for building it for the
real device, we will need to do the courtsiding and the provisioning profile for which we need to have
a paired account with Apple.
In order to build for the simulator, we don't need to do the or the signing process, so we will go
for this option.
So let me open the gate up page for this simple application.
So this is the Gateway page for our sample application and the instructions are in the README file.
So we need to follow these steps in order to build the application for this simulator.
There are a couple of more steps that we need to do.
So I noted on those as well.
Let me open that.
OK, so these are the steps that we need to perform.
We already performed the first four steps, so we will start with the fifth one, that is.
Install yard before that, let us download the project.
So I will click on this button.
And then I will download it as a dip, let us go to the downloads folder.
OK, so this is the project that is downloaded.
Now, let us open the terminal and get these commands executed one by one.
So I will pay Brou.
You stole.
Yeah.
I think the army is an alternative, which you can use to build the applications.
OK, so now we need to install a watchman, so let us type through.
Install.
Watch money.
I don't know what is this?
OK, so now we need to install the react to CLIA, so I will just copy this command.
And then Mr. Doria.
OK, now we need to install cocoa ports, so let us copy this and then paste it over here.
OK, now we need to install port, so let us type guard install.
OK, we need to execute this command from the project directly, so let us go to the project directly.
OK, and now let us execute the command.
Part install.
OK, I think what we need to do is.
We need to execute it from this particular directorate for Iris.
So let us go there and then execute the command.
OK, looks like there is some issue, let us install the cocoa pods again.
And then we will execute.
Part in it.
So it looks like there is an existing pot file in the directory, so let us try to execute or install
again.
I think they should be fine, so let us try it out, let us move on to the next step, that is, let
us execute this command.
John in St..
OK, so in order to build the project, we can either use this command or we can use this command,
so let us try with this particular command and see whether it builds the project successfully.
So I will type.
Dash nitu.
Ram dash, I wish.
OK, I think before we execute the commander, we need to go back to the root folder.
And then we will execute the command again.
So it is launching the iPhone X from the simulator and then it will try to install the application as
well.
Okay, so looks like the bill failed.
So it is saying that we need to run the party, install command, so let us do that now.
OK, this is interesting, so let us go to the IRS folder again.
And then execute the command.
OK, it is working now.
OK, so it looks like we are supposed to execute it after the buildings failed, which is kind of interesting.
Anyways, let us try to build the project again.
So we need to execute direct Netto command.
OK, now, again, we need to go to the root folder.
Which is this one?
The president, the commander now.
So hopefully it should work now.
This might take some time.
OK, so the app is installed successfully.
But we need the intolerable.
And the Taliban will be under this particular folder, so we will copy the AP file and then we will
put it in our automation project.
So I will go to the IRS folder.
Then the bill folder, then the folder, then the bill folder again, then the product folder.
OK, so we do not have the release folder.
We only know that the folder.
So I think we will have to execute this command as well, which will build the application for the simulator,
so let us execute this command.
So let us close this.
And then type.
Yeah, I always got some that bill.
OK.
So I think this is completed and the release folder is also created, so let us open it.
OK, so now we have the tolerable and we can now in our automation project.
OK.
Looks like it's still going on, so let's us it for a minute.
OK, now I think it is completed, so now we can copy Dunstall.
So let us compete under the app for the.
OK, finally, we are the most vulnerable and now we can do the changes in the automation to support
the iris platform.
OK, so let us now go to the conflict properties file.
And then we will add the global parameters for the IOC platform.
First, we will add the automation name.
That is.
Iooss Automation.
Name.
Equal to.
Excuse me, test, this is for Iris and then Iris Bundall I.D., which is the unique idea for the IRS
application.
Equal to.
So we need to get the penalty for our sample application, so for this, let us go to the project route
folder.
Or you can just expand our doorstep profile in our project.
And then open the info file, which will deepen the clarity of the application.
So this is the the lady, so let us copy it.
And then it over here.
OK, then we need to add the application, so I will type ileus app location equal to.
Slash Happe.
And the acronym is.
This one.
So I will type Swack.
Labs.
Mobile.
I got a puppy that said.
So now let's go to the best test class.
So, yeah, we need to initialize the driver for Iris.
So that we will do best on the platform name.
OK, so we will create a switch gears block like this.
Switch.
Based on the platform name.
And we will get the platform name from detesting file.
So these capabilities that form name platform Vergennes and the device name, these are coming from
the test and you.
So we don't have to put those in the switch statement.
OK, so I will type guess.
And right.
Colin.
And then I will copy this entire court to block.
Over here.
Let us remove this.
Let are the break statement.
Now, the another case for Iris.
And then we will copy paste the same code block.
Or what here?
OK, so now we will change the automation name to Iris Automation name.
We don't need the aid package and activity, so we will just remove those.
The application will be Ierace application.
We can change this to Android app Warrell.
And this one, too, I was happy all.
For the memorial, we will defend this.
Here.
And then we will remove this like this.
We can offer you us, the driver should be Ierace driver solitaires gingered.
So let's turn to Capital Irish driver.
And now we don't need this particular court to block senators the latest.
OK.
We need to put a brake statement over here.
And then we will add another case.
Which is basically the default guess.
And then we will throw an exception here, if the platform name is in either of Android, not Irish.
And we will say invalid platform.
And the platform.
Name.
So this way, if we mistakenly provide any value other than Iris or Android, we will get an exception.
Look at that.
Let us now update the test in Jacksonville and run this program for our Earth simulator.
So the platform name will be Ierace.
Platform one will be.
13 dot three, and the duration will be ifone 11.
Let us know if you could program.
So it has launched this simulator.
So it takes some time to launch this simulator and install the app, and it might happen that the program
will fail in the first attempt.
In that case, do not worry, just execute the program and then see what happens.
OK, so the app is installed and launched successfully.
But the test cases will fail, which is expected because we are not that different development for Irish.
So as you can see, we are errors that indicate that it is not able to find your element.
OK, so let us load the application in the inspector and then let us inspect the elements and find those
in our project.
So I already saw the capabilities that are required to launch this application on Earth.
I will just open it.
Yet I argue the point lady instead of the happy.
Because my application is already installed and I just need to launch it, okay, so I will start the
session.
OK, so let us inspect the elements now.
So far, username, I will use the accessibility.
Let me open the login page, page, object, model file.
OK, now we will use.
At the rate I was excuse me, be fined by.
And for Iris, we need to use the Idy instead of accessability, so I will type Heidi equal to.
Test username.
OK, let us import this glass.
OK, so not one important point that if you're using your client, which is below seven dot jero, then
you need to use Ateret I always find by it.
But if you're using our client, which is seven Dot, Jiro and Abbo, then you need to use Aderet Iris
executer to find a by.
OK, now let us find the other element.
So I will just copy this.
OK, so for password.
We need to use this one.
So I will just copy pasted.
For logging.
We need to use this one.
And for their text, we will need to read it first by entering the unvalued username.
So let us do that.
No tap on the login button.
OK, we got the.
OK, so for the error, we cannot use this expert.
Because it has the static text that we need to validate if we use this and say that static text is different
than they expected text, then instead of throwing a assertion, the automation will throw an exception.
Which is not a good way.
So we should avoid using this static text to find the ultimate.
So let us try to build the custom expert.
So this looks like the parent element, so let us copy it.
And then pasted over here.
Let us to look at our strategy to expand.
And then we will tape slash child Colin Colon.
And this is the class for our element, so we will use it.
We will talk over.
Dishware.
So now let us search this element.
OK, so it formed our element so we can use this expert.
So I will say XPath equal to.
And we will start over here.
That's it for the login page.
So now let us move on to the perhaps page before that.
Observed that to get the right text, we are using the get attribute method and we are sending the attributes
text.
So this will work for Android, but for us, there is no text attribute to.
There is.
Labeler tribute.
So we need to use global.
But our great attribute method doesn't support labor.
So let us go there.
OK, so we are two options to handle this, one way is to handle this in the respective page.
That is the login page.
So what we need to do is we need to use the platform name.
And based on the platform name, we can either send text or label to this method and it will just work
fine.
But then we will have to do this and link whatever it is required in the front pages.
The other option is to handle this in the best test class itself so that we don't have to handle anything
in the pages.
OK, so instead of get a tribute method, we used to get text Matara.
So I will take public.
Strain get text.
Mobile element E!
OK, before that, we need to define the platform name at the class level so that it is available for
this method.
So let us define it, protected static
platform.
As a string.
OK, I understand the value.
Here in this matter platform, equal to.
Platform name, which we will get from the examiner.
OK.
I hear we can use the switch statement.
And then at the guess, is that this case.
Android.
Colin.
So in case of Android, we will use the great attribute method.
So in case of Android, that reboot is text.
So we need to return it to.
And then for Iris.
Return, get a tribute.
For our viewers, that report is level and then we will return the null value.
Like this, and now we need to use the get taxed method in the log in page class, so I will change
this to get taxed.
And then I will remove this argument.
That's it.
Now, let's move on to the product page.
So here we are, only one element.
That is the product title, so let us find it.
It does with the in.
On the simulator directly.
Now, let us refresh this, India inspector.
Yet again, we cannot use this expert because it has the static text, so let us build a custom expert.
OK, so this is the element that we need to find.
OK, so we can use this element to find our element, so let us copy this.
And the door, yeah.
Let us first find the pattern of this element.
So we will just see parent Alan Colon start one and then.
What element is a sibling for this element?
So we will type preceding.
Dash sibling Kalanchoe Lone Star.
One, OK.
So let us find this element.
OK, so it formed our element so we can use this.
So let us type.
Ateret Iowas.
EXI you may be fined by.
Export equal to.
And then posted over here.
40 plus.
OK, now, instead of that attribute, we need to use the get taxed method, so let us change it to.
That's it.
So both of our pages are updated and we don't really have to update anything in our test class because
the functionality of this application is the same on Android and Iris.
Before we execute this, let us go back to the best test class.
And then let us comment on this, because, no, we don't want to install the app again since it is
already installed, but to launch an already installed app, we need to use the already.
So let us use that.
So let us use the Pantelleria capability.
Again, the value is.
This one.
Let us know exactly program.
OK, so the app is launched.
First, let's get started.
But it will fail, and this is because.
It is not able to find keyboarder.
Because the simulator is using the keyboard from my Mac.
So PM should be able to open the keyboard in order to send the kids.
So they think Ebola is not present.
So what we need to do is.
We need to go to the hardware man option, then we need to go to keyboard and then and check this option.
If you inject this option, it will not use the keyboard from the Mac.
It will show the keyboard within this simulator.
So let us check this.
And then later in the program.
Now see the magic.
OK, so now the keyboard is launched and it is able to send the kids.
OK, how bizarre that it is not clearing the previous entry.
So that is why two of our test cases will fail.
So these kind of differences will be there between Android and I always, and we will have to handle
those in the automation.
So let us go back to the log in page.
OK, we will need a common metaphor, so let us go to the best test class.
And create a method.
For clearing the field.
Like this.
And let us use it in the login page before we send the username.
So I will type clear username TextField.
Let us do for the password frilled as well.
Also right now, what we're doing and looking for one platform.
Always make sure that there is no impact on the other platform, for example, yet in case of us, we
are clearing the field before sending the case, but this is not required for Android.
But even if we cleared the field for Android, there will be no harm.
But keep this in mind.
If you are doing some Adara handling, that might impact on the other platform.
OK, let us know here on the program.
Notice that the test case execution on the simulator is very slow.
I do not observe this slowness when I execute on the real device.
OK, so all our discuses past.
Let us take the test and the results.
OK, so since we made the changes for Iris, we need to make sure that our test cases works for Android
as well.
So let us execute this on our real Android device.
So let us update this back to Android.
Platform, Magento, not Jairo.
And directing them to excel, to excel for and we can do any device name, let me measure the device.
Let us note on the program.
And then confirm all our test cases are working fine.
OK, all the test cases past.
OK, so now say, if you don't have a real Android device and if you want to execute this on an emulator,
you can do that as well.
So what we'll do is we will add one more parameter.
Similar to.
And the value can be true or false.
So we will set it to probe and then we will change the platform Vergennes to the U.S. version of my
emulator device, which is standard zero and the emulator device name, which is Pixel underscore to
now we will collect this emulator parameter in our best test class.
So I will add one more parameter here, emulator.
And then I will add it as an argument string emulator.
And then.
We know this everyday capability.
So using this, we can launch the every day event if it is not started, so let us uncommented this.
And we need to provide the equity name over here, OK?
So we need to have the if condition, that is if.
My devices and emulator, that is you, Muleta.
He calls.
Through.
Then I need to use this capability.
And then here I will provide the device him.
OK, so this way, if my device is an emulator.
Then I will be using the everyday capability to start my emulator automatically, and if my device is
not the emulator.
That is, if this is false, then I don't have to use this capability because then it is.
It really is.
So let us know.
Execute this.
OK, so it has launched The Muleta, so not that we did not start it manually before executing the program.
So APM is doing it for us automatically.
OK, so the test case is executed successfully on demilitarise.
OK, now say, if the platform was done on my emulator and on my real device is same, then there will
be conflict.
It will not be able to launch the device.
So in that case, we can use utility capability for the real device instead of using the platform.
So that way it will identify the real device using the Udairi capability and it will identify the simulator.
It was in the platform for that capability.
So let us out on more parameter.
You did.
And the value will be let us launch the terminal.
And execute Adibi devices.
This is the udairi of the real device, so let us copied and pasted over here.
Now we need to collect this parameter.
Like this.
And then.
In the yellow block.
We will say.
Use the utility capability.
For their elderlies.
OK, and we need to move the platform Vergennes from here.
Two, yeah.
We don't need Platform Virgin for the railways, we need it only for the military, and then we will
need it for our viewers as well.
So let us a little over here as we.
For our viewers as well, we can do this kind of handling between the simulator and the reality is.
But since I don't have the app built for the real device, I will skip it for now.
OK, let us note on this for the real device, so let us set this to false.
And then run the program.
So notice that I'm not changing the platform where John 932.
OK.
So all over discuses past.
So now our automation supports Android emulator, Android real device, as well as wireless simulator,
and with this small change, we can support it for our shareholders as we.
OK.
So it is we are done with the multiple platform support.
Unfortunately, the other three calls we cannot cover in this video because of time constraint.
We will look into this in our next video so that we can get sufficient time to understand and implement
this.
Thanks for watching this video.