All right, so this lecture is more like a lecture, which you can easily figure out.
I mean, this is not even a lab kind of things, but I just felt that we have not discussed about it
a lot.
So I'm just going to be talking about it probably very quickly in this particular lecture.
So it's not going to be that complex or modern like how you used to do in the network interception or
cookies.
But this is more like reading the data from a JSON file and using it for data driven testing.
This is something like Don't ask me like how I can do Adriaan testing on the playwright.
I think it was the same question asked by students in my puppeteer's, so I would like to add the same
over here in this course as well.
All right.
So this lab is more diverse than they are doing testing.
So what I'm going to do is I'm just going to go over here to that package.
I'm going to create a folder.
I'm going to call this as DDT for data driven testing.
And over here, I'm going to create a new folder and I'll call this as probably data.
And this data is going to have or hold a JS on file so that one file is going to be called as test data
dart Jasen.
So this guy is basically holding all the test data for our logging operation.
So if you remember in our earlier tests that we wrote for the app Dorsami dot com website, we used
to enter the user name as admin and password is password and the user details something like this.
So this is going to be more like that in this particular test.
I mean, it is going to enter all the user details over here and we're going to see if that works or
not that simple.
It is.
It's super simple and super easy to do.
So in order to do this, I'm actually going to copy paste the same exact code from what we wrote in
our earlier sections.
So I guess we have that on the network interception probably over here.
Uh, oops.
I think we deleted most of them.
So I guess I need to create a new data driven test.
Dargis and I'm going to pass this code.
So this code is going to be pretty much exactly the same code that we wrote already.
And the code is going to look something like this.
I mean, this is the same code that we recorded in our work order earlier.
So I'm just going to do or maybe make use of the same code here.
So what it's going to do is it's going to log into the site and then it's going to enter the hardcoded
value that we have at the moment.
And then that's it.
That's what it is going to be doing, basically.
So if I just go to the DDT over here and if I do, unless it has the data and red ribbon testing, so
I'm just going to do a node of data driven testing.
Dargis So it is going to execute the code like how it used to execute it.
So but all these data that we are entering at the moment on the app is basically from the hardcoded
value.
Right.
So you can see that it is all hardcoded value.
That's what it is entering to perform the operation.
But instead of the hardcoded value that we have at the moment over here, I'm actually going to be making
use of that data that we have in our strategies on file.
In order to do this operation, we are actually going to be making use of a simple construct.
All we going to do is we need to import that data in our test.
So far doing that, I'm just going to do a required and because the power of JavaScript is you can easily
get a JS on file using this.
That's it.
So if you do that, all the data on file is going to be automatically available for you.
This is really, really cool.
I mean, literally really, really cool.
So I'll show you what I really mean.
So if I just go over here on the data and if I want to replace this, I've been to the admin value that
we have on over here.
So I'm going to do is data darte if I just type login, which is nothing but this guy, the login dart
user name.
So if I just give this and if I save it over here, let me just stop the test.
And if I try to run this test at the moment, I'm sorry to give a semicolon.
And if I try to run this guy, you can see that it is going to open the test for me and it is also going
to enter the admin over there, which is quite good, right?
I mean, you could able to do the exact same thing using this particular simple code.
So I just replaced the data log login, that username.
So it's going to enter the user name for me from the design file.
Similarly, if I want to enter the password so I can oops, sorry, I can go here and it can enter the
password data dart and you can see that the intelligence is also.
This time very handy, so it's going to automatically pass, that is on file.
Read that for us.
I'm just going to show us all the property over here, which is quite good.
And similarly, you can keep replacing all these values as well, something like DataDot user.
So this is going to be the name.
So that's it.
So did I not use user name is going to be the name and for the salary, I'm just going to enter the
salary and for the duration work I can just replace that or the duration worked and for the grade I
can just replace that to grade and for the e-mail I can just replace that to e-mail.
That's it.
Very, very simple.
And once I do that, I can then save this.
And then if I try to run this test, it is going to run as expected if I'm not wrong.
So that is.
It is, guys.
I mean, this is really, really easy to work with while we try to perform any one testing.
But do you think that every time I run the test, there is an operation to delete the user as well,
like the user that we created?
But because this is an hardcoded expert over here, the religion is not going to happen.
I mean, it's literally not going to happen.
So in order to delete this user, we should dynamically get the data or pass the value of the particular
user test to user to delete this operation, which you can do it very, very easily.
I think we can make this lab even more interesting.
If you try to handle this dynamic delete operation, please try to do it yourself.
If you can't really do it, we're going to discuss the same solution in our next video.