Transcripted Summary

Let's go ahead and jump into some code.

I want to show you some actual baseline examples and how they look in Applitools.

One thing I do want to mention is I actually have been designing this code to be as clean as possible so that you can see real alive best practices when it comes to test automation and the visual validation using Applitools. They're not some real dirty examples that I just came up with.

There are actually best practices that are applied here such as don't repeat yourself principal, where I've been removing a lot of duplication and creating a lot of viewer usability and stuff like that.

I didn't use the Page Object pattern with Selenium, which I normally would use, but that's to keep everything as basic and as transparent as possible. But the rest of the stuff here that you see are best practices and something that I would actually do in real life.

So, keep in mind and you can use these for yourself to get started much quicker.

Let's proceed.

Anyway, which you can see here is I've actually created a namespace called “Applitools”.

And I've created a TestFixture, which is name unit attribute that tells us that this class is a test class and I've created a Category to help me better differentiate.

Then I've created this class called BaselineExamples that inherits from BaseClass.

Inside of our class we have a couple properties.

This constant property is something we're calling an AppName and I've provided this a String right here (“sample app 1”).

Then we have this other property, which is called the TestCaseName and I've provided it this test case name right here called “Test1”.

Over here you have an automated test case and this automated test case is called a SetBaselineUsingAppName.

What you're going to see in here is that we're going to a pricing page (GoToPricingPage).

If I peek at this definition and scroll down a bit, you can see that this is a very simple method.

All it does is use Selenium WebDriver to navigate to this URL right here. This URL is what we're going to be using for a bunch of our Applitools videos. The reason why I created this method so that I can reuse this method and know exactly where I'm going to navigate to.

So, after we go to the page down here, we are using Applitools Eyes to do an open method — Eyes.Open.

Open method basically starts the test in Applitools.

We're passing 4 different parameters in this case.

  • We're passing in a driver, which is mandatory.

  • We're passing in an app name. An app name, you can see comes from up here.

  • We're passing in a test case name, which you can see comes from up here. It's called test one.

  • Then we're passing in a resolution 1080p.

Resolution is something I'm actually storing in the BaseClass as well. Let me show you that.

So, you can see that I'm storing resolution 1080p and it basically returns a new object of type Size that is in the 1080p resolution. So rather than passing this String around, I just stored it in 2 properties and now I can use these properties wherever I need for my test automation.

So, we open Applitools test case starting right here. Then we're going to use the Applitools CheckWindow method that is going to do all of the complicated logic and to visually validate that our automated test matches of what is expected.

Now that you know how this first test case works, I want you to take a look at the other tests that I have written.

They are all going to be very similar. As you can see over here, they're all going to a pricing page. You can see that right away all of this gets highlighted.

They all use Eyes.Open but the difference is what I wanted to show you here is how we create a different baseline and that's exactly why I created these tests.

So over here, you can see that we have all the same exact parameters as before, but we're passing in a different app name.

As a result, what that's going to do is create a brand-new baseline.

Down here, everything is exactly the same.

You can see with all the same parameters. However, we're passing in a brand-new test case name.

And finally, at the bottom, everything is the same except the 720p resolution as opposed to the 1080p resolution.

So, what does this mean for you based on everything that I have taught you about baselines?

Well, it means that every single test here is going to create a brand-new baseline because we're setting totally different parameters.

Now the browser and the operating system, I can't control. I'm running on a Windows 10 and Chrome. So that's why those parameters are basically staying static unless I'm running on a different browser. But those parameters are staying static, but these are the parameters that I told you we have control over.


© 2024 Applitools. All rights reserved. Terms and Conditions Privacy Policy GDPR