All right, so now that we already have our cookies in this particular Jason file, we can just use
this same Jason file and we can able to set the cookie information on our test and we can see how it
actually works.
So far doing that, I'm just going to create one more file called call this as cookie or maybe a cookie
jar.
Yes.
And this guy is going to hold the same sort of test, probably, uh, like get cookies.
I don't really have to go deal everything, but just copy paste on the court from here.
And I'm just going to get rid of all these courts because all I'm going to do is I'm just going to navigate
directly to that particular website to create an.
Employee create page, and I need to see if that really works or not without logging in and stuff,
so I'm not going to do any of these informations or here.
I'm just going to use a cookie and we'll see how it actually works.
So far, doing that, as you can see, I have already done the code.
I have a commentary to even my earlier lecture.
I have to call this method, called us the cookie on the context.
And then I need to add a cookie over here.
I can do this cookie directly using this particular Jasen file.
I can just put all the value in my file and then I can do it, or I can just try to read the file and
then I can set the particular value on this particular add cookie.
So what I'm going to do is I'm just going to do this cookie.
Is equal to John Dot String.
If I was, I always try to do and then first dot read file sync.
Of slash.
The cookies.
Jason, I think, is equally Keidar Jason.
Yeah, and the format is going to be the UTF eight as well.
That's it, and this cookie is something we are going to add over here, so this way it's going to add
all the cookie information for us, which is quite good.
And now if I try to navigate directly to the particular website that do on the create website, I should
see the site being already logged in instead of logged outstate.
So we'll see how it actually works.
Um, actually based this particular URL instead of the.
Employee login, so I'm not even going to login this time, I'm just going to do a cookie information
and then I'm going to pass the cookie information and then I'm going to do a create operation.
So we'll see how it actually works.
So, node.
Eat a cookie, Dargis, oops, I'm also getting some error here.
Uh, says that the cookie expected array and got a string.
Um, I think I messed up somewhere on the call.
Yeah.
I think this Jasanoff, a string yafai is not right because the string yafai is going to convert the
jasen.
Value to end string, but this guy, the ad, Kyuki, always expect an array if I'm not wrong, as you
can see over here, this is expecting for an array.
So we need to somehow get the array over here.
So what we should do is instead of Jasanoff string, if there is a method called as POS, which is going
to do a part of the operation for us and will do things for us, much, much easier.
So I'm just going to stop this guy and I'm probably going to save it right now.
And if I try to run the year kookie, I'm definitely sure that this is going to work fine.
I'm sorry it's not been saved.
Sorry about that.
So I'm just going to save it and stop the test on it again.
So you can see that the browser is not opening and you can see that our site is now logged in, guys,
you can see that this guy is going to show us the employee information employee details employee list.
And that is a create new as well as I could able to easily create.
And this guy is actually logged in, which is quite good.
So that.
Sensitive information.
So the information that I have is actually correct over here, so if I go to the application, you could
see that I have the cookie over here.
These values are actually set from our cookies that we have passed over the cookies on the jasen file
that we have over here, which is quite good.
So this way, we could be able to ensure that we could be able to set cookies on our website and we
could be able to log in without actually logging in and perform all the operations.
So this way is very, very handy because I got this I get some questions from the audience asking how
I can actually log into a website which actually has a Microsoft authenticator or a Microsoft logging
operation.
So you can actually get those cookies information.
You can directly set the cookie information on your website and then you can bypass the logging operation
and then you can directly get into the site instead of you being sitting all the cookie information.
So this way you can reduce the fragile code as well.
You don't really have to log in each and every time.
Rather, you can just set the cookie and then you can log in from there.
This way you save enormous amount of time of being logging every time and then performing the operation.
This saves a lot of time as well.
So this is another better way of dealing with your coding instead of logging in each and every time.
Lot of guys, this how we can actually deliver the cookies and this is how we can modernize our automation
in playwrite.
I think this Hands-On lab is giving even more information of modernizing work test automation a level
further.