Placeholder Image

字幕列表 影片播放

  • Hi, everyone.

  • I'm a developer, advocated aptly tools, and we're gonna talk about visual validation today.

  • But first, we're gonna play a little game off.

  • Who done it clearly?

  • Somebody in this room murdered Lord Smythe, who at precisely 3 34 this afternoon was brutally bludgeoned to death with a blunt instrument.

  • I want each of you to tell me your whereabouts.

  • At precisely the time that this dastardly deed took place, I was polishing the brass in the master bedroom.

  • I was buttering his lordship's scones below stairs.

  • But I was planting my petunias in the potting shed.

  • Constable, arrest later smiles.

  • But But how did you know, madam?

  • As any horticulturist will tell you, one does not plant petunias until May is out.

  • Take her away.

  • It's just a matter of observation.

  • The real question is how observant were you?

  • What?

  • Clearly, somebody in this room murdered Lord smile who at precisely 3 34 this afternoon was brutally bludgeoned to death with a blunt instrument.

  • I want each of you to tell me your whereabouts.

  • On precisely the time that this dastardly deed took place, I was polishing the brass in the master.

  • I was buttering his lordship's scones below stairs.

  • But I was planting my petunias in the potting shed.

  • Constable, arrest Lady Smythe.

  • I can't believe you all let a dead man get up and walk away.

  • But actually, I can't believe it, because we all suffer from what's called in intentional blind.

  • This is where you're so focused on a specific task that you miss other things new and unexpected, that might come into your vision.

  • And this happens a lot when we're developing our code and we do these little quick.

  • I was about to curse these little quick, uh, half effort tests on, and we missed a lot of what else is going on in our application, right?

  • So how do we sell for this?

  • We usually try to automate these tests.

  • It's not relying on us.

  • And when we automate the test and we're making sure that every time that test runs has taken the exact same steps and it is verifying the exact same things and that sounds really good and predictable, right?

  • What if I told you you were actually coding in, but an intentional blindness was all scripts a worse than we are Onley looking at the being that we told it to look at.

  • And it misses anything that we didn't specifically think of to code in.

  • For example, what about if you're text is on the screen and you want to verify that this text is there, right?

  • So you write some cold and it verifies that it's there.

  • But what if that text was bleeding off the edge of the page?

  • You see this all the time on mobile views?

  • What about it?

  • That text was covered by another element, so your user couldn't even see it.

  • What about if it was the same color as the background and again your user couldn't see?

  • All of these things will be missed with our traditional assertions.

  • And this isn't one off type things that happens all the time.

  • Now that I'm aware of visual testing, I see these visual bugs everywhere and some of your abs.

  • Here's an example.

  • This is in a world.

  • This is the world's second largest cinema chain.

  • They had a visual bug on the page that actually, if you would like to store your credit card information now, if you saw this in your app, you probably would wouldn't think It was a big bug, you know?

  • But how many of you in here would actually Who are your credit card?

  • And for me?

  • Exactly.

  • No one.

  • No hands worry.

  • The reason for that is because you look at this and you think if they didn't even see this, I'm not convinced that they're testing the back end.

  • And that's something.

  • Actually holds my private data.

  • Right.

  • So engagement here would go really low.

  • Now, your test, as written today will probably pay because it is looking Thio.

  • See if those labels air There's already a little buttons or there it can click things functionally.

  • This works, right?

  • So this gives the pool it and some production.

  • And you miss this type of thing.

  • This is open table.

  • How many people use open table, Make reservations?

  • Yes, I was going to Riley, and they're famous for their barbecue.

  • So I wanted to make a dinner reservation at my favorite place there with some of my friends.

  • Seven people, this reservation.

  • So I went to click a time that I wanted in this motel popped up.

  • I was a little bit confused at first because there was nothing in the center there.

  • I didn't know what I was supposed to be doing.

  • As I looked around, I noticed in the upper right corner those two buttons say select.

  • So I scratch my head a bit.

  • Okay.

  • What are these buttons?

  • One wire there.

  • Two of them.

  • To where?

  • They're not a line in three.

  • What am I selected again?

  • And so I did what any of you would do.

  • I opened Chrome Dev tools, began to dig around and figure out what were these buttons.

  • And actually, the labels were there.

  • They were just as far away from the buttons as possible Again.

  • We think that these people don't test they bear cold, but they might be tested it.

  • The tests were passed in this case because the tests are looking in the dom.

  • Right.

  • And all of this stuff is there.

  • It's present, functional, but ah, user cannot use this right.

  • And most of their users are not engineers who know about chrome depth tools and are gonna dig in the dom.

  • So this is money that's being lost.

  • These aren't one offs haven't so your favorite tech companies as well Amazon Someone not only wants to purchase something but they want to multiply the number of items of the amount of money they're going to spin.

  • And you have this cool feet book Facebook on their marketplace.

  • Paige, I'm going shopping.

  • I want to buy things.

  • I cannot even read the text again.

  • Your tests?

  • Yeah.

  • Texas Present Instagram.

  • This is my favorite one.

  • The reason this is my favorite one is because this is sponsored content.

  • Someone paid Instagram the show, their poles to people.

  • And it looks like this again.

  • Your test is this Takes President.

  • Yes, yes, yes.

  • And deploy Twitter.

  • All of the tweets are there the Texas present?

  • We can't read this.

  • This is very annoying.

  • The great news is that we don't have to live like this.

  • Visual testing can also be automated.

  • Now, what is visual testing?

  • It's where you take a screenshot of your application in the state that everything is perfect and as you want it.

  • And then on any regression runs it takes another screen shot and compares the two there.

  • Any differences?

  • It alerts you Now.

  • Visual testing is not something that it's very new.

  • It's been around for a while, but we, as an industry, were using some antiquated methods, but we were comparing them pixel by pixel, in making sure that the picture was exactly the same.

  • The problem with this is that pixel comparison is really flaky, not really designed for testing purposes.

  • For example, the top picture is a picture of my app.

  • One is in its perfect state.

  • The second picture is a regression run.

  • The regression run failed token, See walk.

  • The search button is bold here in the second picture, but not the first.

  • Well, if you put your mouth over the button, it bolds.

  • So if you were running this front and test and it just so happened that the mouse landed right there when the screen shot was taken.

  • Now you have a field field it another one who can't see why this one field her, sir, Though after the word bad, the cursor is solid in the first picture, but not in the sex, because cursors blank right?

  • So if you happen to take the picture in the split second, that is not the same then that feels so.

  • This became very, very annoying for people.

  • Capitals came out with ah Wei to do a visual validation that uses machine learning to be ableto only catch of the things that we would care about as human beings.

  • Here's another little spot.

  • The difference game.

  • You all don't get to play because you let the dead man walk away in the first game.

  • So I did it for you.

  • I ran this through the pics of the picks when I ran it through the Apple Tools bill with pictures of pixel.

  • You notice here pretty much everything is highlighted.

  • Very, very sensitive.

  • Even so, White space using this.

  • I can't really tell exactly what's different in those pictures versus using it with tablets, tools, spots, the things we would as human beings.

  • Okay, so let's add this to an existing test base.

  • First, let me show you the application that we're gonna be testing is a single page application, and it has eight of my favorite books on testing.

  • And the way that this works give us some more realistic.

  • The way that this works is you just type in one of the book titles and a filters that, for example, if I put in test and I see all the books that have test this part of the title.

  • That's it.

  • Okay.

  • And let's look at the test now.

  • So we have to test here one that is looking for a specific book with the exact title Agile testing.

  • So we searched for that.

  • We make sure that there's only one book that's returned and that it is the right title.

  • And then the second test, this one is looking for multiple one.

  • So the one I showed you in the example you put in the word test.

  • Here are the books that we expect to come back.

  • We validate that all of them are actually visible.

  • And the Arthur right titles.

  • Hey, so let's run this test.

  • This big one.

  • I'm using Cyprus here.

  • Anybody who's Cyprus?

  • Yeah, the jealousy that announced me.

  • So they just released 4.0, yesterday.

  • And now cross browser support.

  • I know.

  • All right, so we've run this test and this is past beautiful.

  • Everything is lovely.

  • Okay, let's switch back toe application mode.

  • And let's say we want to like jazz this page up a bit.

  • You know, we want a little bouncy effect or something.

  • So we had a little CSS here, and we have tests, so we feel very confident, and we go ahead and commit this right.

  • So we run this little test again and let's see Oh, no, What won the line of CSS?

  • I have flipped this application on its head, but the test is still passing.

  • Why is this?

  • Because we said, make sure there are five books are there five books?

  • Check.

  • Make sure that those five books are these titles.

  • That's true, right?

  • It's missing these other things that in intentional blindness.

  • So let's add visual testing to see if we can catch these kinds of bloods that our traditional frameworks would miss.

  • Okay, so it's an ad visual testing.

  • The first command is toe open your eye.

  • Beautiful.

  • Write poetry.

  • So we say, cy dot eyes open.

  • All right, And then after the test, let's go ahead and make a after each and in here, we're going to want to close our eyes when we're done.

  • Very intuitive.

  • All right.

  • Okay.

  • Now, within the test itself, let's go ahead and add some visual testing here, so we're going to see a side dot I's check window and that's the entire thing.

  • This will do.

  • Ah, screen capture into the visual testing and with that screen capture is gonna make sure that this title all of the titles are visible.

  • So really, I don't even need this line anymore.

  • It's gonna make sure is only five of them.

  • So I don't need this.

  • So now I'm doing my favorite thing, which is to delete CO.

  • I no longer need this, Ray.

  • Oh, my gosh, this is getting really good.

  • And I don't need a variable, cause I'm only using it that one time so I can put that they're so look how nice my test.

  • Let's now.

  • Yes, Yes.

  • Okay.

  • All right.

  • So let's make sure we put the books back.

  • Yes.

  • OK, so we're gonna run it this first time and what's going on here?

  • Did I miss something up?

  • Okay, okay.

  • So what's going on here is it takes a picture, is going to send this image out to the avenue tools cloud.

  • And so I don't have to store this stuff on my computer.

  • I can if I want it.

  • So there's options for that.

  • But by default, this just close out to the hapless whose cloud and capitals will then create this as a new baseline saying OK, This is a new test that you have will store that fear.

  • All right.

  • And then every time I run, the regression runs is going to compare the two.

  • Now, this is still running because I'm on, like my bone, uh, WiFi.

  • So it's a little bit slower, but let's go to the applique tools dashboard.

  • So we can see now, you don't have to do this the very first time you run the test.

  • I'm really done.

  • But I just want to show you this.

  • Okay, so we have this search here, and we see that there's no baseline.

  • So this new image will be the baseline image that will be store for us.

  • Wants that.

  • Okay.

  • I know my wife take girls do.

  • All right.

  • I'ma let that cook.

  • Um, But you see the little thumbnail here, right?

  • All right, So Okay, there it is.

  • All right.

  • So let's talk about this a little bit.

  • This is really powerful.

  • This is great.

  • Like, uh, I want to run this again with the books flip, and let's make sure that it actually captures that.

  • Okay, so let's uncommon out there, we flipped the books and that's run our test again.

  • Okay, great.

  • So this is now going to take another screen shot again since this out to the cloud and now is doing the aye aye comparisons to make sure that these are the same or not.

  • And then it should alert us.

  • Um, when this feels all right, So, you see, he got a little error here and Cyprus, you have to go into, like, crawling death tools to see the era.

  • But just gonna show you here.

  • So we come back to our dashboard and we see that now we have this test markers on result.

  • So a iess saying that failed.

  • But, hey, something has changed here, Human.

  • Come and see if this is what you want it like, this was an intentional change or not.

  • Of course, flipping our books upside down is not an intentional change.

  • So we say, Oh, no.

  • And we just do a thumbs down.

  • And now this test is marked as field.

  • Okay, so this will capture the things that we missed without an intentional blind is, we don't have to think of every single assertion toe add to our co base.

  • This covers everything, but on the flip side, of that.

  • That's also a con.

  • If we think about it in some cases, right, because it captures everything.

  • So not just these books.

  • It also captured the text that I put in to hear the name of the title on the application.

  • Anything else that was going on the page.

  • So that's great in some cases.

  • But it could also be a nuisance in other cases where it's capturing too much, right?

  • So we could solve for this By scoping this down.

  • We don't have to take a picture of the entire page.

  • It's very, very flexible.

  • So if I wanted to do this other test and stand this ah was disabled, this one in here I'm gonna do.

  • Okay, So this one is the one letter is just one book.

  • Now let's say that I only want this one book captured.

  • I don't want to take a picture of the entire page.

  • So weaken, simplify this again.

  • We get to delete some code, and then let's do the side that eyes checked window.

  • And this time we can specify some information so we can say target a specific region and, uh, give it the selector for that region.

  • that you want targeted.

  • So I already know that it has an idea of P i.

  • D three.

  • So I'm saying, just do this one book, All right?

  • So if we run this again, But I miss that my search Curtis.

  • All right, so it takes a picture of this, but this time on Lee the book.

  • So it finds that selector, it takes a picture of that and then sends it off to aptitudes to do the comparison.

  • So let's look it with that.

  • Let's light.

  • All right, So we have a new test here, and we see that it's only the book best captured.

  • Not all the rest of the noise, but this is pretty powerful as well.

  • We can scope it down as we want without some drawbacks to this approach too.

  • Right?

  • So, for example, let's say that I actually typed in the word agile testing here, and it didn't work.

  • The filter doesn't work.

  • None of the books were fields to the way All of them were still there with this test pass or what?

  • It failed me Say pass.

  • I mean, say fail.

  • I mean, here on the edge of their seats, waiting.

  • Okay, so this would actually pass because it's going to find that specific region that I told it.

  • And that book is there, and it looks beautiful.

  • So this would pass, so we could couple our visual assertions with the traditional functional ones as well.

  • So in this case, we could say OK on Lee, do the visual testing on that one book, but then make sure that there's only one book showing.

  • So that way you're mixing and matching.

  • It doesn't have to replace everything you already have.

  • You can do both.

  • Okay, you can also do testing on dynamic layouts.

  • Soul.

  • Let's look at another test.

  • Let's go ahead and just make one really quickly.

  • And this one we're gonna say, should have a nice layout, and this time we're not even gonna search.

  • Okay, so we're just going to look at the layout owls.

  • It's ah, who works on V s cold here.

  • I don't like that.

  • Look, I don't like that feature.

  • All right?

  • So have a nice layout here, so let's go ahead and run this as is.

  • So what this is going to do is it is point to at this point, is running as normally, but we're gonna and something's here to see.

  • You know what?

  • I want to test some dynamic content.

  • It might not always be the same every time.

  • So the way that this works is is going to use machine learning to observe any patterns that it confined.

  • With this application and the patterns that I'm guessing it seeing is okay, we have some squares, and they are this much with the party.

  • And they all have, like, a purple thing at the top and some white text in it, and a picture and some bolt ticks and blah blah, blah.

  • So it's figuring those things out, and then we can actually go into our application, and we can change.

  • The order of lists has changed the water of a couple of books.

  • All right, now, in order to say, hey, apple tools, we want to do, um, some some dynamic testing here.

  • We're going to say inside of here, we can do match level and say this equals a layout match level.

  • Hey, and then we'll run this again.

  • And there are four different types of match level.

  • So the one we've been using by default was strict.

  • That just does a regular comparison.

  • There is exact, which does picks it a pixel.

  • But we say no to picks it a pixel.

  • Right.

  • So don't use that one.

  • And there is this one layout, which does the dynamic content.

  • And then there's also a constant one that does colorblind comparison.

  • All right, so let's look at this test.

  • I'm run its wife, so I should have a baseline.

  • Yes.

  • All right.

  • So notice here, that cucumber book and the first picture was in the third place on the second role.

  • But in the second picture, it is the second place, and this still passed because it noticed.

  • Okay, um, the layout and everything is fine.

  • Nothing looks messed up here.

  • If I wanted to preview this in a different match level just to see it, if I did in a strict mode, it would have captured that these books were different.

  • All right, so this is really powerful.

  • We used this when I was working at Twitter, um, after her ugly bug re found.

  • And, uh, we have, like, new sights and things they use is where their constant is gonna be different Pretty much every time.

  • The app loads, but structurally, you want to make sure everything looks good, all right.

  • And finally, last thing I want to show you is that you can do cross browser testing with this.

  • A swell till sq bit of dads.

  • And, um, I'm going to I shouldn't do that.

  • Um, just passed in, like all of the things I want to test on.

  • So I want to test on fire Fox and Chrome and I eat and I want to test on iPhone 10 and in landscape molding and galaxy so I can just add this here and this will run all of those tests across all of those configurations.

  • So I mean it less.

  • Let's run.

  • Let's run both of those tests that we had our 1st 2 tests.

  • Okay, so I noticed this just opened in electron or whatever.

  • This is not going into all of those different browsers, at least not from our view.

  • So what this is doing?

  • I really magical in my mind.

  • It is capturing the dom and all of its assets.

  • So all of the Js files all of the CSS fouls, and it's taking it in that state and then blasting it across all of the configuration that we said.

  • So you don't have to execute those scenarios over and over again across all of these platforms.

  • It just takes it once.

  • It's already in that state.

  • This shows what it'll look like in all of them.

  • So we go back to our dash, boy.

  • Let's see what we have here.

  • Okay?

  • Why Law?

  • So in a matter of seconds, we've run.

  • Aah!

  • These 12 tests is a lot to look at.

  • I can even group this down to, like, buy device are like my browser, and then I can manage this a little bit more, and I see that that test has run.

  • So this is iPhone in whatever mo that ISS which one is that landscape?

  • And this is a portrait.

  • And then this is the book.

  • I'm both as well.

  • So that is visual testing.

  • And in a shell, very, very powerful stuff.

  • You can open your free account on on Apple.

  • It'll site.

  • Um, let me know if you have any questions.

  • I'll be around for the rest of the day.

  • And you can also, uh, you can also hit me up on Twitter at Tech Girl 1908 If you don't.

  • If you're too shy to come, talk to me, person.

  • All right.

  • Thank you so much.

Hi, everyone.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

你的測試缺乏視野。為你的自動化框架添加眼睛--Angie Jones|JSConf Hawaii 2020 (Your Tests Lack Vision: Adding Eyes to Your Automation Framework - Angie Jones | JSConf Hawaii 2020)

  • 4 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字