WEBVTT

00:00:00.000 --> 00:00:02.790
>> There's no restart on
my timer so I know where I'm at.

00:00:02.790 --> 00:00:06.030
Hello, everyone. Good afternoon.

00:00:06.030 --> 00:00:10.170
How's lunch? Everyone enjoyed
this giant pickles? I know I did.

00:00:10.170 --> 00:00:12.315
Yeah, awesome.

00:00:12.315 --> 00:00:17.565
So this session is
about U(I) Testing,

00:00:17.565 --> 00:00:19.935
therefore, do you U(I) test?

00:00:19.935 --> 00:00:22.950
So before I start, this is
my favorite question in the world.

00:00:22.950 --> 00:00:24.705
This is easy one.

00:00:24.705 --> 00:00:29.175
How many people write
tests? Show of hands.

00:00:29.175 --> 00:00:31.830
Everyone on the stream,
that's quite a few hands.

00:00:31.830 --> 00:00:34.305
I'm surprised, I'm very happy.

00:00:34.305 --> 00:00:38.290
Now, how many of you U(I) test?

00:00:39.130 --> 00:00:41.705
Not bad, that's awesome.

00:00:41.705 --> 00:00:44.060
Well, so this session is basically,

00:00:44.060 --> 00:00:48.635
and so I'm not going to be doing
the basics of how U(I) test work,

00:00:48.635 --> 00:00:51.350
there's bunch of good content
out there already for that.

00:00:51.350 --> 00:00:54.185
It's super simple, it's
examine U(I) test.

00:00:54.185 --> 00:00:56.735
The framework I'll be
talking about today is

00:00:56.735 --> 00:00:58.070
literally just made for

00:00:58.070 --> 00:01:00.740
making U(I) test super
simple and super great.

00:01:00.740 --> 00:01:04.820
So what we're talking about today
is best practices and how to

00:01:04.820 --> 00:01:08.000
write something that
was talked about a lot

00:01:08.000 --> 00:01:11.195
in the Keynote today,
cross-platform U(I) test.

00:01:11.195 --> 00:01:14.435
So who am I?

00:01:14.435 --> 00:01:16.220
I'm pretty sure no one knows me.

00:01:16.220 --> 00:01:19.715
I'm not as famous as
much, but I'm Sweeky.

00:01:19.715 --> 00:01:24.250
I work in what we call the
DevOps Customer Advisory Team,

00:01:24.250 --> 00:01:25.950
and I'm in the subset that's called

00:01:25.950 --> 00:01:28.570
the Mobile Customer Advisory Team.

00:01:28.730 --> 00:01:31.260
We're really cool bunch of people,

00:01:31.260 --> 00:01:32.905
we love Xamarin, we love Mobile,

00:01:32.905 --> 00:01:35.000
and we work in making customers

00:01:35.000 --> 00:01:37.310
happy and we work in making
our products better.

00:01:37.310 --> 00:01:39.710
So we drive a lot of feedback,

00:01:39.710 --> 00:01:42.025
so anything you want to say,

00:01:42.025 --> 00:01:44.270
Mobile you want to discuss,

00:01:44.270 --> 00:01:47.015
sneakers, whatever,
just come find me.

00:01:47.015 --> 00:01:50.240
I work at the San Francisco office.

00:01:50.240 --> 00:01:53.575
I am known to code for candy,

00:01:53.575 --> 00:01:56.055
so if you ever want me
to write U(I) tests,

00:01:56.055 --> 00:01:58.170
you know how to bribe me, and I am

00:01:58.170 --> 00:02:01.660
a die-hard Microsoft and
a die-hard Xamarin fan.

00:02:03.380 --> 00:02:05.670
Now that you know who I am,

00:02:05.670 --> 00:02:08.070
follow me on Twitter, be my friend.

00:02:08.070 --> 00:02:10.110
Let's get down to testing.

00:02:10.110 --> 00:02:13.035
So Xamarin U(I) test.

00:02:13.035 --> 00:02:15.045
For those not familiar,

00:02:15.045 --> 00:02:21.030
it's NUnit-based unit
testing framework,

00:02:21.030 --> 00:02:24.435
but in C Sharp, and it allows
you to write U(I) test.

00:02:24.435 --> 00:02:27.434
It's aimed to be used
with mobile platforms,

00:02:27.434 --> 00:02:30.505
so your apps don't always
have to be a Xamarin app,

00:02:30.505 --> 00:02:32.690
so they can be a ReactNative App,
they can be a Native,

00:02:32.690 --> 00:02:33.980
Android or iOS App,

00:02:33.980 --> 00:02:36.425
you can still write
U(I) test for them.

00:02:36.425 --> 00:02:39.420
If you're familiar
with how NUnit works,

00:02:39.420 --> 00:02:42.065
their syntax or the test will
look pretty familiar to you.

00:02:42.065 --> 00:02:43.280
So there's a test fixture tag,

00:02:43.280 --> 00:02:46.220
there is a test tag, you're
doing some setup before a test,

00:02:46.220 --> 00:02:48.380
you run the test, and then you

00:02:48.380 --> 00:02:51.140
can have something that
happens after the test.

00:02:51.140 --> 00:02:54.515
Please straightforward,
Xamarin U(I) test,

00:02:54.515 --> 00:02:57.620
you can run these tests
locally, and then if you want,

00:02:57.620 --> 00:02:59.480
you can use the app
center test servers and

00:02:59.480 --> 00:03:02.155
then run your tests
on our device labs.

00:03:02.155 --> 00:03:06.020
It also integrates really well
with your CICD pipelines,

00:03:06.020 --> 00:03:08.825
which is my favorite part
of the whole process.

00:03:08.825 --> 00:03:12.000
So the description of
the talk said a lot

00:03:12.000 --> 00:03:15.140
about pop of the page object pattern.

00:03:15.140 --> 00:03:17.510
So what is this exactly?

00:03:17.510 --> 00:03:20.765
So let's talk of it this way.

00:03:20.765 --> 00:03:25.550
Mobile apps usually come with
a bunch of different views,

00:03:25.550 --> 00:03:27.740
when we actually write Xamarin apps,

00:03:27.740 --> 00:03:30.470
we have a bunch of
views, if it's MVVM,

00:03:30.470 --> 00:03:32.060
you have your views
and you have the code

00:03:32.060 --> 00:03:33.830
behind for each view, this and that,

00:03:33.830 --> 00:03:35.850
so simple concept, think

00:03:35.850 --> 00:03:38.400
of your App being a bunch
of different pages,

00:03:38.400 --> 00:03:40.560
so when you want to write

00:03:40.560 --> 00:03:42.930
the U(I) tests with
the page object pattern,

00:03:42.930 --> 00:03:44.450
we're going to treat each page

00:03:44.450 --> 00:03:47.540
individually as
its own independent class.

00:03:47.540 --> 00:03:51.035
So elements on that page
live in this class,

00:03:51.035 --> 00:03:52.730
interactions you can do with

00:03:52.730 --> 00:03:55.145
these elements live
within that same class.

00:03:55.145 --> 00:03:57.790
So if you have a button on page a,

00:03:57.790 --> 00:04:01.880
all the code in page
a's class would be a query on

00:04:01.880 --> 00:04:03.320
how the system will find

00:04:03.320 --> 00:04:06.410
that button and whatever method
to interact with a button.

00:04:06.410 --> 00:04:10.250
So click on a button
or if it's a list,

00:04:10.250 --> 00:04:11.485
so swipe on a list,

00:04:11.485 --> 00:04:13.790
all those methods for
that one page live there.

00:04:13.790 --> 00:04:15.125
Page b for your app,

00:04:15.125 --> 00:04:18.215
separate class, altogether
has its own things.

00:04:18.215 --> 00:04:23.030
The main idea behind doing
this is the fact that,

00:04:23.030 --> 00:04:25.285
since you're separating
out all these pages,

00:04:25.285 --> 00:04:27.275
it's really easy to maintain.

00:04:27.275 --> 00:04:29.840
So suppose you go in
and you make a change

00:04:29.840 --> 00:04:32.710
just to like maybe the
settings page in your app,

00:04:32.710 --> 00:04:34.310
all you have to go do is go

00:04:34.310 --> 00:04:36.035
to the settings page
of your test and just

00:04:36.035 --> 00:04:37.475
update the values there and that's

00:04:37.475 --> 00:04:39.605
your test are back to running again.

00:04:39.605 --> 00:04:41.460
So it's super easy to maintain,

00:04:41.460 --> 00:04:43.620
super easy to scale out,

00:04:43.620 --> 00:04:45.990
and then comes my best favorite part

00:04:45.990 --> 00:04:48.490
of this pattern it
makes across platform.

00:04:48.490 --> 00:04:51.775
So that same page can
exist on iOS or Android.

00:04:51.775 --> 00:04:56.005
Then, what could be the possible
no differentiating factor here?

00:04:56.005 --> 00:04:58.790
On Android, the button could have

00:04:58.790 --> 00:05:01.260
a separate query and then also

00:05:01.260 --> 00:05:02.460
maybe there's a little bit of a

00:05:02.460 --> 00:05:04.110
no touch behavior that's different,

00:05:04.110 --> 00:05:07.535
so you can handle that in your code
with the on-device checks.

00:05:07.535 --> 00:05:09.260
So again, super simple,

00:05:09.260 --> 00:05:10.520
super easy to set up,

00:05:10.520 --> 00:05:12.965
and we'll see more about it now.

00:05:12.965 --> 00:05:15.230
So what I was talking

00:05:15.230 --> 00:05:17.760
about visually just
imagining the whole thing.

00:05:17.760 --> 00:05:20.485
So these are different
pages of your app,

00:05:20.485 --> 00:05:23.855
take each page and turn
each page into a class,

00:05:23.855 --> 00:05:26.420
that's literally how the first steps

00:05:26.420 --> 00:05:29.075
of writing the page
object pattern starts.

00:05:29.075 --> 00:05:33.840
So if you want to be a
little more fancy about it,

00:05:33.840 --> 00:05:35.855
when you're done setting up

00:05:35.855 --> 00:05:37.130
the whole architecture pattern and

00:05:37.130 --> 00:05:38.440
when you go back and
you look at your tests,

00:05:38.440 --> 00:05:39.650
there's never going to be

00:05:39.650 --> 00:05:41.660
a point that you feel like,
"Oh, what did I write?

00:05:41.660 --> 00:05:43.280
What does this mean?"
There's going to be

00:05:43.280 --> 00:05:46.720
a direct correlation between
your app and your tests.

00:05:46.720 --> 00:05:51.120
So it just makes it so much
nicer to write your tests,

00:05:51.120 --> 00:05:54.710
I feel like it just encourages
everyone to reserve,

00:05:54.710 --> 00:05:56.555
maintain, and write good U(I) test,

00:05:56.555 --> 00:05:59.065
which I think is very very important.

00:05:59.065 --> 00:06:01.020
If I can, I'm going to say it,

00:06:01.020 --> 00:06:02.395
I say this all the time,

00:06:02.395 --> 00:06:05.900
but we live in the era of
mobile apps and we live in the era

00:06:05.900 --> 00:06:07.130
of making customers and

00:06:07.130 --> 00:06:09.530
your users really happy
with your mobile apps.

00:06:09.530 --> 00:06:11.360
If you'd not U(I) testing them,

00:06:11.360 --> 00:06:12.890
there's a minimum subset of

00:06:12.890 --> 00:06:15.890
10 percent who are not getting
the best visual look of

00:06:15.890 --> 00:06:17.600
your app just because
you never tested it on

00:06:17.600 --> 00:06:20.900
that one obsolete phone
that someone's using.

00:06:20.900 --> 00:06:22.985
That's how you can
leverage U(I) tests

00:06:22.985 --> 00:06:24.680
and Apps center and
make sure that your app

00:06:24.680 --> 00:06:26.390
looks beautiful and runs really well

00:06:26.390 --> 00:06:28.930
on all the different platforms
that are trying to support.

00:06:28.930 --> 00:06:34.940
So the next awesome thing about
the page object pattern is,

00:06:34.940 --> 00:06:38.615
if you've written U(I) test
before or if you've not,

00:06:38.615 --> 00:06:41.645
this is basically what a
simple U(I) test looks like.

00:06:41.645 --> 00:06:43.100
So you have, like I said,

00:06:43.100 --> 00:06:44.630
it's very similar to
the NUnit pattern,

00:06:44.630 --> 00:06:47.415
that you have to set up, and
you have the actual test,

00:06:47.415 --> 00:06:48.745
and in the test, if you look,

00:06:48.745 --> 00:06:51.725
it has a really long line that says,

00:06:51.725 --> 00:06:54.260
app.Tap, and then it's trying to

00:06:54.260 --> 00:06:57.685
find an element on
the screen by its ID.

00:06:57.685 --> 00:07:01.190
The beauty of using
the page object pattern is,

00:07:01.190 --> 00:07:03.680
it makes it a little more
generic in the sense that,

00:07:03.680 --> 00:07:05.705
remember those pages
I was talking about,

00:07:05.705 --> 00:07:09.370
it literally becomes
in the login page,

00:07:09.890 --> 00:07:12.450
perform the login action,

00:07:12.450 --> 00:07:14.480
and then use this username
and password.

00:07:14.480 --> 00:07:17.210
So it makes it easier to read also.

00:07:17.210 --> 00:07:19.520
So again, if anyone who's
not done testing before,

00:07:19.520 --> 00:07:21.080
is not really, "Oh,

00:07:21.080 --> 00:07:23.470
my God, how am I going to
write a C Sharp test?"

00:07:23.470 --> 00:07:25.275
They can just come
in and be like, "Oh,

00:07:25.275 --> 00:07:26.610
this just reads like English,

00:07:26.610 --> 00:07:27.915
this isn't so hard to understand,

00:07:27.915 --> 00:07:29.940
I know what's going on in this test."

00:07:29.940 --> 00:07:34.470
So I can keep going
on and on like this,

00:07:34.470 --> 00:07:36.325
but this isn't any fun.

00:07:36.325 --> 00:07:39.305
What I'm actually going to do now is,

00:07:39.305 --> 00:07:41.420
I'm going to switch over and actually

00:07:41.420 --> 00:07:43.820
write a page object button test
for you right now,

00:07:43.820 --> 00:07:47.100
because who doesn't
like some live coding?

00:07:47.930 --> 00:07:52.590
So while I get this thing set up.

00:07:52.590 --> 00:07:55.760
So this has become a
side hobby of mine.

00:07:55.760 --> 00:07:59.815
So this is an app that
my good friend James Clancy,

00:07:59.815 --> 00:08:03.660
if you remember him from
Xamarin evolve 2016,

00:08:03.660 --> 00:08:06.170
he gave my favorite talk
on Async await,

00:08:06.170 --> 00:08:08.210
definitely cashed out
videos on YouTube.

00:08:08.210 --> 00:08:11.490
But so, he's been
working on his gmusic,

00:08:11.490 --> 00:08:14.870
some Google Music loan and he's
been rewriting his Google,

00:08:14.870 --> 00:08:16.730
so it was originally only for iOS,

00:08:16.730 --> 00:08:18.430
he's been rewriting it for firms,

00:08:18.430 --> 00:08:20.640
and he's an open source
project he teaches it

00:08:20.640 --> 00:08:23.700
every Wednesday, you
should only check him out.

00:08:23.700 --> 00:08:26.150
I noticed that he's been writing

00:08:26.150 --> 00:08:27.840
all this grid Xamarin Forms score,

00:08:27.840 --> 00:08:29.985
but guess what, he's not been doing,

00:08:29.985 --> 00:08:32.120
UI testing, any of it.

00:08:32.120 --> 00:08:36.995
So as my contribution to
the open source community,

00:08:36.995 --> 00:08:39.410
we will now write UI
tests for Clancy,

00:08:39.410 --> 00:08:42.990
and Clancy if you're
watching, you're welcome.

00:08:43.490 --> 00:08:48.370
So before I start,

00:08:48.860 --> 00:08:51.495
so again, this is tips and tricks,

00:08:51.495 --> 00:08:53.030
so I'm going to give
you tips and tricks.

00:08:53.030 --> 00:08:56.630
Tip number 1, I would always
suggest testing on real devices.

00:08:56.630 --> 00:08:58.340
So you can see right
now, but on this table,

00:08:58.340 --> 00:09:01.290
I actually have an icon on
an iOS device connected,

00:09:01.290 --> 00:09:03.305
and I'm screen mirroring
it for you right now.

00:09:03.305 --> 00:09:05.850
So this is what the app
looks like right now,

00:09:05.850 --> 00:09:07.380
so if you get in,

00:09:07.380 --> 00:09:08.850
you'll see a list of songs,

00:09:08.850 --> 00:09:10.905
you can slide up,

00:09:10.905 --> 00:09:15.450
and you can see this nice
little now playing screen.

00:09:15.450 --> 00:09:17.295
This is as far as he's got,

00:09:17.295 --> 00:09:18.990
and if you swipe to the side,

00:09:18.990 --> 00:09:21.195
look at this beautiful
gradient that he's got,

00:09:21.195 --> 00:09:24.015
and you can look at the
side navigation menu.

00:09:24.015 --> 00:09:26.285
Okay. So this is as far as he's got,

00:09:26.285 --> 00:09:29.325
so let's get some U(I)
tests written for this.

00:09:29.325 --> 00:09:33.745
So since you can just
see my iOS device here,

00:09:33.745 --> 00:09:35.665
now I'm going to start with iOS.

00:09:35.665 --> 00:09:38.960
This is U(I) test project that
you see on the left over here,

00:09:38.960 --> 00:09:42.850
this is literally what you
get when I do right-click,

00:09:42.850 --> 00:09:49.120
"Add," "New Project," and I pick
if my thing comes up, there we go.

00:09:49.120 --> 00:09:50.955
So if I pick a U(I) test project,

00:09:50.955 --> 00:09:54.260
this is the blank template
code that you get.

00:09:54.260 --> 00:09:55.910
I have not done anything at all,

00:09:55.910 --> 00:09:58.505
this is as is as you get it.

00:09:58.505 --> 00:10:00.135
All I have done is,

00:10:00.135 --> 00:10:01.605
in the App initializer,

00:10:01.605 --> 00:10:05.190
I've just put in a part
to where the APK for

00:10:05.190 --> 00:10:07.160
the Android device is build to

00:10:07.160 --> 00:10:09.730
and I put in synthesis on my device,

00:10:09.730 --> 00:10:12.275
I put in the bundle ID
for the iOS app.

00:10:12.275 --> 00:10:15.680
So that's all you need
to do to get started.

00:10:15.680 --> 00:10:19.330
So to make sure I
didn't break anything,

00:10:19.330 --> 00:10:24.340
let's get the app running
because that's step number 1.

00:10:24.340 --> 00:10:26.795
So let's get iOS,

00:10:26.795 --> 00:10:29.510
let's get that test running,
so the page object pattern.

00:10:29.510 --> 00:10:30.955
The way the pattern works is,

00:10:30.955 --> 00:10:34.070
it's based off four main pages.

00:10:34.070 --> 00:10:35.820
If you were to go to

00:10:35.820 --> 00:10:40.580
our GitHub repository
where we have this set up,

00:10:40.580 --> 00:10:42.140
there is a sample in there,

00:10:42.140 --> 00:10:43.610
we have a wiki that

00:10:43.610 --> 00:10:46.190
again goes through everything
that I'm discussing right now.

00:10:46.190 --> 00:10:47.385
So if you forget,

00:10:47.385 --> 00:10:49.055
just go in and have a read.

00:10:49.055 --> 00:10:51.165
But literally, all the U(I),

00:10:51.165 --> 00:10:53.179
all page of the pattern
can be encapsulated

00:10:53.179 --> 00:10:55.790
into these four pages that
I mentioned over there.

00:10:55.790 --> 00:10:58.465
That Manager, a base test fixture,

00:10:58.465 --> 00:11:01.640
a base page, and a platform query.

00:11:05.330 --> 00:11:07.710
Oops, what did I do?

00:11:07.710 --> 00:11:10.060
Do I have a test failure?

00:11:15.200 --> 00:11:17.385
Okay, I am going to
such out for Android,

00:11:17.385 --> 00:11:21.380
just for a bit, and get this running.

00:11:21.380 --> 00:11:24.960
My devices just disconnect.

00:11:31.590 --> 00:11:37.630
We got it. Who's going to
connect this back up. All right.

00:11:37.630 --> 00:11:41.605
So we have our Repl on the side,

00:11:41.605 --> 00:11:43.870
which we will use to query for
the elements on the screen,

00:11:43.870 --> 00:11:45.745
we have my app up on the front.

00:11:45.745 --> 00:11:49.150
But before I do any of that going
back to the page object pattern.

00:11:49.150 --> 00:11:51.310
So those four base pages.

00:11:51.310 --> 00:11:53.830
Day-to-day, I just come in and just

00:11:53.830 --> 00:11:56.170
literally just go "File New"
and copy in those pages.

00:11:56.170 --> 00:11:59.470
But if you wanted to be
super convenient for you,

00:11:59.470 --> 00:12:04.075
we have a NuGet package
that you can import in,

00:12:04.075 --> 00:12:05.800
and all that does is just auto

00:12:05.800 --> 00:12:07.840
injects those four pages
that I mentioned,

00:12:07.840 --> 00:12:11.845
the BaseTest, BasePage,
PlatformQuery, and AppManager.

00:12:11.845 --> 00:12:14.350
It just adds that in
automatically for you.

00:12:14.350 --> 00:12:15.730
So I'm going to do that.

00:12:15.730 --> 00:12:17.530
If you notice, one, two,

00:12:17.530 --> 00:12:20.260
three, four; four pages are added in.

00:12:20.260 --> 00:12:22.030
Let's see what each of them look as

00:12:22.030 --> 00:12:24.040
a small things we have
to set up in there.

00:12:24.040 --> 00:12:30.925
So AppManager will turn into
the new AppInitializer.

00:12:30.925 --> 00:12:33.970
All AppManager literally
doing is it's just telling

00:12:33.970 --> 00:12:35.560
the framework this is where

00:12:35.560 --> 00:12:38.305
the Android app is and this
is where the iOS app is.

00:12:38.305 --> 00:12:40.840
Since I already had it set
up in this code over here,

00:12:40.840 --> 00:12:44.680
I'm just going to copy the part
because I don't want to type this

00:12:44.680 --> 00:12:48.820
out again, with this in here.

00:12:48.820 --> 00:12:51.340
So if you were doing
this, another tip,

00:12:51.340 --> 00:12:53.770
both on Windows and on Mac,

00:12:53.770 --> 00:12:56.035
you can right-click here
and add an app project.

00:12:56.035 --> 00:12:57.985
This will connect into the solutions,

00:12:57.985 --> 00:12:59.380
if you're doing a Xamarin app,

00:12:59.380 --> 00:13:02.530
and you have your solution
with the UITest side-by-side.

00:13:02.530 --> 00:13:05.365
You can hook them up to
work with each other.

00:13:05.365 --> 00:13:11.410
I usually avoid doing that
mostly because sometimes it can

00:13:11.410 --> 00:13:13.810
take a few minutes if it's

00:13:13.810 --> 00:13:17.800
a really big app for it to start
because it'll rebuild the app,

00:13:17.800 --> 00:13:21.370
deploy it on the device, and
then start the test for you.

00:13:21.370 --> 00:13:23.635
I just like a faster turnaround time,

00:13:23.635 --> 00:13:25.420
so I usually just make

00:13:25.420 --> 00:13:27.250
sure the apps already
installed on my device,

00:13:27.250 --> 00:13:28.420
and then I start writing tests.

00:13:28.420 --> 00:13:33.500
That's cool little tip, they
can help you sometimes.

00:13:33.840 --> 00:13:36.730
Let me get that in here. All right.

00:13:36.730 --> 00:13:40.810
So all I've done in this is again
just put in the path to where

00:13:40.810 --> 00:13:45.595
the APK and the installed
mobile ID for my app.

00:13:45.595 --> 00:13:47.980
I can now get rid of AppInitializer,

00:13:47.980 --> 00:13:49.705
I don't need this anymore.

00:13:49.705 --> 00:13:53.350
So let's delete. Next step.

00:13:53.350 --> 00:13:55.585
We've got AppInitializer done.

00:13:55.585 --> 00:13:59.335
We need to now come in and let's
take a look at the BasePage.

00:13:59.335 --> 00:14:00.640
So BasePage.

00:14:00.640 --> 00:14:02.650
So every page that I
was talking about,

00:14:02.650 --> 00:14:03.850
like each class is a page,

00:14:03.850 --> 00:14:05.605
so every page is going
to inherit this.

00:14:05.605 --> 00:14:07.390
All this is doing is it provides you

00:14:07.390 --> 00:14:09.685
with an on Android and on iOS.

00:14:09.685 --> 00:14:11.980
So this is how you can do
that cross-platform splitting

00:14:11.980 --> 00:14:13.810
that I was talking about.

00:14:13.810 --> 00:14:16.390
Another cool thing that
the BasePage does for

00:14:16.390 --> 00:14:18.715
you is it takes a free screenshot.

00:14:18.715 --> 00:14:21.295
So if you want to run
these tests on App Center,

00:14:21.295 --> 00:14:23.830
usually is you don't have
screenshots in your test,

00:14:23.830 --> 00:14:25.030
if you just upload a test,

00:14:25.030 --> 00:14:26.860
you're not going to get
a good test result.

00:14:26.860 --> 00:14:28.330
To make life easy for you,

00:14:28.330 --> 00:14:30.610
we have an AssertOnPage.

00:14:30.610 --> 00:14:33.250
It's for free. It does it
automatically on each page.

00:14:33.250 --> 00:14:35.290
So on each page that
inherits a BasePage,

00:14:35.290 --> 00:14:37.600
it's automatically
going to verify, "Hey,

00:14:37.600 --> 00:14:40.434
is this on the page I'm expecting?"

00:14:40.434 --> 00:14:42.820
Now, you'd be wondering how
would the system know or

00:14:42.820 --> 00:14:45.190
how are we verifying it's
on the page it needs to be.

00:14:45.190 --> 00:14:47.200
That's what this magic
little thing and

00:14:47.200 --> 00:14:49.780
the fourth file called PlatformQuery.

00:14:49.780 --> 00:14:52.660
So this is what we use in

00:14:52.660 --> 00:14:54.010
this pattern to make sure you're

00:14:54.010 --> 00:14:55.840
on the page you're expected to be.

00:14:55.840 --> 00:14:58.315
For example, if you're
on a login page,

00:14:58.315 --> 00:15:01.060
most probably some people
usually have the Word

00:15:01.060 --> 00:15:03.700
login or like signed in on that page,

00:15:03.700 --> 00:15:05.440
you can just use that
as a platform tray

00:15:05.440 --> 00:15:07.180
to make sure that you are
on the page are expected,

00:15:07.180 --> 00:15:09.100
So just something
unique to that page.

00:15:09.100 --> 00:15:10.870
So that you know for sure, okay,

00:15:10.870 --> 00:15:12.490
I'm on the page I'm
expected to be and I

00:15:12.490 --> 00:15:14.665
can perform the actions on that page.

00:15:14.665 --> 00:15:17.455
The nice part is once it
verifies you're on that page,

00:15:17.455 --> 00:15:18.850
it takes a free screenshot for you.

00:15:18.850 --> 00:15:21.325
So it's like on this page.

00:15:21.325 --> 00:15:24.415
All right. So that's
what BasePage does.

00:15:24.415 --> 00:15:29.575
BaseTestFixtures are every test
is going to inherit this.

00:15:29.575 --> 00:15:32.050
Same process. So they're
providing those on

00:15:32.050 --> 00:15:34.870
iOS and on Android values here.

00:15:34.870 --> 00:15:37.870
Again, sometimes there are
some flaws in the app which can

00:15:37.870 --> 00:15:41.620
default little bit
between iOS and Android.

00:15:41.620 --> 00:15:43.780
So within your tests, you
can have a breakup and

00:15:43.780 --> 00:15:46.870
the flaw using these values.

00:15:46.870 --> 00:15:50.035
Literally, all it does is it grabs

00:15:50.035 --> 00:15:52.735
the value from AppManager
and starts the app for you.

00:15:52.735 --> 00:15:54.580
That is it. It's super simple,

00:15:54.580 --> 00:15:57.860
nothing too complicated, nothing
too fancy happening over here.

00:15:57.870 --> 00:16:02.140
The last is the test itself.

00:16:02.140 --> 00:16:06.160
So this was how the
initial test looks like,

00:16:06.160 --> 00:16:08.610
but if you noticed
in the test fixture,

00:16:08.610 --> 00:16:11.580
we're already doing like all of
these tagging things in there.

00:16:11.580 --> 00:16:13.470
So we can slim down the whole test,

00:16:13.470 --> 00:16:15.060
it doesn't need all these values.

00:16:15.060 --> 00:16:21.220
What it'll start looking
like is something like this.

00:16:21.220 --> 00:16:26.365
So your test will literally
just inherit BaseTestFixture.

00:16:26.365 --> 00:16:27.970
Again, we're passing in the platform,

00:16:27.970 --> 00:16:30.775
so it knows what platform to run on.

00:16:30.775 --> 00:16:34.450
So the Repl being the
read only eval loop,

00:16:34.450 --> 00:16:36.685
which led to query for
elements on the screen.

00:16:36.685 --> 00:16:38.935
So you can have a test
that just launches that,

00:16:38.935 --> 00:16:40.960
and then I have another test
already written in

00:16:40.960 --> 00:16:44.155
here that goes into the homepage,

00:16:44.155 --> 00:16:46.750
like on the homepage that
the apps are on right now.

00:16:46.750 --> 00:16:48.355
Let me pull up app again.

00:16:48.355 --> 00:16:52.690
It will swipe and it will
go into the Settings tab.

00:16:52.690 --> 00:16:57.490
So simple test just to make sure
I haven't messed anything up.

00:16:57.490 --> 00:16:58.765
So the test is there.

00:16:58.765 --> 00:17:02.470
Let's have a look at what
a completed page looks like.

00:17:02.470 --> 00:17:04.495
We will be writing down
this page, so don't worry.

00:17:04.495 --> 00:17:08.540
So walking through what to expect.

00:17:09.060 --> 00:17:12.745
So this is what a page looks like.

00:17:12.745 --> 00:17:16.150
A few tips here. Alien thing

00:17:16.150 --> 00:17:19.855
the Word query makes
life so much nicer.

00:17:19.855 --> 00:17:24.145
So when you are setting up
the different buttons on the screen,

00:17:24.145 --> 00:17:25.930
you can simply just do query,

00:17:25.930 --> 00:17:28.450
or you can even make it
into a fancy little funk.

00:17:28.450 --> 00:17:30.190
So that's a cool little tip to have.

00:17:30.190 --> 00:17:31.780
So we don't have these
buttons on the screen.

00:17:31.780 --> 00:17:33.385
I'm going to comment
this out for now.

00:17:33.385 --> 00:17:36.820
The next thing you'll notice
is it inherits some BasePage.

00:17:36.820 --> 00:17:39.820
So if I were to remove this away,

00:17:39.820 --> 00:17:41.860
the system will
automatically be like,

00:17:41.860 --> 00:17:43.135
no there's something wrong.

00:17:43.135 --> 00:17:46.270
I'm not going to let you do this
because you need to implement

00:17:46.270 --> 00:17:49.960
the platform query implementations.

00:17:49.960 --> 00:17:52.810
Because like I said, it is
what drives the system,

00:17:52.810 --> 00:18:00.520
it is what basically that helps
the system understand sorry,

00:18:00.520 --> 00:18:02.635
that okay, this is on
the page I'm supposed to be,

00:18:02.635 --> 00:18:05.275
and now I can perform
the actions on it.

00:18:05.275 --> 00:18:11.320
So the homepage, that's literally
this page that it lands on,

00:18:11.320 --> 00:18:15.730
it checks for, so for on iOS,

00:18:15.730 --> 00:18:17.890
it's text for this button.

00:18:17.890 --> 00:18:19.690
I don't have an iOS open, do I?

00:18:19.690 --> 00:18:21.910
It checks for this button
that says gMusic.

00:18:21.910 --> 00:18:25.420
But if you'll notice, there's
no menu add task in Android.

00:18:25.420 --> 00:18:28.960
So let's find out what the trade
could be for Android's.

00:18:28.960 --> 00:18:31.525
Let me get, where's my Repl,

00:18:31.525 --> 00:18:33.970
not my terminal go away.

00:18:33.970 --> 00:18:39.080
So let's see what we
have going on in here.

00:18:40.140 --> 00:18:43.780
In this giant stream of things,

00:18:43.780 --> 00:18:45.625
this can be a little overwhelming.

00:18:45.625 --> 00:18:47.125
If you're writing UI
test for the first time,

00:18:47.125 --> 00:18:48.340
I know a lot of people who don't

00:18:48.340 --> 00:18:49.930
like looking at rapel
and I don't blame you,

00:18:49.930 --> 00:18:51.670
this is a Cortana information.

00:18:51.670 --> 00:18:54.940
Again, few tips and tricks
just to make your life easier.

00:18:54.940 --> 00:18:58.765
Things in these square brackets
are usually classes.

00:18:58.765 --> 00:19:01.750
If you're querying for a class
and you try and figure out,

00:19:01.750 --> 00:19:04.660
if I can find an ID for
a page or an element,

00:19:04.660 --> 00:19:07.480
I can use the class, this
is what you want to use.

00:19:07.480 --> 00:19:09.310
What I'm going to do is,

00:19:09.310 --> 00:19:12.295
I actually went in and added
a couple of automation IDs,

00:19:12.295 --> 00:19:15.010
and I see that there is now
playing page and there's

00:19:15.010 --> 00:19:17.800
a mini player which is
this thing at the bottom,

00:19:17.800 --> 00:19:19.900
so I'm going to use
that as the Trait.

00:19:19.900 --> 00:19:21.940
Let's go in here and replace that,

00:19:21.940 --> 00:19:23.635
so we have mini player.

00:19:23.635 --> 00:19:26.530
So the homepage looks good
enough to me, that's fine.

00:19:26.530 --> 00:19:28.990
I'm not going to put any method
in the homepage right now just

00:19:28.990 --> 00:19:31.480
because we're not doing
any action on the homepage yet,

00:19:31.480 --> 00:19:34.885
all we're doing is swiping
into that side menu.

00:19:34.885 --> 00:19:39.145
I'm going to go back into
the base page for a bit,

00:19:39.145 --> 00:19:41.980
because there's
cool funky little thing

00:19:41.980 --> 00:19:44.065
I have here which I'm
going to copy over.

00:19:44.065 --> 00:19:47.230
What is going on is,

00:19:47.230 --> 00:19:49.585
the base page is super powerful.

00:19:49.585 --> 00:19:51.940
One of the cool things I
want to highlight here is,

00:19:51.940 --> 00:19:55.750
if you look at the how this app
works, let me put this up,

00:19:55.750 --> 00:19:58.390
so you're in the songs you right now,

00:19:58.390 --> 00:20:00.160
you can switch over to artists.

00:20:00.160 --> 00:20:03.835
Again, the side menu is still
accessible from the same page.

00:20:03.835 --> 00:20:06.010
If I go into genres,

00:20:06.010 --> 00:20:08.245
again the side menu is accessible,

00:20:08.245 --> 00:20:09.940
and I love the host side,
and no one has

00:20:09.940 --> 00:20:12.055
reacted to my trashy taste in music,

00:20:12.055 --> 00:20:14.210
you guys are the best.

00:20:14.760 --> 00:20:17.245
The thing is, this is a shared page

00:20:17.245 --> 00:20:18.880
it's like shared functionality,

00:20:18.880 --> 00:20:20.800
so let's share the code.

00:20:20.800 --> 00:20:24.670
I'm going to put this
in my base page,

00:20:24.670 --> 00:20:29.185
so all this is doing is this
is the Select menu method,

00:20:29.185 --> 00:20:31.090
which is going to do
the action of open

00:20:31.090 --> 00:20:33.250
the menu and select a menu item.

00:20:33.250 --> 00:20:35.845
I'm going put this in the base page
because it looks like

00:20:35.845 --> 00:20:39.460
every single page in this app
has access to this base page.

00:20:39.460 --> 00:20:41.470
It is going to make
my life easier to do that.

00:20:41.470 --> 00:20:45.775
Another cool trick is the return
values of these methods.

00:20:45.775 --> 00:20:47.635
If you return the page you are on,

00:20:47.635 --> 00:20:49.450
you can keep stringing on the methods

00:20:49.450 --> 00:20:51.895
just makes your test
look much much nicer.

00:20:51.895 --> 00:20:54.865
What we recommend with
the page object pattern is,

00:20:54.865 --> 00:20:58.825
if it's a method that doesn't
navigate out of that page,

00:20:58.825 --> 00:21:00.610
make the return type the page itself.

00:21:00.610 --> 00:21:01.990
Because that means
you're going to continue

00:21:01.990 --> 00:21:03.400
doing more actions on that page,

00:21:03.400 --> 00:21:06.490
you don't want to new up a page
when you're writing the test.

00:21:06.490 --> 00:21:08.560
But if you're navigating
away from the page,

00:21:08.560 --> 00:21:10.210
it means that there's
going to be a new page

00:21:10.210 --> 00:21:12.580
happening after this method
is done anyway,

00:21:12.580 --> 00:21:16.615
so that's when you want to make
it wide. That's another cool tip.

00:21:16.615 --> 00:21:22.420
I don't have my using alias in
here so let me pull that over,

00:21:22.420 --> 00:21:26.000
you want to use some funks and wow.

00:21:26.790 --> 00:21:31.900
Okay, this seems happy
this looks good.

00:21:31.900 --> 00:21:33.760
I have a similar thing that does

00:21:33.760 --> 00:21:38.185
the drag action from the bottom
to open up the now plain view.

00:21:38.185 --> 00:21:40.495
Again, it's a shared action
whichever page you're

00:21:40.495 --> 00:21:42.790
on you should be able to
do this actions again,

00:21:42.790 --> 00:21:44.770
I've put that in my base page.

00:21:44.770 --> 00:21:46.900
You'll start noticing
things like we're

00:21:46.900 --> 00:21:48.490
doing all these
principles you would do

00:21:48.490 --> 00:21:50.080
when you're writing an app not

00:21:50.080 --> 00:21:52.120
necessarily when
you're writing a test.

00:21:52.120 --> 00:21:54.910
The highlight of
this whole thing is that,

00:21:54.910 --> 00:21:57.040
writing tests is like writing an app.

00:21:57.040 --> 00:21:58.570
I mean if you're smart about it,

00:21:58.570 --> 00:22:00.175
and you may go test suites robust,

00:22:00.175 --> 00:22:01.480
it just makes writing

00:22:01.480 --> 00:22:04.310
the tests and maintaining
them so much nicer.

00:22:04.380 --> 00:22:06.805
Cool, so habit-based set up,

00:22:06.805 --> 00:22:08.455
I have my homepage setup.

00:22:08.455 --> 00:22:10.390
We have our test going,

00:22:10.390 --> 00:22:11.440
so I'm going to comment out

00:22:11.440 --> 00:22:14.530
this old testfile because
we don't need this anymore,

00:22:14.530 --> 00:22:18.085
and this is our settings thing.

00:22:18.085 --> 00:22:23.230
Another cool tip, it's all
running through Nunit.

00:22:23.230 --> 00:22:25.390
Yeah, if you support Nunit 3 now,

00:22:25.390 --> 00:22:30.170
so you can use Nunit 3 with UI test.

00:22:30.960 --> 00:22:34.600
Highlight and use every single power
that Nunit provides.

00:22:34.600 --> 00:22:38.690
Use test cases, and you
know optimize your desks.

00:22:39.900 --> 00:22:43.075
It's like you have
all this power there,

00:22:43.075 --> 00:22:44.560
don't forget that
even though this has

00:22:44.560 --> 00:22:46.300
Xamarin UI test is running on Nunits,

00:22:46.300 --> 00:22:48.610
you have all Nunit functionality
available to you.

00:22:48.610 --> 00:22:50.965
So you can assert, you
can use test cases,

00:22:50.965 --> 00:22:52.615
you can use ignore,

00:22:52.615 --> 00:22:56.410
you can also use
my favorite thing category.

00:22:56.410 --> 00:22:59.590
My favorite thing to
do with category is to

00:22:59.590 --> 00:23:02.275
set up tests with smoke test,

00:23:02.275 --> 00:23:04.825
nightly tests, dev tests.

00:23:04.825 --> 00:23:08.665
If you have your CI/CD setup
with the UI tests in it,

00:23:08.665 --> 00:23:10.690
categorize your tests,
so you're not running

00:23:10.690 --> 00:23:12.625
the whole test suite every time.

00:23:12.625 --> 00:23:16.465
So if it's just a Dev BR check
just make it runs on smoke tests.

00:23:16.465 --> 00:23:18.490
If it's a daily big,

00:23:18.490 --> 00:23:19.840
do a subset of

00:23:19.840 --> 00:23:22.825
your whole suite and call that
your daily category of tests.

00:23:22.825 --> 00:23:24.640
If it's a Nike bid, that's when I'd

00:23:24.640 --> 00:23:26.830
recommend doing like
the whole test end-to-end,

00:23:26.830 --> 00:23:28.150
just because no one's
working on and you

00:23:28.150 --> 00:23:30.145
have all the three computers.

00:23:30.145 --> 00:23:36.410
Again, use leverage all the cool
stuff that Nunit has to provide.

00:23:36.540 --> 00:23:42.145
I'm going to rebuild the,

00:23:42.145 --> 00:23:43.540
oops, I have my rapel open,

00:23:43.540 --> 00:23:44.725
don't I? Yes I do.

00:23:44.725 --> 00:23:47.380
Let's quit out of this,

00:23:47.380 --> 00:23:50.905
rapel is good, does look happy.

00:23:50.905 --> 00:23:58.930
We set up the test case for
settings page and check that out.

00:23:58.930 --> 00:24:03.010
Now sets it up in
the unit test panel,

00:24:03.010 --> 00:24:05.260
so I'm going to go open
up the settings page,

00:24:05.260 --> 00:24:07.285
let's see what this looks like.

00:24:07.285 --> 00:24:10.795
Attempt number two with iOS,
let's see how this goes.

00:24:10.795 --> 00:24:14.300
No, it doesn't like
my iOS device, why?

00:24:16.920 --> 00:24:21.490
Oops, stood this, kill the app.

00:24:21.490 --> 00:24:25.300
Get this app again, clean.

00:24:25.300 --> 00:24:35.155
Here we go, come on,

00:24:35.155 --> 00:24:37.520
don't edit it out on me.

00:24:37.800 --> 00:24:40.825
Make all the demo gods happy.

00:24:40.825 --> 00:24:45.610
As it's running, let me see,

00:24:45.610 --> 00:24:48.670
I was going to say something that
only, oh yes, it's running now.

00:24:48.670 --> 00:24:54.710
Let's see how this goes.
It is opening the app.

00:24:57.450 --> 00:25:01.990
No, it didn't swipe and
select my menu item.

00:25:01.990 --> 00:25:04.550
I'm so sad now, let's
see what's going on.

00:25:04.650 --> 00:25:08.840
Site right left, we have the menu.

00:25:13.650 --> 00:25:16.000
The next thing this will
happen, but let's say

00:25:16.000 --> 00:25:18.085
that I was doing on let's debug test.

00:25:18.085 --> 00:25:20.260
Not sure why this isn't working,

00:25:20.260 --> 00:25:22.210
what I'm going to do is going
to enter rapel in here,

00:25:22.210 --> 00:25:24.010
and I'm going to verify
why my test isn't working

00:25:24.010 --> 00:25:25.870
because honestly I
thought this was going to

00:25:25.870 --> 00:25:30.530
work as I need it
work like an article.

00:25:33.570 --> 00:25:36.985
This is how the completed test,

00:25:36.985 --> 00:25:39.565
oh my God, I should
remember to kill that.

00:25:39.565 --> 00:25:44.290
You saw how the completed look

00:25:44.290 --> 00:25:46.090
of the test looks like
and how does a bunch of

00:25:46.090 --> 00:25:48.550
my Go-Share and method sharing
that you can do.

00:25:48.550 --> 00:25:53.080
How would you go about starting
out writing a fresh test,

00:25:53.080 --> 00:25:55.435
so maybe converting tests
that you already have.

00:25:55.435 --> 00:25:57.130
Step number one would be literally

00:25:57.130 --> 00:25:58.885
what I just did,
adding in the UI test,

00:25:58.885 --> 00:26:01.405
you can use the pop package
or you can go into

00:26:01.405 --> 00:26:05.690
GitHub and manually copy over
those pages whatever you like.

00:26:06.240 --> 00:26:10.180
The second thing is
like I said you go in,

00:26:10.180 --> 00:26:11.500
edit the app manager file,

00:26:11.500 --> 00:26:14.260
delete all the app initializer
file, you did all that.

00:26:14.260 --> 00:26:17.050
You come in and then

00:26:17.050 --> 00:26:19.795
the next step literally just is
to start creating the pages.

00:26:19.795 --> 00:26:22.150
I had homepage already created
with the trade in there,

00:26:22.150 --> 00:26:23.560
but that's literally the next step.

00:26:23.560 --> 00:26:25.120
The initial buy-in can be a

00:26:25.120 --> 00:26:26.920
little expensive because
it takes a little bit of

00:26:26.920 --> 00:26:30.490
time depending on how many pages
and how advanced your app is.

00:26:30.490 --> 00:26:31.870
But the nice part is,

00:26:31.870 --> 00:26:33.460
you can actually split up this work

00:26:33.460 --> 00:26:35.200
because it's independent
on who's working on it.

00:26:35.200 --> 00:26:36.715
Because everyone who's on that page,

00:26:36.715 --> 00:26:38.110
so you can split up the work of

00:26:38.110 --> 00:26:39.640
writing each page
between five people,

00:26:39.640 --> 00:26:41.005
everyone writes one page,

00:26:41.005 --> 00:26:43.810
and that's it, you have in
the initial setup done.

00:26:43.810 --> 00:26:47.800
Because once the pages are in that's
all that takes the most time,

00:26:47.800 --> 00:26:50.365
then you just cooking up
the methods to write your tests,

00:26:50.365 --> 00:26:52.645
super-simple, it's
really straightforward.

00:26:52.645 --> 00:27:00.500
Now, let's see why my swipe
right to left wasn't swiping.

00:27:03.750 --> 00:27:07.840
So is my code other way around?

00:27:07.840 --> 00:27:11.170
My code is right to
left, okay let's see.

00:27:11.170 --> 00:27:14.090
I had the rapel open, let's verify.

00:27:14.100 --> 00:27:18.730
If it's going right to left
it's not doing anything weird.

00:27:18.730 --> 00:27:20.740
Okay, let's go left to right.
I think you guys are right.

00:27:20.740 --> 00:27:27.400
I think it is supposed
to swipe left to right.

00:27:28.380 --> 00:27:31.615
There you go, nice catch. Thank you.

00:27:31.615 --> 00:27:35.470
The joy the voting on it and none
of you are asleep, this is good.

00:27:35.470 --> 00:27:37.090
I hate doing sessions
after lunch because

00:27:37.090 --> 00:27:39.860
I'm always sure that
everyone's half-asleep.

00:27:41.010 --> 00:27:44.065
The other thing that I did
here was I started putting

00:27:44.065 --> 00:27:46.330
a sample of how a function
would look like,

00:27:46.330 --> 00:27:48.790
but I over-complicated things myself.

00:27:48.790 --> 00:27:50.500
This is literally just doing

00:27:50.500 --> 00:27:53.570
a string query match
to what's in here.

00:27:53.790 --> 00:27:56.890
Another thing I like to
usually do is since like I

00:27:56.890 --> 00:27:59.380
said the initial setup
is just the pages,

00:27:59.380 --> 00:28:01.900
and the quickest way
to find elements on

00:28:01.900 --> 00:28:05.190
a page I App.flash everything,

00:28:05.190 --> 00:28:07.695
it's my favorite thing in here.

00:28:07.695 --> 00:28:11.470
Since I wanted to just tap
on that Settings button,

00:28:12.050 --> 00:28:15.215
if I just add.Flash settings,

00:28:15.215 --> 00:28:18.160
I can just figured out- it's
got two settings buttons,

00:28:18.160 --> 00:28:21.920
I just need to make it go, do.

00:28:22.830 --> 00:28:25.705
That's my exact Settings
button, that's it.

00:28:25.705 --> 00:28:28.375
If you just spend a little bit of
time and just keep doing this,

00:28:28.375 --> 00:28:30.775
it makes setting of
this pages super fast.

00:28:30.775 --> 00:28:33.160
Also, most cases if
you're the one who's

00:28:33.160 --> 00:28:35.440
written the app you know
what automation ID you

00:28:35.440 --> 00:28:37.465
attached in Xamarin Forms or

00:28:37.465 --> 00:28:40.540
what name on accessibility
ID you provided.

00:28:40.540 --> 00:28:42.700
So you would most probably
know the query already.

00:28:42.700 --> 00:28:44.260
It should be super super fast,

00:28:44.260 --> 00:28:47.245
and super intuitive
once you get into it.

00:28:47.245 --> 00:28:50.814
I'm going to go grab this,

00:28:50.814 --> 00:28:52.660
and I'm going to change this because

00:28:52.660 --> 00:28:54.550
it doesn't need to
be this complicated.

00:28:54.550 --> 00:29:01.255
This can literally just be a string
and it can just live here.

00:29:01.255 --> 00:29:03.830
Then I'm going to use,

00:29:05.460 --> 00:29:07.690
I did not pull that in today,

00:29:07.690 --> 00:29:09.800
no, it's right here, okay.

00:29:17.450 --> 00:29:24.105
No, doesn't make it,
well, okay, hold on.

00:29:24.105 --> 00:29:26.830
I'm going to do a
little bit of fudging here.

00:29:30.770 --> 00:29:35.320
I want to show off
how to write those.

00:29:37.520 --> 00:29:40.125
Okay. This looks good.

00:29:40.125 --> 00:29:47.140
Let's change you, and
let's change you.

00:29:49.580 --> 00:29:53.010
I need my query again.

00:29:53.010 --> 00:29:57.040
So I'm going to go back in
here. So this was the query.

00:30:00.800 --> 00:30:03.060
What do I need in here?

00:30:03.060 --> 00:30:10.270
So I'm going to just
make this settings.

00:30:16.040 --> 00:30:18.120
Actually, I don't even

00:30:18.120 --> 00:30:20.400
need that anymore, now
that I think about it.

00:30:20.400 --> 00:30:23.205
I can just come in and do this,

00:30:23.205 --> 00:30:29.580
throw in my Lambda check
right in here.

00:30:29.580 --> 00:30:33.900
So makes of element this,
"Tap" on element this.

00:30:33.900 --> 00:30:36.420
Okay. So this for now,

00:30:36.420 --> 00:30:42.030
we'll just open up the settings menu,

00:30:42.030 --> 00:30:44.265
just because I don't want
to waste everyone's time,

00:30:44.265 --> 00:30:45.165
and we're getting close.

00:30:45.165 --> 00:30:49.455
So let's get this set up here.

00:30:49.455 --> 00:30:52.660
Okay, great.

00:30:53.900 --> 00:30:56.290
What's wrong?

00:31:02.450 --> 00:31:05.700
So I called it.

00:31:05.700 --> 00:31:09.510
"SelectMenuItem" but I don't
give it a value right now.

00:31:09.510 --> 00:31:12.490
Okay. Let's do this.

00:31:14.330 --> 00:31:17.100
Is it still running?

00:31:17.100 --> 00:31:21.525
Okay. So always remember to kill
the app which I forget to do.

00:31:21.525 --> 00:31:24.090
So let's get this going.

00:31:24.090 --> 00:31:31.680
I think this is the slowest part,

00:31:31.680 --> 00:31:33.165
just waiting for that launch.

00:31:33.165 --> 00:31:36.225
But apart from that,
it gets super fast.

00:31:36.225 --> 00:31:38.430
So what we're going to do now
very quickly is I'll just

00:31:38.430 --> 00:31:40.470
show you how to set a page up because

00:31:40.470 --> 00:31:44.520
that's usually all that you
need to understand on what's

00:31:44.520 --> 00:31:49.540
happening, and just understand.

00:31:51.860 --> 00:31:55.965
Let me guess, my index
is zero not one.

00:31:55.965 --> 00:31:58.200
Yes, my index is zero not one.

00:31:58.200 --> 00:32:03.580
Okay. Let's split.

00:32:04.160 --> 00:32:08.160
There we go. What I want to
verify it's a slide one, two.

00:32:08.160 --> 00:32:11.280
Okay. It will come in to this page.

00:32:11.280 --> 00:32:13.905
But what we're going to
actually write the test for,

00:32:13.905 --> 00:32:16.290
I want to test for that
now playing screen.

00:32:16.290 --> 00:32:22.150
So let's try this.

00:32:23.030 --> 00:32:26.140
Let's go in here.

00:32:32.330 --> 00:32:38.710
OpenNowPlaying and when I
open up a Repl on that page.

00:32:42.650 --> 00:32:46.515
Okay. So while that's launching,

00:32:46.515 --> 00:32:49.095
how would you start with a new page?

00:32:49.095 --> 00:32:54.120
"Add new page". So let's
call it the NowPlayingPage.

00:32:54.120 --> 00:32:57.270
Everybody good to learn. This
is what everyone would do.

00:32:57.270 --> 00:33:00.749
Next step, we're going to
inherit from BasePage,

00:33:00.749 --> 00:33:02.010
but then it's going to be like, "No,

00:33:02.010 --> 00:33:03.435
you need to have the platform query."

00:33:03.435 --> 00:33:06.490
Okay. Throw in the platform query.

00:33:09.530 --> 00:33:13.560
So it's up on my page
and it's ready to go.

00:33:13.560 --> 00:33:17.310
So we can put this back here,

00:33:17.310 --> 00:33:18.990
get the font up for this.

00:33:18.990 --> 00:33:21.750
Okay. So usually what I do is,

00:33:21.750 --> 00:33:25.980
I never remember how the platform
trait and stuff looks like.

00:33:25.980 --> 00:33:30.645
I go and open in a sample or I
just go into already made page.

00:33:30.645 --> 00:33:34.515
I decide to copy this over
because I like to cheat.

00:33:34.515 --> 00:33:39.030
So under this command
here put this in here.

00:33:39.030 --> 00:33:40.980
All right. All you have to
do now is come in and just

00:33:40.980 --> 00:33:43.395
change up the trait values
per platform.

00:33:43.395 --> 00:33:46.290
So let's see what it
could be for iOS.

00:33:46.290 --> 00:33:49.150
So let's see what we have here.

00:33:49.700 --> 00:33:53.745
We have a bunch of screens.

00:33:53.745 --> 00:33:55.890
But I do have the page ID that says

00:33:55.890 --> 00:33:58.050
NowPlayingPage which is promising.

00:33:58.050 --> 00:33:59.310
So I'm going to grab this.

00:33:59.310 --> 00:34:03.490
So for iOS, I'm going to
put this as a page trait.

00:34:06.250 --> 00:34:10.120
That's quit are here.

00:34:10.120 --> 00:34:13.020
I'm going to pull up Android,

00:34:13.020 --> 00:34:18.510
and let's do the same
thing for Android.

00:34:18.510 --> 00:34:21.855
So Android settings.

00:34:21.855 --> 00:34:25.120
Let me just run this test.

00:34:25.250 --> 00:34:27.890
So initial setup.

00:34:27.890 --> 00:34:30.320
I'm not just doing literally
what I will do if I was doing

00:34:30.320 --> 00:34:32.960
this on my own at my desk.

00:34:32.960 --> 00:34:34.430
So the first step I'd come in,

00:34:34.430 --> 00:34:35.690
launch this a couple of times,

00:34:35.690 --> 00:34:38.045
get all the page traits done.

00:34:38.045 --> 00:34:40.900
Once I have the page trait values,

00:34:40.900 --> 00:34:42.810
I need to fix this
for Android clearly,

00:34:42.810 --> 00:34:43.935
it's not swiping up right.

00:34:43.935 --> 00:34:48.405
But a tree in here,

00:34:48.405 --> 00:34:51.850
let's see what's going on
in Android. Let's see.

00:34:51.890 --> 00:34:55.830
So there's the label.
Because I come back up.

00:34:55.830 --> 00:35:00.330
Okay. So there's MiniPlayer,
there's CurrentSong, CurrentArtist.

00:35:00.330 --> 00:35:02.280
I see an opening page again.

00:35:02.280 --> 00:35:05.910
So let's just borrow
the same thing for both.

00:35:05.910 --> 00:35:09.180
Now that that's set up,
we can start putting in

00:35:09.180 --> 00:35:12.270
some values for elements
on that screen.

00:35:12.270 --> 00:35:17.235
So again go back, let's grab
the using alias for this.

00:35:17.235 --> 00:35:20.265
NowPlayingPage, let's
come in here. All right.

00:35:20.265 --> 00:35:23.370
So the NowPlayingPage has
a bunch of buttons that I see.

00:35:23.370 --> 00:35:26.460
So let's see what's going on here.

00:35:26.460 --> 00:35:28.710
So there's the "Play" button,

00:35:28.710 --> 00:35:30.180
there's the up and thumbs up,

00:35:30.180 --> 00:35:33.180
thumbs down, there's
the "MiniPlayer".

00:35:33.180 --> 00:35:36.360
What I'm going to try and attempt is,

00:35:36.360 --> 00:35:38.370
let's see if you can get
into the "Shuffle" button.

00:35:38.370 --> 00:35:40.650
So that's this button over here.

00:35:40.650 --> 00:35:42.630
So there's shuffle,
there's repeat play.

00:35:42.630 --> 00:35:45.210
Right. Now if you notice this
is another issue I've seen.

00:35:45.210 --> 00:35:48.075
So you may not always have
control over the source code,

00:35:48.075 --> 00:35:49.350
and you may not always
be able to go in

00:35:49.350 --> 00:35:50.640
there and add automation IDs,

00:35:50.640 --> 00:35:53.055
or add physical names for things.

00:35:53.055 --> 00:35:54.900
So for example, if I look in here,

00:35:54.900 --> 00:35:58.125
all I get to see is
the bottom grids control.

00:35:58.125 --> 00:36:02.280
I don't have any specific names
for any of those buttons being.

00:36:02.280 --> 00:36:04.440
I think that's a custom control
that glance is used.

00:36:04.440 --> 00:36:07.510
So I have no values for it.

00:36:07.610 --> 00:36:11.895
The best way to do it is
just keep drilling down.

00:36:11.895 --> 00:36:13.604
So I'm going to,

00:36:13.604 --> 00:36:15.060
let's query down from here.

00:36:15.060 --> 00:36:18.210
So this is called
the bottom grids control.

00:36:18.210 --> 00:36:22.395
So I'm going to look at what are
the children inside of it first.

00:36:22.395 --> 00:36:27.870
I guess I see one, two, three, four.

00:36:27.870 --> 00:36:29.400
Nope, there's a lot
of things in there.

00:36:29.400 --> 00:36:31.320
Okay. Let's flash these because I'm

00:36:31.320 --> 00:36:34.150
not sure what's in here,
there's so many things.

00:36:37.950 --> 00:36:41.890
Okay. One, two, three, four, okay.

00:36:41.890 --> 00:36:45.235
So to the bottom grid is
this whole bottom area,

00:36:45.235 --> 00:36:46.990
I don't need the whole bottom area.

00:36:46.990 --> 00:36:50.140
So I'm going to use the last child,

00:36:50.140 --> 00:36:53.650
and let's see what's
in the, there we go.

00:36:53.650 --> 00:36:55.450
We're getting closer now, right?

00:36:55.450 --> 00:37:00.780
So it's not always going to
be a happy case where you can

00:37:00.780 --> 00:37:02.880
write those perfect IDs
and you know maintain

00:37:02.880 --> 00:37:06.765
a perfect unique set of identifiers
for element on the screen.

00:37:06.765 --> 00:37:08.790
I wouldn't get too decided on that.

00:37:08.790 --> 00:37:11.790
Having anything and
getting just basic tests

00:37:11.790 --> 00:37:13.470
going is a lot more important than

00:37:13.470 --> 00:37:15.545
trying to find unique IDs
for any element.

00:37:15.545 --> 00:37:17.740
So as long as the test doesn't break,

00:37:17.740 --> 00:37:20.530
it's a little brittle at this point
I would agree but then that's

00:37:20.530 --> 00:37:23.470
when you can take this test and
show it to the Team and be like,

00:37:23.470 --> 00:37:25.315
"Hey, this is really useful."

00:37:25.315 --> 00:37:27.115
Let's start adding,

00:37:27.115 --> 00:37:28.390
the fact that these are going to be

00:37:28.390 --> 00:37:29.770
tested and let's be more mindful,

00:37:29.770 --> 00:37:31.660
add more names to
these things in the future.

00:37:31.660 --> 00:37:33.280
So let's come in.

00:37:33.280 --> 00:37:35.425
I think that was the second button,

00:37:35.425 --> 00:37:38.020
it's going to verify. Yup. That's it.

00:37:38.020 --> 00:37:42.055
So the next step literally would be,

00:37:42.055 --> 00:37:44.080
I can just go in here.

00:37:44.080 --> 00:37:46.090
This is where the beauty
comes in, right?

00:37:46.090 --> 00:37:49.270
So this is, so let's call it.

00:37:49.270 --> 00:37:58.040
So there is the Shuffle Button
and there is, let's go.

00:37:59.460 --> 00:38:02.395
What was at the Repeat Button?

00:38:02.395 --> 00:38:04.150
They're kind of next door
to each other, right?

00:38:04.150 --> 00:38:06.550
So let's optimize setting this up.

00:38:06.550 --> 00:38:09.430
So this is where you initialize

00:38:09.430 --> 00:38:13.435
the queries for
each control on the page.

00:38:13.435 --> 00:38:18.235
So this is where the cross platform
part of page object plays in.

00:38:18.235 --> 00:38:21.310
If the query is the
same on both platforms,

00:38:21.310 --> 00:38:23.395
this current one is a great example.

00:38:23.395 --> 00:38:25.600
I don't think it's going to be
the same on each just because we

00:38:25.600 --> 00:38:28.240
had to go through like
the bed and child of a thing,

00:38:28.240 --> 00:38:32.230
and UI layouts within iOS and
Android can be a little different.

00:38:32.230 --> 00:38:33.700
So this is a good candidate than not.

00:38:33.700 --> 00:38:36.940
This is probably not going
to be a shared value,

00:38:36.940 --> 00:38:39.730
but something like
the Now Playing trade.

00:38:39.730 --> 00:38:41.320
Since it's the same
on both platforms,

00:38:41.320 --> 00:38:43.105
you could just literally
come in just go like

00:38:43.105 --> 00:38:46.405
Shuffle Button and then just
drop the query in here,

00:38:46.405 --> 00:38:47.710
and that just means that oh use

00:38:47.710 --> 00:38:50.005
the same query value
for what platforms.

00:38:50.005 --> 00:38:52.450
But if it's different for each,

00:38:52.450 --> 00:38:53.875
let's just separate it out.

00:38:53.875 --> 00:38:56.875
So if on both platform,

00:38:56.875 --> 00:38:58.885
how you'll do to have

00:38:58.885 --> 00:39:00.460
certain different settings in iOS and

00:39:00.460 --> 00:39:02.575
Android and firms similar concept.

00:39:02.575 --> 00:39:05.065
So this is what the
Shuffle Button looks like,

00:39:05.065 --> 00:39:08.725
and we have the Repeat Button

00:39:08.725 --> 00:39:12.955
and the index of that
was just though,

00:39:12.955 --> 00:39:14.410
I think I swapped out the index.

00:39:14.410 --> 00:39:17.935
So this is one, this is
two, [inaudible] boom.

00:39:17.935 --> 00:39:20.560
That's it. Okay. You
could at this point

00:39:20.560 --> 00:39:23.725
actually just continue and
put down the page methods.

00:39:23.725 --> 00:39:26.650
So like for this page
and Now Playing,

00:39:26.650 --> 00:39:34.790
this will be press
say Shuffle Button.

00:39:36.720 --> 00:39:40.915
I'm going to return this,

00:39:40.915 --> 00:39:42.940
only because this is
an action that's not

00:39:42.940 --> 00:39:44.695
navigating near way out of this page.

00:39:44.695 --> 00:39:46.150
I'm going to stay and I can

00:39:46.150 --> 00:39:48.670
continue doing
more things on this page.

00:39:48.670 --> 00:39:51.370
After this I can go and
click that comes up button.

00:39:51.370 --> 00:39:53.050
I can go click the share button.

00:39:53.050 --> 00:39:55.255
I can go click the ellipsis button.

00:39:55.255 --> 00:39:57.310
So this is what I was

00:39:57.310 --> 00:39:59.290
talking about before actions
that stay on the page,

00:39:59.290 --> 00:40:00.865
make it return the page type itself.

00:40:00.865 --> 00:40:03.325
Because when you write a test,

00:40:03.325 --> 00:40:06.460
it can string along.

00:40:06.460 --> 00:40:08.320
So another good thing
I like to do is,

00:40:08.320 --> 00:40:10.210
I always like to wait
for an element to

00:40:10.210 --> 00:40:12.775
appear before I do any action on it.

00:40:12.775 --> 00:40:16.510
It's just like assertive
true or assertive visible,

00:40:16.510 --> 00:40:17.680
but I just try to use weight for

00:40:17.680 --> 00:40:19.390
element just because
it has a built in

00:40:19.390 --> 00:40:22.870
retry mechanism already
baked into it from UI test.

00:40:22.870 --> 00:40:25.720
Makes it super nice.
Makes my test feel a

00:40:25.720 --> 00:40:28.915
little more like I feel
better about it before.

00:40:28.915 --> 00:40:30.760
Just to make sure the element
has actually been

00:40:30.760 --> 00:40:33.115
rendered on the screen
before I tap on it.

00:40:33.115 --> 00:40:37.690
So let's just to see what was at

00:40:37.690 --> 00:40:43.450
guard Press Repeat because

00:40:43.450 --> 00:40:45.760
I want to show you what
the stringing of tests look like.

00:40:45.760 --> 00:40:48.085
So let's return this.

00:40:48.085 --> 00:40:53.720
Again, app.WaitFor Repeat Button,

00:40:54.120 --> 00:41:00.805
and app.Tap Repeat Button.

00:41:00.805 --> 00:41:04.825
All right. So now do
I have this ready?

00:41:04.825 --> 00:41:08.020
The next step literally
left to do would be I'd

00:41:08.020 --> 00:41:10.480
relaunch a Repl again
but for iOS this time,

00:41:10.480 --> 00:41:12.670
and all I will do
for iOS it is go and

00:41:12.670 --> 00:41:15.265
find the queries for
those two buttons.

00:41:15.265 --> 00:41:17.260
That's it, my page is set up.

00:41:17.260 --> 00:41:19.240
That's all you have to
do. So this is just

00:41:19.240 --> 00:41:20.860
all the initial buy-in that you need.

00:41:20.860 --> 00:41:22.330
This is all the time you'd spend

00:41:22.330 --> 00:41:23.815
the first time just setting these up,

00:41:23.815 --> 00:41:25.120
and after they're
super-simple because

00:41:25.120 --> 00:41:26.725
now what I'm going to go add a test.

00:41:26.725 --> 00:41:28.240
Let's add a brand new test.

00:41:28.240 --> 00:41:32.630
So let's call it now blink test.

00:41:32.640 --> 00:41:37.180
I'm going to come in here,

00:41:37.180 --> 00:41:38.890
add in the BaseTestFixture.

00:41:38.890 --> 00:41:43.130
This needs platform.

00:41:44.430 --> 00:41:49.760
Going to, add this in,

00:41:50.310 --> 00:41:54.640
platform, boom. That's it.

00:41:54.640 --> 00:41:56.950
You're set up. To write a test,

00:41:56.950 --> 00:41:58.930
let's put in a test tag,

00:41:58.930 --> 00:42:00.940
doesn't have N unit in here.

00:42:00.940 --> 00:42:02.890
So let's pull in N unit, after that.

00:42:02.890 --> 00:42:07.105
So public void. Let's call it,

00:42:07.105 --> 00:42:12.760
XamDevSummitTest because I am
great with names. All right.

00:42:12.760 --> 00:42:16.000
So coming to the new homepage,

00:42:16.000 --> 00:42:18.970
and then you want to
go open Now Playing.

00:42:18.970 --> 00:42:22.240
Boom, that's it. That's
my first action. Next thing.

00:42:22.240 --> 00:42:23.560
Now that I've opened Now Playing,

00:42:23.560 --> 00:42:24.730
I'm on the Now Playing page.

00:42:24.730 --> 00:42:28.690
So new Now Playing Page. What was it?

00:42:28.690 --> 00:42:32.890
So let's press Repeat and then
I want keep doing actions,

00:42:32.890 --> 00:42:38.020
and then I'm going to press
the Shuffle Button. That's it.

00:42:38.020 --> 00:42:41.740
So your UI test like sort of
flowing and going and running in

00:42:41.740 --> 00:42:46.510
through and maintaining it

00:42:46.510 --> 00:42:48.520
now moving forward,
just think about it.

00:42:48.520 --> 00:42:50.050
If you come back after a couple of

00:42:50.050 --> 00:42:52.240
days or a couple of months
and you read this test,

00:42:52.240 --> 00:42:53.320
you're like, "Oh okay,

00:42:53.320 --> 00:42:55.510
yes I'm testing the
functionality for the states.

00:42:55.510 --> 00:42:57.940
Nothing is ambiguous. Nothing
is weird, it all make sense.

00:42:57.940 --> 00:43:02.800
It's readable." Yeah. So it's
a framework that we use quite a bit.

00:43:02.800 --> 00:43:05.290
It's popular withing
my team and we've had

00:43:05.290 --> 00:43:08.200
some good feedback sharing
it with other people.

00:43:08.200 --> 00:43:12.475
So that's how literally
implementing it looks like.

00:43:12.475 --> 00:43:14.935
What did I have left to show?

00:43:14.935 --> 00:43:17.485
Okay, yeah. So I want to
quickly go back here.

00:43:17.485 --> 00:43:19.600
I covered a lot of it right now
when I was talking about it,

00:43:19.600 --> 00:43:23.815
but just other useful UI Test Tips.

00:43:23.815 --> 00:43:25.570
Again test on Real Devices like I am

00:43:25.570 --> 00:43:28.135
right now, it's super helpful.

00:43:28.135 --> 00:43:30.370
If you put breakpoints in your tests

00:43:30.370 --> 00:43:32.215
and you're wondering how
to hit those breakpoints.

00:43:32.215 --> 00:43:34.000
So if you just double-click
and run a test,

00:43:34.000 --> 00:43:35.380
it won't hit those.

00:43:35.380 --> 00:43:37.330
You right-click and do debug,

00:43:37.330 --> 00:43:39.760
and it's then it'll start
hitting your breakpoints.

00:43:39.760 --> 00:43:41.590
I showed you the using statement.

00:43:41.590 --> 00:43:45.145
I showed you the test cases
and categories.

00:43:45.145 --> 00:43:50.410
This is just other best practices
that we tried to share,

00:43:50.410 --> 00:43:52.390
keeping it that each desolate

00:43:52.390 --> 00:43:54.580
independent within its status
is a good practice.

00:43:54.580 --> 00:43:57.370
Don't tie chain activities
because suppose one test fails,

00:43:57.370 --> 00:43:58.780
you don't want like
everything else to fail.

00:43:58.780 --> 00:44:01.540
You want some useful
information to come out.

00:44:01.540 --> 00:44:03.550
Be deterministic.

00:44:03.550 --> 00:44:06.580
You can put in back doors
which you can invoke into

00:44:06.580 --> 00:44:07.900
your apps for things like

00:44:07.900 --> 00:44:10.180
authentication or you want
to mark a data service.

00:44:10.180 --> 00:44:13.190
Back doors are
a great thing to look into.

00:44:13.200 --> 00:44:16.090
What else? Try not to loop.

00:44:16.090 --> 00:44:20.290
Use good assertions, so
assort elements are visible,

00:44:20.290 --> 00:44:21.430
weight that elements are visible,

00:44:21.430 --> 00:44:22.630
weight element's gone away.

00:44:22.630 --> 00:44:24.850
[inaudible] are great for animations.

00:44:24.850 --> 00:44:26.290
So if you have
a transition animation,

00:44:26.290 --> 00:44:27.850
putting away it far and wait for

00:44:27.850 --> 00:44:30.040
no element is a great thing to use.

00:44:30.040 --> 00:44:32.320
Avoid Thread.Sleeps.

00:44:32.320 --> 00:44:34.015
That's the worst thing you could.

00:44:34.015 --> 00:44:35.650
Do not put Thread.Sleeps.

00:44:35.650 --> 00:44:38.380
Again, just be careful if you loop.

00:44:38.380 --> 00:44:40.495
Looping is not your friend.

00:44:40.495 --> 00:44:42.220
So I went a little bit overtime,

00:44:42.220 --> 00:44:45.620
but I can quickly do
questions, so questions.

00:44:46.230 --> 00:44:49.510
Just go on ahead to the mic so

00:44:49.510 --> 00:44:51.120
that everyone else
online can hear you too.

00:44:51.120 --> 00:44:52.690
>> So when you mentioned backdoors,

00:44:52.690 --> 00:44:54.955
you would just then write
a method within your code?

00:44:54.955 --> 00:44:57.700
>> Yes, exactly. So you
want to keep those for iOS,

00:44:57.700 --> 00:44:58.945
put them in app delegate

00:44:58.945 --> 00:45:01.420
and on Android putting
your main activity,

00:45:01.420 --> 00:45:03.430
and then you can invoke
that same string name

00:45:03.430 --> 00:45:06.470
in your test and you can
do whatever you want.

00:45:06.540 --> 00:45:09.070
>> So for the reports,

00:45:09.070 --> 00:45:12.280
is there any future plans to
making a visualizer like it,

00:45:12.280 --> 00:45:14.575
like we have for XML tree?

00:45:14.575 --> 00:45:16.780
>> Let's talk about it.
Come and meet me at

00:45:16.780 --> 00:45:18.670
the booth and I love to hear ideas.

00:45:18.670 --> 00:45:21.670
I've heard this feedback
and I love to know

00:45:21.670 --> 00:45:22.780
more and we can look into

00:45:22.780 --> 00:45:24.895
something about doing
something like that, yeah.

00:45:24.895 --> 00:45:27.220
>> Another one into your base page,

00:45:27.220 --> 00:45:29.665
you did return this.

00:45:29.665 --> 00:45:31.630
Always return the page wrong.

00:45:31.630 --> 00:45:34.420
So don't we have to wait for it?

00:45:34.420 --> 00:45:37.630
So if you're doing data loading
and your spinner is up before,

00:45:37.630 --> 00:45:38.860
we go into the page, do we have

00:45:38.860 --> 00:45:40.150
to do something for that especially?

00:45:40.150 --> 00:45:44.095
>> Yes. So you can totally
throw it in that base page.

00:45:44.095 --> 00:45:45.850
That was just one way
of using the base page.

00:45:45.850 --> 00:45:47.110
I just want to highlight the power of

00:45:47.110 --> 00:45:48.730
having shared methods in there.

00:45:48.730 --> 00:45:51.310
You can actually just write
an extension or like a helper,

00:45:51.310 --> 00:45:52.540
and then put something like,

00:45:52.540 --> 00:45:53.950
you know you're
expecting an animation.

00:45:53.950 --> 00:45:55.990
So just be like, hey, wait
for the spinner to go away.

00:45:55.990 --> 00:45:57.415
So wait for no element,

00:45:57.415 --> 00:46:00.820
and put in the ID to the spinner
or just use the spinner class,

00:46:00.820 --> 00:46:02.890
and then just verify
that the spinner has

00:46:02.890 --> 00:46:05.050
gone away and then start
doing your actions. Yeah.

00:46:05.050 --> 00:46:07.995
>> Yeah. One last question maybe
it's not really in your area,

00:46:07.995 --> 00:46:09.360
but you take screenshots.

00:46:09.360 --> 00:46:11.070
Is there anything that you can do

00:46:11.070 --> 00:46:15.075
for matching screenshots
with previous tests like,

00:46:15.075 --> 00:46:16.650
because if you're doing UI,

00:46:16.650 --> 00:46:18.120
you want to know that
your elements are

00:46:18.120 --> 00:46:20.160
still on-screen
instead of off-screen,

00:46:20.160 --> 00:46:22.995
I don't know if you can
do that in the reports.

00:46:22.995 --> 00:46:25.575
>> No, not right now.

00:46:25.575 --> 00:46:29.440
Again, I've heard of people
wanting a tool that could do that.

00:46:29.440 --> 00:46:30.895
I think it's a great idea too.

00:46:30.895 --> 00:46:32.605
Only thing I can think of is,

00:46:32.605 --> 00:46:34.975
if you upload these tests
to App Center,

00:46:34.975 --> 00:46:36.685
it generates those reports for you.

00:46:36.685 --> 00:46:38.200
It'll be like a manual check though

00:46:38.200 --> 00:46:39.910
there's no automated way to do it.

00:46:39.910 --> 00:46:42.370
Maybe you can use cognitive services
and build that tool,

00:46:42.370 --> 00:46:43.895
and I'd love to help you with it.

00:46:43.895 --> 00:46:44.490
>> All right. Thank you.

00:46:44.490 --> 00:46:44.990
>> Yeah.

00:46:44.990 --> 00:46:48.790
>> Hi, I noticed that in
one of your tests you

00:46:48.790 --> 00:46:52.630
had a drag method with
some hard-coded Kubernetes.

00:46:52.630 --> 00:46:52.900
>> Yeah.

00:46:52.900 --> 00:46:54.100
>> Is that going to give you problems

00:46:54.100 --> 00:46:55.180
on different size to [inaudible]?

00:46:55.180 --> 00:46:57.565
>> It totally is and
not the recommended way to do it.

00:46:57.565 --> 00:46:59.875
It was just for this demo,
I just wanted to swipe.

00:46:59.875 --> 00:47:01.090
I didn't even swipe that well,

00:47:01.090 --> 00:47:05.350
but the ideal way to actually
do that is again query

00:47:05.350 --> 00:47:07.390
to that element and use
x and y coordinates

00:47:07.390 --> 00:47:09.880
because that's a mini player
and I have the ID for it.

00:47:09.880 --> 00:47:11.770
So you should in
good practice be doing that,

00:47:11.770 --> 00:47:14.140
and that's what I'll be
doing for the actual code.

00:47:14.140 --> 00:47:15.790
I want to PR this into Clancy,

00:47:15.790 --> 00:47:17.785
clean this up, make it look nicer.

00:47:17.785 --> 00:47:20.560
Please go in and have a look
at that and give me feedback

00:47:20.560 --> 00:47:23.140
or just go in and contribute
more code in there. So yeah.

00:47:23.140 --> 00:47:24.310
>> Thank you.

00:47:24.310 --> 00:47:27.100
>> So and there's actually I
think in my correctors are

00:47:27.100 --> 00:47:29.500
like a swipe to feature
where you can put in.

00:47:29.500 --> 00:47:31.015
So you make sure you swipe to it.

00:47:31.015 --> 00:47:32.170
>> Yeah, you can swipe to it.

00:47:32.170 --> 00:47:34.165
You can swipe tool,

00:47:34.165 --> 00:47:36.370
takes in or you can put
on an element you want to

00:47:36.370 --> 00:47:39.010
target to or like an x and y
coordinate you want to go to.

00:47:39.010 --> 00:47:43.255
Yep. Okay, just like
two more questions I think yeah.

00:47:43.255 --> 00:47:44.830
>> We often find that
when we're recording

00:47:44.830 --> 00:47:47.485
UI tests require timeouts,

00:47:47.485 --> 00:47:48.820
that they work great on

00:47:48.820 --> 00:47:50.950
local machines and
our build server but they

00:47:50.950 --> 00:47:56.185
felt continuously absent or
is there a way around that?

00:47:56.185 --> 00:47:58.105
>> Let's- come meet me at the booth.

00:47:58.105 --> 00:48:00.325
I love to see what exactly
is going on. Yeah.

00:48:00.325 --> 00:48:05.800
>> Is Xamarin UI Tests as
Framework actively maintained-

00:48:05.800 --> 00:48:06.130
>> Yes.

00:48:06.130 --> 00:48:08.035
>> -because I've
heard something else.

00:48:08.035 --> 00:48:10.495
>> No, it is being
actively worked on.

00:48:10.495 --> 00:48:12.985
It just updated to UI Test

00:48:12.985 --> 00:48:16.570
3.0 because now we have
NUnit Support 3.0.

00:48:16.570 --> 00:48:18.520
So yes, they are actively
working on it. Yeah.

00:48:18.520 --> 00:48:19.015
>> Thank you.

00:48:19.015 --> 00:48:21.565
>> Okay. That's all questions
I can take right now.

00:48:21.565 --> 00:48:22.660
I'll be at the booth,

00:48:22.660 --> 00:48:23.980
so please come and find me and

00:48:23.980 --> 00:48:25.585
ask me all other questions
that you have.

00:48:25.585 --> 00:48:28.240
I'd love to look at any UI Test Code
that you need help,

00:48:28.240 --> 00:48:30.320
but thank you so much.

