Latest / CyberSecurity Summary / Practical WebDriverIO: Learn to Automate Effectively Using WebDriverIO APIs
Transcript
- 0:00Speaker 1: All right, time to really get into web Driver EO.
- 0:03Speaker 2: I know you guys are super interested in this.
- 0:05Speaker 1: Oh yeah, definitely. This is like the framework everyone's talking.
- 0:08Speaker 2: About right now, and for a good reason, right, totally totally.
- 0:11Speaker 1: Yeah. So, you know, maybe you're starting a new project,
- 0:14Speaker 1: or maybe you just want to be in the no
- 0:16Speaker 1: whatever it is. You sent in a really cool excerpt
- 0:19Speaker 1: to kick things off, practical web Driver EO. Nice choice.
- 0:23Speaker 2: Yeah, that's a great book, and we have.
- 0:25Speaker 1: Our expert here to break it all down, you know,
- 0:27Speaker 1: especially all the technical stuff.
- 0:29Speaker 2: So absolutely happy to help make sense of it all perfect.
- 0:31Speaker 1: So web DRIVERYO. It's not just another framework, right. It's
- 0:36Speaker 1: built on no JS, right, which basically means like it
- 0:40Speaker 1: s beaks JavaScript like.
- 0:42Speaker 2: A native Yeah, it's perfect if your application is already
- 0:44Speaker 2: using a lot of javascripts exactly.
- 0:47Speaker 1: Okay, But like the big question, why would someone choose
- 0:51Speaker 1: web Driver EO over say, Selenium or even Cyprus.
- 0:56Speaker 2: Oh that's a great question, and that's where the practical
- 0:59Speaker 2: in your source really comes in. You know, Webdriver YO
- 1:02Speaker 2: is known for being super flexible. Sometimes Selenium it can
- 1:05Speaker 2: feel a little bit rigid, Okay, yeah, especially if you're
- 1:09Speaker 2: working with like elements on a web page that change
- 1:12Speaker 2: a lot, or you need to do some really complex
- 1:15Speaker 2: stuff right right, webdriver Yo gives you a lot more control.
- 1:19Speaker 1: I see, I see. And in the source they talk
- 1:21Speaker 1: about the package dot Jason file pretty early on. Yeah,
- 1:25Speaker 1: which you know, any no JS developer knows that file
- 1:30Speaker 1: like the back of their hand for sure. But the
- 1:32Speaker 1: cool thing is the book doesn't like dwell on the basics.
- 1:35Speaker 1: It jumps right into the stuff that can be a
- 1:37Speaker 1: real headache, you know, like managing all those dependencies, Oh absolutely,
- 1:41Speaker 1: and especially making sure all the versions play nice with
- 1:43Speaker 1: each other, which oh boy.
- 1:45Speaker 2: Yeah version mismatches a node.
- 1:47Speaker 1: I mean, don't even get me started.
- 1:49Speaker 2: It's a whole thing.
- 1:50Speaker 1: The author definitely seems to know where people will get
- 1:52Speaker 1: tripped up.
- 1:53Speaker 2: It's like it's like they've been there.
- 1:54Speaker 1: Yeah, exactly, like they've seen it all. So the source
- 1:59Speaker 1: it suggests like some proactive stuff you can do, like
- 2:03Speaker 1: using a lock file to basically freeze those dependencies. Yeah,
- 2:07Speaker 1: and also just like updating regularly so you don't fall too.
- 2:10Speaker 2: Far back for sure, keep things fresh, you know.
- 2:12Speaker 1: Yeah. Absolutely. Have you ever had like a full on
- 2:15Speaker 1: dependency nightmare?
- 2:17Speaker 2: Oh? Yeah, absolutely? I mean who hasn't spent hours and
- 2:19Speaker 2: hours debugging just to realize, oh it's.
- 2:21Speaker 1: Some tiny little version contact. Yeah it's the worst. But okay,
- 2:27Speaker 1: enough about setup woes. What really caught my eye in
- 2:30Speaker 1: this source was like this amazing section on locator strategies.
- 2:36Speaker 1: Oh yeah, it's like a masterclass in how to find
- 2:38Speaker 1: exactly what you need on a web page.
- 2:41Speaker 2: Locators. That's the foundation of any good automation framework. And
- 2:44Speaker 2: the source it goes into like all these different types,
- 2:47Speaker 2: is it the ton I, DCSs, selectors, X path, even
- 2:50Speaker 2: just planelink text.
- 2:52Speaker 1: It's pretty impressive.
- 2:53Speaker 2: But it's not just knowing they exist, right, it's about
- 2:56Speaker 2: choosing the right one.
- 2:57Speaker 1: Oh, that's where the strategy comes in. Yes, The source
- 2:59Speaker 1: talks about finding the most reliable locator, you know, like
- 3:03Speaker 1: if you have a logo and it has a unique ID.
- 3:05Speaker 2: Yeah, Like, if it's a static ID, go for it,
- 3:08Speaker 2: use that exactly.
- 3:09Speaker 1: That's probably your best bet. But if you have stuff
- 3:11Speaker 1: on the page that's always changing.
- 3:14Speaker 2: Oh, dynamically generated concept.
- 3:16Speaker 1: Yeah, that's when things get a little bit tricky. Totally.
- 3:19Speaker 2: The source it says like IDs should be your go
- 3:22Speaker 2: to whenever you can, because they tend to be the
- 3:25Speaker 2: most stable. Okay, makes sense, But when you're dealing with
- 3:28Speaker 2: more complex stuff CSS selectors they can give you a
- 3:31Speaker 2: lot more flexibility. XPath can be super powerful. But it's
- 3:35Speaker 2: also like if the structure of the web page changes,
- 3:39Speaker 2: it can break your.
- 3:40Speaker 1: Tests right right, it's more fragile exactly. It's almost like
- 3:43Speaker 1: you need to be a detective, you know, looking at
- 3:45Speaker 1: the web page's HTML, like searching for clues. That's a
- 3:48Speaker 1: great analogy, trying to find that perfect locator.
- 3:51Speaker 2: It's and the source it even gives you tips on
- 3:54Speaker 2: using your browsers, developer tools, you know, to inspect elements
- 3:58Speaker 2: and test out different locators. Yeah, it encourages you to experiment,
- 4:02Speaker 2: get your hands dirty, which I really like.
- 4:03Speaker 1: Yeah totally. So, okay, we've got our elements, they're all
- 4:07Speaker 1: locked down, Now what can we actually de with them?
- 4:10Speaker 2: That's where the fun begins, right.
- 4:12Speaker 1: This source goes deep, deep into this amazing world of
- 4:15Speaker 1: browser commands.
- 4:16Speaker 2: Oh yeah, it's like having superpowers.
- 4:18Speaker 1: It really is. Like switching between windows, no problem, piece
- 4:22Speaker 1: of cake, Taking screenshots of the entire page, like the
- 4:25Speaker 1: whole layout, easy psy and get this. You can even
- 4:28Speaker 1: inject JavaScript for those moments when you'd need ultimate control.
- 4:33Speaker 2: That's where things get really interesting.
- 4:35Speaker 1: For example, you know, you imagine you have a website
- 4:38Speaker 1: and you have users all over the world.
- 4:41Speaker 2: Oh yeah, international users.
- 4:42Speaker 1: The source it gives an example of how to simulate geolocation.
- 4:46Speaker 1: Oh wow, so you can see how the site behaves
- 4:48Speaker 1: if you were in like I don't know the rebuta triangle.
- 4:52Speaker 2: That's pretty cool.
- 4:53Speaker 1: Maybe not the best place for vacation, but you get
- 4:55Speaker 1: the idea.
- 4:56Speaker 2: Yeah, I get it. So that's what makes webdriver yos
- 4:58Speaker 2: so awesome.
- 4:59Speaker 1: It really is powerful.
- 5:00Speaker 2: It's not just about like clicking buttons or filling in forms.
- 5:04Speaker 2: It's about recreating real world scenarios like location based services.
- 5:09Speaker 1: And stuff exactly. And the source it doesn't just tell
- 5:12Speaker 1: you like, hey, here's this cool feature, right, it tells
- 5:15Speaker 1: you why it matters.
- 5:16Speaker 2: Yeah the way.
- 5:17Speaker 1: So like simulating geolocation, it's not just a neat trick.
- 5:22Speaker 1: It's actually super important for testing features. You know, like
- 5:26Speaker 1: if you have location based search, targeted content, even stuff
- 5:31Speaker 1: like delivery services.
- 5:32Speaker 2: You know makes sense.
- 5:33Speaker 1: It adds a whole new dimension to how you think
- 5:35Speaker 1: about testing.
- 5:36Speaker 2: It's about thinking outside the box.
- 5:38Speaker 1: Yeah, totally, okay, so we can find elements we can
- 5:40Speaker 1: interact with them, but what about making sure they actually
- 5:43Speaker 1: work the way they're supposed to go.
- 5:44Speaker 2: Oh, that's where assertions come in, right, exactly.
- 5:46Speaker 1: And this source goes deep into the world of web
- 5:48Speaker 1: drive reo assertions.
- 5:50Speaker 2: They're like checkpoints for your application.
- 5:52Speaker 1: Yeah, exactly. So it's not enough to just like poke
- 5:55Speaker 1: around and see if things kind of work right. You
- 5:57Speaker 1: got to be specific, like this element must do this.
- 6:00Speaker 2: Yeah, and then you check if that's actually true.
- 6:03Speaker 1: Yeah. And this source it goes way beyond the basics,
- 6:06Speaker 1: Like there are all these specialized assertions that webdriver Yo
- 6:09Speaker 1: give you.
- 6:10Speaker 2: Oh it's awesome, right, it's like going from a basic
- 6:12Speaker 2: checkup to a full blown medical scam.
- 6:15Speaker 1: Love that analogy. So the source it starts with this
- 6:18Speaker 1: assertion is existing. Oh yeah, I no, it checks if
- 6:21Speaker 1: an element is actually there, you know, in the dom.
- 6:24Speaker 1: But here's the thing, and the source points this out. Yeah,
- 6:27Speaker 1: it's subtle, is existing. It won't actually fail your test
- 6:32Speaker 1: if the element's missing.
- 6:33Speaker 2: Right. It's more about gathering information.
- 6:36Speaker 1: So it's like a scalp.
- 6:37Speaker 2: Yeah, like a little spy.
- 6:38Speaker 1: Hey this element there, Yep, it's there, or Nope, can't
- 6:42Speaker 1: find it.
- 6:43Speaker 2: And then you decide what to do with that.
- 6:44Speaker 1: Information exactly exactly. Maybe you want to wait for it
- 6:47Speaker 1: to show up, or maybe you want to handle it
- 6:49Speaker 1: gracefully if it's not there.
- 6:50Speaker 2: Right, It's all about flexibility and being in control, you know.
- 6:53Speaker 1: Totally totally, And if you do want an assertion that's like, hey,
- 6:58Speaker 1: this element better be here or we have a problem.
- 7:01Speaker 2: Yeah, like a hard stop.
- 7:02Speaker 1: Yeah, the source recommends to exist or to be present.
- 7:07Speaker 2: Those are your go to for sure.
- 7:08Speaker 1: Okay, what about elements that are there but they're like hiding.
- 7:13Speaker 2: Oh you mean visible? Yeah?
- 7:14Speaker 1: Yeah, visibility. As users we take it for granted totally,
- 7:18Speaker 1: but an automation, huge.
- 7:21Speaker 2: Deal huge, So that's where you use is displayed. It's
- 7:25Speaker 2: like saying, hey, not only should this element be there,
- 7:28Speaker 2: but it should be visible too, like a user could
- 7:31Speaker 2: actually see it makes sense, And just like before, you've
- 7:34Speaker 2: got a stronger version to be displayed or too visible.
- 7:37Speaker 1: Oh I like that.
- 7:38Speaker 2: Yeah, if you need to be absolutely sure.
- 7:40Speaker 1: Yeah totally. Oh and the source even talks about this
- 7:43Speaker 1: cool assertion to be visible in viewport.
- 7:46Speaker 2: Oh yeah that's a good one.
- 7:48Speaker 1: This one's like next level thing.
- 7:50Speaker 2: He checks if the element's not just visible, but if
- 7:52Speaker 2: it's actually in the part of the page the user
- 7:54Speaker 2: can see without scrawling right.
- 7:55Speaker 1: Right, because you could have a super long web page.
- 7:57Speaker 2: Yeah, and technically an element could be visible, but if
- 8:00Speaker 2: you've got to scroll down a mile to find it,
- 8:02Speaker 2: is it really visible exactly?
- 8:04Speaker 1: It's like you got to think like a user, you know,
- 8:06Speaker 1: how are they actually experiencing thisally? Totally? Okay, So we've
- 8:09Speaker 1: got presence, we've got visibility. What about elements that are
- 8:13Speaker 1: visible but you can't like interact with them, like a
- 8:17Speaker 1: button that's disabled or something.
- 8:19Speaker 2: Yeah, that's a good one. So the source it goes
- 8:21Speaker 2: into that too. You can check if an element is
- 8:24Speaker 2: enabled or disabled using like to be enabled and to
- 8:27Speaker 2: be disabled.
- 8:28Speaker 1: Ah okay, so you're making sure those interactive elements are
- 8:30Speaker 1: actually like working exactly.
- 8:32Speaker 2: And checkboxes, Oh, don't get me started on checkboxes.
- 8:35Speaker 1: It can be a real pain to test.
- 8:37Speaker 2: The source it highlights is selected and to be selected.
- 8:42Speaker 2: Use those to check if a checkboxes you know, checked
- 8:45Speaker 2: or not. Right might seem small, but it's important. Like
- 8:48Speaker 2: think about accepting terms and conditions on a website.
- 8:51Speaker 1: Yeah, if that checkbox isn't checked, you might not be
- 8:53Speaker 1: able to do anything exactly.
- 8:55Speaker 2: It's those little things that can make or break the
- 8:58Speaker 2: whole user experience, and.
- 9:00Speaker 1: Web Driver EO gives you the power to test all
- 9:03Speaker 1: of it.
- 9:04Speaker 2: It does, yeah, and you know it's cool the source.
- 9:06Speaker 2: It goes beyond just listing assertions. It actually gives you
- 9:09Speaker 2: a whole example of like a real world test case.
- 9:13Speaker 2: Oh nice, yeah, for a user loginflow, so.
- 9:16Speaker 1: You can see everything in action exactly.
- 9:18Speaker 2: You see how web driver EYO can do like end
- 9:21Speaker 2: to end testing, not just little isolated checks.
- 9:24Speaker 1: I love that. And it uses like the Page Object
- 9:27Speaker 1: Model POM to keep everything organized, right m h.
- 9:30Speaker 2: POMM is the way to go.
- 9:31Speaker 1: So it starts by like making sure all the important
- 9:34Speaker 1: elements are there, like the logo, the input fields, you know,
- 9:37Speaker 1: all that good stuff, and then it makes sure they're
- 9:39Speaker 1: visible and enabled.
- 9:40Speaker 2: Yeah, got to make sure they're ready for action exactly.
- 9:43Speaker 1: Then it's like, okay, let's simulate a user typing in
- 9:45Speaker 1: their username and password. And here's what I really like
- 9:47Speaker 1: about it. It doesn't just assume everything's going to work perfectly.
- 9:51Speaker 2: Oh yeah, that's key.
- 9:52Speaker 1: It uses those conditional statements if and else right, so
- 9:56Speaker 1: it can handle like if an element is missing or
- 9:58Speaker 1: if it's disabled. It and like log a warning or something.
- 10:02Speaker 2: Yeah, instead of just crashing the whole test exactly.
- 10:05Speaker 1: So it's like built in resilience. Yeah, you know, not
- 10:08Speaker 1: every cast needs to be a straight up pass or fail.
- 10:10Speaker 2: Sometimes you just want to know, like, hey, what could
- 10:12Speaker 2: go wrong here?
- 10:13Speaker 1: Exactly. It's about finding that sweet spot between being thorough
- 10:17Speaker 1: and also being realistic, you know.
- 10:19Speaker 2: And the source does a great job of showing you
- 10:21Speaker 2: how to do that.
- 10:22Speaker 1: Yeah, it really does. So all this talk about assertions,
- 10:26Speaker 1: it brings up another super important part of web Drive
- 10:29Speaker 1: REO testing.
- 10:30Speaker 2: Waits.
- 10:31Speaker 1: Oh yeah, waits essential. The source dedicates a good Yeah. Basically,
- 10:35Speaker 1: you just pause the test for a certain amount of time.
- 10:37Speaker 2: You have the application a chance to catch up.
- 10:39Speaker 1: It's like saying, okay, everyone, take a deep breath, count
- 10:42Speaker 1: to ten and then we'll continue. I like that, but
- 10:45Speaker 1: for more dynamic situations, you need something a little smarter, right.
- 10:48Speaker 2: Yeah, Like wait for display.
- 10:50Speaker 1: Oh yeah, that one's super useful.
- 10:51Speaker 2: It waits for an element to actually become visible on
- 10:55Speaker 2: the page.
- 10:55Speaker 1: So you're not just waiting for an arbitrary amount of time, right,
- 10:59Speaker 1: You're waiting for a special thing to happen.
- 11:01Speaker 2: That's where you see web Driver EOS flexibility and action.
- 11:05Speaker 1: And the cool thing is you can customize the time
- 11:08Speaker 1: out period so you can control how long you're willing
- 11:10Speaker 1: to wait, you know, and the polling interval, like how
- 11:13Speaker 1: often it checks to see if the condition's been met.
- 11:16Speaker 2: It's like fine tuning your patience level exactly exactly.
- 11:19Speaker 1: And then you've got weight for enabled that waits for
- 11:21Speaker 1: an element to become enabled so you can actually interact
- 11:24Speaker 1: with it.
- 11:24Speaker 2: Yeah, like a button that's initially grayed out.
- 11:27Speaker 1: Yeah know, at wait for exist. No one waits for
- 11:30Speaker 1: an element to like actually exist in the dom.
- 11:33Speaker 2: Web driver eyo gives you all the tools to handle
- 11:36Speaker 2: those tricky asynchronous operations.
- 11:39Speaker 1: It does, but the real star of the show when
- 11:43Speaker 1: it comes to waits is wait until.
- 11:46Speaker 2: Oh yeah, wait until. That's the big one.
- 11:48Speaker 1: This one's like ultimate flexibility. It's like a magic wand
- 11:52Speaker 1: you can define your own custom condition.
- 11:54Speaker 2: The source it gives a great example of using it
- 11:57Speaker 2: to wait for an element to have specific tech content.
- 12:00Speaker 2: Oh super powerful.
- 12:02Speaker 1: So like you're not limited to just the pre defined conditions, right,
- 12:06Speaker 1: you can get as creative as you need to be.
- 12:08Speaker 2: It's all about tailoring your weights to your specific.
- 12:10Speaker 1: Needs totally, and you still have control, like you can
- 12:14Speaker 1: set a time out, you can set a custom message
- 12:16Speaker 1: if it times out. You can even control how often
- 12:18Speaker 1: it checks for the condition.
- 12:19Speaker 2: Super customizable.
- 12:21Speaker 1: Okay, so weights, they're absolutely crucial, and this source does
- 12:24Speaker 1: a fantastic job of explaining like all the ins and
- 12:27Speaker 1: outs it does. Now, let's talk frameworks. We touched on
- 12:30Speaker 1: them briefly before, but this source it really gets into
- 12:33Speaker 1: the specifics of Cucumber and Typescript.
- 12:36Speaker 2: Yeah, frameworks they bring structure to your test code, you know,
- 12:39Speaker 2: they help you organize everything right, and the source it
- 12:42Speaker 2: highlights the benefits of each one.
- 12:44Speaker 1: Yeah, it does a great job of that.
- 12:45Speaker 2: So Cucumber it's all about that behavior driven development approach,
- 12:50Speaker 2: you know BDD. It's perfect for teams that really want
- 12:54Speaker 2: to collaborate and they want to make sure their tests
- 12:56Speaker 2: are understandable to like everyone involved, not just the developers.
- 13:00Speaker 1: Yeah, it's like bridging that gap between the technical folks
- 13:02Speaker 1: and the you know, the non technical folks exactly. And
- 13:05Speaker 1: then you've got Typescript, which brings that like lovely type
- 13:09Speaker 1: safety to the JavaScript world.
- 13:11Speaker 2: Oh yeah, Typescript is a life savers, especially when you're
- 13:14Speaker 2: working on a big, complex project.
- 13:16Speaker 1: It can really help catch errors early on. Absolutely, so
- 13:20Speaker 1: it really comes down to like what does your team need,
- 13:23Speaker 1: what are your preferences.
- 13:24Speaker 2: It's all about finding the right tools for the job totally.
- 13:28Speaker 1: And the source it even walks you through how to
- 13:30Speaker 1: set up both frameworks with webdriveryo like step by step.
- 13:35Speaker 2: Yeah, it's super helpful.
- 13:36Speaker 1: Okay, before we move on to the really fun stuff. Yeah,
- 13:39Speaker 1: actually writing the test scripts.
- 13:41Speaker 2: I know I'm excited for that, me too.
- 13:43Speaker 1: But first let's talk about the configuration file wato dot
- 13:47Speaker 1: com dot js.
- 13:48Speaker 2: Oh yeah, the control center.
- 13:50Speaker 1: It's like mission control for your webdriver real project.
- 13:54Speaker 2: And the source. It gives a great overview of all
- 13:57Speaker 2: the different configuration options there, from logging levels and services
- 14:02Speaker 2: to reporters and capabilities. It's all there.
- 14:04Speaker 1: It's pretty impressive. And the source it really emphasizes like
- 14:08Speaker 1: you got to understand what each option does you know, like,
- 14:11Speaker 1: how does it actually affect your tests?
- 14:13Speaker 2: Yeah, it's about making informed choices exactly.
- 14:15Speaker 1: Don't just copy and paste stuff without knowing what it's
- 14:17Speaker 1: doing exactly.
- 14:18Speaker 2: Got to understand the why behind the what.
- 14:20Speaker 1: And the source it does a great job of explaining
- 14:22Speaker 1: all those whys.
- 14:23Speaker 2: It's like having a personalized setup guide.
- 14:25Speaker 1: You know, totally, totally. So we've covered installation, locators, commands, assertions, frameworks, configuration. Wow,
- 14:33Speaker 1: that's a lot, I know, right, Yeah, it's incredible how
- 14:36Speaker 1: much this source manages to pack into like a short excerpt.
- 14:39Speaker 1: It's a good foundation though, it is, and I think
- 14:41Speaker 1: it sets us up perfectly to actually start writing those
- 14:44Speaker 1: test scripts.
- 14:44Speaker 2: Yeah, which is what we'll be diving into next time exactly.
- 14:48Speaker 1: But before we jump into all that practical stuff, let's
- 14:51Speaker 1: just pause for a minute and let everything we've talked
- 14:53Speaker 1: about today sink in.
- 14:55Speaker 2: You know, yeah, take a breath there.
- 14:56Speaker 1: It's a lot, but it's exciting it is.
- 14:59Speaker 2: And with this found foundation, I mean, you guys are
- 15:02Speaker 2: well on your way to becoming web driver EO masters.
- 15:05Speaker 2: That's the goal, and building super robust and reliable tests
- 15:08Speaker 2: for your applications, whatever those applications might be.
- 15:11Speaker 1: That's the dream, right, all right, welcome back to our
- 15:14Speaker 1: web driver Yo, deep dive.
- 15:16Speaker 2: I'm excited for this part, me too.
- 15:18Speaker 1: Last time we laid down all the groundwork, like installation locators, commands,
- 15:24Speaker 1: all the essential there's like getting a sneak peek into
- 15:26Speaker 1: the frameworks toolkit, right, but now it's time to see
- 15:29Speaker 1: how those tools actually work in practice.
- 15:31Speaker 2: Let's get hands on.
- 15:32Speaker 1: Exactly and this source practical web Driver. Yo, it's a
- 15:36Speaker 1: perfect guide for this part of the journey. It doesn't
- 15:39Speaker 1: just tell you what to do, it shows you how
- 15:41Speaker 1: to do it right the right way. Yeah, like how
- 15:44Speaker 1: to write test scripts that are clean, easy to maintain,
- 15:47Speaker 1: and super reliable. That's what we want exactly. So the
- 15:50Speaker 1: source it starts off with this design pattern that's like
- 15:54Speaker 1: super popular in the testing world, the Page Object model
- 15:57Speaker 1: or POM.
- 15:58Speaker 2: Oh yeah, POM got love.
- 16:00Speaker 1: I've heard people talk about it, but honestly, this source
- 16:03Speaker 1: finally made it click for me.
- 16:04Speaker 2: Yeah. POM can be a game changer for sure.
- 16:06Speaker 1: It's all about bringing order to the chaos, right, Like
- 16:10Speaker 1: thinking of your application is a collection of pages, and
- 16:13Speaker 1: each page has its own like unique elements and interactions.
- 16:17Speaker 2: Right And instead of having your test code all over
- 16:20Speaker 2: the place, you create separate classes for each page. Ah,
- 16:24Speaker 2: so you can keep everything organized and easy to find.
- 16:26Speaker 1: It's like creating a blueprint for each page exactly. So, Like,
- 16:30Speaker 1: if you have a log in page, you'd have a
- 16:31Speaker 1: log in page class. Yeah, and that class would have
- 16:34Speaker 1: all the locators for like the username field, the password field,
- 16:37Speaker 1: the log in button.
- 16:39Speaker 2: And the methods for actually interacting with those elements too.
- 16:42Speaker 1: Ah okay, okay, so instead of having like this cryptic
- 16:46Speaker 1: code all over your test scripts, you'd have these nice,
- 16:49Speaker 1: clean method calls right exactly.
- 16:51Speaker 2: It makes your code so much more readable.
- 16:53Speaker 1: It's like writing a story, yeah, about how your tests
- 16:56Speaker 1: are interacting with the application.
- 16:58Speaker 2: And if the layout of the page changes, you only
- 17:00Speaker 2: need to update the page object class. Oh, you don't
- 17:05Speaker 2: have to touch all your test scripts.
- 17:06Speaker 1: That makes updating so much easier.
- 17:08Speaker 2: Exactly, makes your code less fragile, less likely to break
- 17:12Speaker 2: when things change, and.
- 17:13Speaker 1: The source it actually walks you through an example of implementing.
- 17:17Speaker 2: POM, Yeah, step by step surprisingly straightforward. It is. Yeah,
- 17:22Speaker 2: you create a folder for your page objects, and then
- 17:25Speaker 2: you define a class for each page okay, with all
- 17:27Speaker 2: your locators and your methods nice and organized.
- 17:30Speaker 1: I love it. It's like building a library of reusable
- 17:33Speaker 1: components for your tests.
- 17:34Speaker 2: Exactly, And as your application grows, your library grows with it.
- 17:38Speaker 1: Awesome. Okay, so POM is definitely a game changer. What
- 17:44Speaker 1: other like golden nuggets of wisdom does this source have
- 17:49Speaker 1: about writing really good test scripts?
- 17:51Speaker 2: Well, it talks a lot about helper functions.
- 17:53Speaker 1: Oh, helper functions are the best, like your little helpers, like.
- 17:56Speaker 2: Your sidekicks, exactly. They handle those repetitive tasks that pop
- 18:00Speaker 2: up all the time and testing.
- 18:01Speaker 1: Yeah, the stuff you don't want to write over and.
- 18:03Speaker 2: Over again, exactly. So the source gives some good examples,
- 18:06Speaker 2: like a take screenshot function.
- 18:07Speaker 1: Oh, that's a good one.
- 18:08Speaker 2: Yeah. It captures a snapshot of the current page, so
- 18:11Speaker 2: you can see exactly what's happening exactly. Super useful for debugging,
- 18:14Speaker 2: you know, or.
- 18:15Speaker 1: If you need to document something, or even if you
- 18:18Speaker 1: want to make those cool time laps videos of your
- 18:20Speaker 1: tests running.
- 18:21Speaker 2: Yeah, helper functions can be as simple or as complex
- 18:24Speaker 2: as you need them to be.
- 18:25Speaker 1: The key is to find those tasks that you're doing
- 18:27Speaker 1: over and over again and then just like encapsulate them
- 18:31Speaker 1: into a reusable function.
- 18:32Speaker 2: Yeah, keep your code dry, you know, don't repeat yourself.
- 18:36Speaker 1: Exactly. It makes everything cleaner and easier to read, and
- 18:39Speaker 1: you're less likely to make mistakes.
- 18:41Speaker 2: Absolutely. So we've talked about POM for structure, we've talked
- 18:45Speaker 2: about helper functions for reusability. What about the data that
- 18:49Speaker 2: we actually use in our tests?
- 18:50Speaker 1: Yeah, that's a good point. You can't just use any
- 18:52Speaker 1: old data right right.
- 18:53Speaker 2: It needs to be meaningful relevant to the scenarios you're testing.
- 18:57Speaker 1: So like, if you're testing a log in form, you
- 19:00Speaker 1: wouldn't just use like test user and password as the credentials.
- 19:04Speaker 2: Right, No way, you'd want to test with valid email addresses,
- 19:07Speaker 2: different password links, special characters, all that good stuff.
- 19:11Speaker 1: So you're testing how the app actually behaves in the
- 19:14Speaker 1: real world exactly, And the source suggests storing all that
- 19:17Speaker 1: test data in separate files.
- 19:19Speaker 2: Oh yeah, that's a good practice.
- 19:21Speaker 1: So instead of hard coding values directly in your test scripts,
- 19:24Speaker 1: you'd put them in like JSON or CSV files.
- 19:28Speaker 2: It makes things so much easier to manage.
- 19:30Speaker 1: Yeah, if you need to update something, you only have
- 19:32Speaker 1: to change in one place exactly.
- 19:34Speaker 2: And you can even use different test data files for
- 19:36Speaker 2: different environments like development, staging, production.
- 19:39Speaker 1: It's all about organization, right, making your code easy to maintain.
- 19:43Speaker 1: Oh and the source it also talks about code readability.
- 19:46Speaker 2: Yeah that's important.
- 19:47Speaker 1: It might seem obvious, but when you're deep in the code,
- 19:50Speaker 1: it's easy to forget that other people might need to
- 19:52Speaker 1: read it someday.
- 19:53Speaker 2: Yeah, got to make sure your code makes sense to others,
- 19:55Speaker 2: not just to you.
- 19:58Speaker 1: It's like writing a novel that only you can understand exactly.
- 20:02Speaker 2: So the source reminds us to use clear variable names,
- 20:05Speaker 2: function names, to follow coding conventions, and to add comments.
- 20:10Speaker 1: Yeah, comments are key.
- 20:11Speaker 2: They explain why you're doing something.
- 20:13Speaker 1: So your code is like a pleasure to read, not
- 20:15Speaker 1: a nightmare.
- 20:16Speaker 2: Exactly. So we've got POM forra structure, helper functions for reusability,
- 20:21Speaker 2: meaningful test data, and readable code. It's like we built
- 20:25Speaker 2: a toolkit for writing amazing web drivery o tests. It
- 20:28Speaker 2: feels that way, and the source it leaves us with
- 20:30Speaker 2: this reminder that web driver eyo is always evolving, right,
- 20:34Speaker 2: New features come out, best practices change, The community is
- 20:37Speaker 2: constantly finding new and better ways to do things.
- 20:40Speaker 1: That's like any craft, right, you never stop learning.
- 20:43Speaker 2: That's what makes it so exciting. So keep exploring, keep experimenting,
- 20:47Speaker 2: and don't be afraid to push the limits of what
- 20:49Speaker 2: web drivery o can do.
- 20:51Speaker 1: I love that this deep dive has been incredible. It
- 20:54Speaker 1: has I feel like I can tackle any web driver
- 20:57Speaker 1: EO challenge.
- 20:57Speaker 2: Now I feel that way too, and don't forget the
- 20:59Speaker 2: commune is there to support you.
- 21:01Speaker 1: Yeah, that's a good point.
- 21:02Speaker 2: So ask questions, share your experiences, and contribute back to
- 21:05Speaker 2: the project if you can. Happy testing, all right, welcome
- 21:09Speaker 2: back for round three of our web driver Yo, deep dive.
- 21:12Speaker 1: I'm ready to get my hands dirty and actually write
- 21:13Speaker 1: some test scripts.
- 21:14Speaker 2: That's what we're here for, right, to put all that
- 21:17Speaker 2: theory into practice exactly.
- 21:19Speaker 1: And our source Practical web Driver eyo, it's like the
- 21:22Speaker 1: perfect coding buddy for this part.
- 21:24Speaker 2: It really is. It goes beyond just the concepts and
- 21:27Speaker 2: gets into the nitty gritty of like writing good code right,
- 21:30Speaker 2: like best practices and stuff exactly.
- 21:32Speaker 1: So the source jumps right in with this design pattern
- 21:35Speaker 1: that's like a staple in the testing order page object model.
- 21:40Speaker 1: Oh yeah, po eom, I've heard of it, but this
- 21:43Speaker 1: source it finally made it click for.
- 21:44Speaker 2: Me, Pom. It's all about bringing order to your test code,
- 21:48Speaker 2: you know.
- 21:48Speaker 1: Okay, yeah, I can see that.
- 21:49Speaker 2: Instead of having codes scattered everywhere, you create these separate
- 21:53Speaker 2: classes for each page of your application.
- 21:56Speaker 1: Ah, that makes sense.
- 21:57Speaker 2: So each class it holds all the location for the
- 22:00Speaker 2: elements on that page and all the methods for interacting
- 22:03Speaker 2: with them.
- 22:04Speaker 1: So like if you have a log in page, you'd
- 22:06Speaker 1: have a log in page class, and it would have
- 22:09Speaker 1: the locator for the username field, the password field, the
- 22:12Speaker 1: log in button, all.
- 22:13Speaker 2: That exactly, and it would also have the methods for
- 22:16Speaker 2: like entering the username, entering the password, clicking the button.
- 22:19Speaker 1: Ah okay, So instead of having like lines of code
- 22:23Speaker 1: define those elements and interact with them scattered throughout your
- 22:26Speaker 1: test scripts, you have these nice clean method calls in
- 22:30Speaker 1: your page.
- 22:31Speaker 2: Object class exactly. So your test scripts become much more readable.
- 22:35Speaker 2: You know, they're almost like telling a story.
- 22:37Speaker 1: I like that. Yeah. So if the design of the
- 22:39Speaker 1: log in page changes, you only have to update the
- 22:42Speaker 1: login page class exactly.
- 22:44Speaker 2: You don't have to go hunting through all your pest
- 22:45Speaker 2: scripts and update them individually.
- 22:47Speaker 1: That would be a nightmare, especially if you have a
- 22:49Speaker 1: lot of tests.
- 22:50Speaker 2: POM makes your code way more maintainable, way less likely
- 22:54Speaker 2: to break when things change, and you can.
- 22:55Speaker 1: Reuse those page object classes too.
- 22:57Speaker 2: Right. Oh, absolutely, If multiple tests need to interact with
- 23:00Speaker 2: the login page, you just use the same login page class.
- 23:03Speaker 1: You're not duplicating code, right.
- 23:05Speaker 2: Which means less chance of introducing errors.
- 23:09Speaker 1: Love it and this source it walks you through like
- 23:12Speaker 1: a step by step example of how to actually implement
- 23:15Speaker 1: POM in a web driver yo project.
- 23:17Speaker 2: Yeah, it's surprisingly straightforward once you get the hang of it.
- 23:20Speaker 1: Okay, so POM huge win. What other like pro tips
- 23:24Speaker 1: does this source have for writing really good test scripts?
- 23:28Speaker 2: Well, it talks a lot about helper functions.
- 23:30Speaker 1: Oh yeah, helper functions. Those are life savers.
- 23:32Speaker 2: They're like your little helpers ready to tackle those repetitive
- 23:35Speaker 2: tasks that pop up and testing.
- 23:37Speaker 1: I'm all about saving time and effort, so I'm definitely
- 23:39Speaker 1: a fan of helper functions.
- 23:40Speaker 2: The source gives a bunch of great examples, like what, well,
- 23:43Speaker 2: like a take screenshot fuck?
- 23:45Speaker 1: Oh yeah, that would be super useful, so you don't
- 23:47Speaker 1: have to manually take screenshots all the time.
- 23:49Speaker 2: Exactly. It can automatically capture a screenshot of the current
- 23:53Speaker 2: page and save it to a specific location.
- 23:56Speaker 1: Perfect for debugging or for documentation or even and like
- 24:00Speaker 1: if you want to make a cool time lapse video
- 24:02Speaker 1: of your tests running.
- 24:04Speaker 2: Exactly, And it gives an example of a weight for
- 24:07Speaker 2: pitch to load function.
- 24:08Speaker 1: Okay, and what does that one do?
- 24:09Speaker 2: It waits for a specific condition to be met before
- 24:12Speaker 2: the test continues.
- 24:13Speaker 1: Ah, so make sure the page is actually ready before
- 24:17Speaker 1: the test tries to do anything right.
- 24:18Speaker 2: That's super important for handling those asynchronous operations, you know,
- 24:22Speaker 2: like when things happen out of order.
- 24:24Speaker 1: Yeah, those can be tricky. So basically, helper functions can
- 24:28Speaker 1: be anything you need them to be, as long as
- 24:30Speaker 1: they're helping you avoid writing the same code over.
- 24:32Speaker 2: And over exactly. If you find yourself doing something repeatedly,
- 24:36Speaker 2: turn it into a helper function.
- 24:38Speaker 1: Makes sense. Okay, So we've got structure with POM, we've
- 24:42Speaker 1: got reusability with helper functions. What about the data we
- 24:45Speaker 1: use in our tests? Is that important? Oh?
- 24:47Speaker 2: The data you use is super important. You can't just
- 24:50Speaker 2: use random.
- 24:50Speaker 1: Stuff, right, It needs to be relevant to what.
- 24:52Speaker 2: You're testing exactly. So if you're testing a log in form,
- 24:55Speaker 2: you wouldn't just use like test user and password as
- 24:58Speaker 2: the credentials.
- 25:00Speaker 1: Right, No, you'd want to use a variety of data
- 25:02Speaker 1: like valid email addresses, different password lengths, maybe some special
- 25:07Speaker 1: characters to.
- 25:08Speaker 2: See how the application handles different inputs exactly.
- 25:12Speaker 1: And the source recommends keeping your test data separate.
- 25:15Speaker 2: Yeah, put it in external files like JSON or CSV files.
- 25:19Speaker 1: Ah. Okay, so instead of hard coding it in your
- 25:22Speaker 1: test scripts, you keep it organized in these.
- 25:24Speaker 2: Separate files exactly. That way, if you need to update
- 25:27Speaker 2: the data, you only have to change it in one place.
- 25:29Speaker 1: That's much easier than searching through all your test scripts.
- 25:32Speaker 2: And you can even use different test data files for
- 25:34Speaker 2: different environments like development, staging, production.
- 25:38Speaker 1: So you can tailor your tests to each environment exactly.
- 25:41Speaker 2: And speaking of tailoring, the source also talks about the
- 25:44Speaker 2: importance of code readability.
- 25:46Speaker 1: Oh, readability, that's a good one. Sometimes I get so
- 25:49Speaker 1: focused on making the code work I forget that other
- 25:51Speaker 1: people might need to read it.
- 25:52Speaker 2: Yeah, it's easy to get tunnel vision, but it's super
- 25:55Speaker 2: important to write code that's easy for others to understand.
- 25:58Speaker 1: It's like if you wrote a novel that own you
- 26:00Speaker 1: could understand, no one else could enjoy it exactly.
- 26:03Speaker 2: So the source it gives some good tips like using
- 26:06Speaker 2: clear and descriptive variable names, following coding conventions, adding comments
- 26:11Speaker 2: to explain why you're doing something.
- 26:13Speaker 1: Yeah, comments are super helpful, especially when you're coming back
- 26:15Speaker 1: to code you haven't looked at in a while.
- 26:17Speaker 2: They're like little notes to your future self.
- 26:19Speaker 1: Okay, so we've covered a lot in this deep dive
- 26:21Speaker 1: into web drive yo. From the basics of setup and locators.
- 26:26Speaker 2: To those powerful commands and assertions, to.
- 26:28Speaker 1: The art of writing clean and maintainable test scripts using
- 26:31Speaker 1: pom Helper functions and meaningful.
- 26:34Speaker 2: Test data, and always remembering that code readability is key.
- 26:38Speaker 1: It's been a journey. I feel like I have a
- 26:40Speaker 1: solid foundation in web drive Yo now me too.
- 26:42Speaker 2: And the best part is this is just the beginning.
- 26:45Speaker 2: Web drive Rio is constantly evolving.
- 26:48Speaker 1: That's exciting it is.
- 26:50Speaker 2: So keep learning, keep experimenting, and don't be afraid to
- 26:54Speaker 2: push the boundaries of what's possible with this awesome framework.
- 26:57Speaker 1: I'm ready for the challenge. And you know, one thing
- 27:00Speaker 1: that's been really cool throughout this whole deep dive is
- 27:03Speaker 1: the sense of community around webdriver io.
- 27:05Speaker 2: Oh yeah, the community is amazing.
- 27:07Speaker 1: Everyone's so helpful and supportive, always willing to share their
- 27:11Speaker 1: knowledge and experience.
- 27:12Speaker 2: It's one of the best parts of working with open
- 27:14Speaker 2: source software.
- 27:15Speaker 1: Absolutely so to everyone listening. If you're interested in learning
- 27:20Speaker 1: more about webdriver io, don't be afraid to reach out
- 27:23Speaker 1: to the community, ask questions, get.
- 27:25Speaker 2: Involved, and most importantly, have fun with it. Testing can
- 27:28Speaker 2: be a lot of fun, especially with a tool as
- 27:30Speaker 2: powerful as webdriver Io.
- 27:32Speaker 1: I couldn't agree more so until next time, happy testing everyone,