It works great but I need some help. I have put this code in a test.beforeeach and then tried to run my first test. However, after it logs in perfectly, it doesn't run my first test. I think it happens because the first test is test('"test1', async ({ page }) => { and here it doesnt reference to the same page as it did in test.beforeeach. How can I solve this? It opens a new page and the new page is of course blank.
Hey Koushik, Thank you for this video. I have few queries... If I want to log in to different test files using different login credentials, should I create a separate auth.json for each test file? And if I want to log in to a single test file using different login credentials, how should I do this? Could you please guide me?
Hi sir. I create the playwright framework with bdd approach . But while running parallel execution once the test case failed it is opening one new browser and not able to load the url and cred. If possible can you please connect once?
We have a requirement to test email content ?Doest playwright supports this feature? I had googled it but was not able to find a proper one. It would be great if you suggest me regarding this. Thank you in advance
This is great koushik! Thank you. As I test several apps in my current repo, can store more than one auth.json? Just by naming them differently I assume? auth1.json, auth2.json etc
@@letcode that worked fine yesterday, but today it does not work for me, until I did the manual codegen step again. Would I need to do the manual codegen step every day?
Has anyone else had problems with cookies? They are not being written in the browser context, but if I run "console.log(await context.cookies())" the cookies are shown in the terminal...
Hi! How will it work with Microsoft Authentication? Codegen opens chrome in incognito mode by default, which doesn't support MFA. If you can share that idea too.
Hi Koushik, I tried this code but this opens two browsers one blank and other with logged in state, due to which further steps fails as it tries to search for locators on blank browser, can you suggest some solution here
@@letcode Not able to figure out why 2 browsers are opening, I am using async loginUsingCookies( browser, baseURL) { const context = await browser.newContext({ storageState: "./auth.json" }); const page = await context.newPage(); await page.goto(`${baseURL}`); await page.waitForTimeout(10000); } Can you pls help me here?
Hi koushik, while I'm trying to store the cookies using the same way, After giving the mail id. I'm getting this error in my chrome. Security issue is observed. What could be the issue? anyone please help if you have any views on it/ you faced the same? Couldn’t sign you in This browser or app may not be secure. Learn more Try using a different browser. If you’re already using a supported browser, you can try again to sign in.
Thank you, Koushi. I have a question: when I log in to google, I get the following message: "This browser or app may not be safe" error when trying to log in with Google in desktop apps. I'm using python
Hi Kaushik, Thanks for sharing your knowledge, I have scenario where need to test my application with multiple users at a time for load testing, can you help me to achieve this, Please share if any reference or docs.
Hi all, is it possible to call an api to get a token, save it in the session storage, and navigate the application? My problem is that the application needs a token from a SSO and I didn't find how to deal with it. Thanks!
Hi Koushik, My application uses Firebase authentication, so I can't use this. What are the other alternatives to bypass the OTP? Could you please help me?
Thanks, Koushig. It is great work. I've got problem. I use stroge method as you explained. But website logout. Do you know what is problem? I will be appreciate:)
Thank you ☺️. It's depends on the website implementation, might be your application won't work based on session or storage. Please confirm with your dev team.
Hi Koushik , Thank you for the playwright tutorial. Can you please add video for How to get browser specific cookie value using Playwright. many thanks
Hey I m recently facing issue while using waitForLoadState in build agent using CI/CD pipeline. Same code previously worked properly on build agents but now it's throwing error as TimeoutError: page.waitForLoadState: Timeout 30000ms exceeded.
@@letcode can we do it in automation job?.. if yes then how? How to update the auth.json since in video I can only see creation of auth.json using playwright code gen.. It will help me a lot
Hello Koushik, I'm sorry to write this in comment but I don't know how I can talk to you otherwise, I'm the guy with the problem of uplloading. I find your videos very interesting and thank you for those tutorials. I'm trying to test if a button of copy is working on my page but I don't know how to see what's in my clipboard once I clicked on copy. Thank you for your help, tou're the boss.
Hi, I have a solution for this in java. th-cam.com/video/Bt3v6ivGRxI/w-d-xo.html I'll check the same for node. Feel free to ask anything in comments ☺️. Thank u
@@letcode One question, is there another way to save cookies? Is that when creating a test for someone would not want to release the code and the person has to use npx. Thanks.
Works great!
This saves a lot of headaches trying to by-pass SSO, etc.
👍👍
Great vid! Saving so much time for my E2E tests.
Awesome 😎
Thank you koushik. It's very informative. excited to learn every day.
Thank you 😊
This is cool! Thanks a lot for posting this. It saved me a lot of time.
Glad you like it 😊
Clear Cut Explanation, but i have a doubt.
Can i use multiple cookies in same auth.json file. will it work or is there any other procedure
Yes, you can
Great Video, Its easy to setup but having a quick question how are you handling when the cookies expires after sometime as they have expiry time
Yes, we have to regenerate or we can use the fixture to generate and use it on the go.
It works great but I need some help. I have put this code in a test.beforeeach and then tried to run my first test. However, after it logs in perfectly, it doesn't run my first test. I think it happens because the first test is test('"test1', async ({ page }) => { and here it doesnt reference to the same page as it did in test.beforeeach. How can I solve this? It opens a new page and the new page is of course blank.
Hi, you can use test.use({storage state:auth.json})
Hey Koushik, Thank you for this video. I have few queries... If I want to log in to different test files using different login credentials, should I create a separate auth.json for each test file?
And if I want to log in to a single test file using different login credentials, how should I do this?
Could you please guide me?
Hi, yes different auth files for different users. For the same test with a different auth file I'm not sure, I'll look into it.
@@letcode Thanks
Hi Koushik,
const page = await context.newPage();
const ctxt = page.context();
ctxt.storageState()
What does this piece of code do in the test?
This will create a new context with page and storage state used to inject the cookies.
Hi sir. I create the playwright framework with bdd approach . But while running parallel execution once the test case failed it is opening one new browser and not able to load the url and cred. If possible can you please connect once?
I'm not sure how you have configured, can't help much with this without seeing the code.
We have a requirement to test email content ?Doest playwright supports this feature? I had googled it but was not able to find a proper one. It would be great if you suggest me regarding this. Thank you in advance
Playwright can scrape any pages, so technically possible.
This is great koushik! Thank you. As I test several apps in my current repo, can store more than one auth.json? Just by naming them differently I assume? auth1.json, auth2.json etc
Welcome. Of course you can.
@@letcode that worked fine yesterday, but today it does not work for me, until I did the manual codegen step again. Would I need to do the manual codegen step every day?
Thank You Koushik. It is really a great idea and it's helpful.
Can you please guide us how to handle untrusted SSL certificate with playwright ?
Sure I will
Has anyone else had problems with cookies? They are not being written in the browser context, but
if I run "console.log(await context.cookies())" the cookies are shown in the terminal...
Cookies won't be stored in the context.
It will be saved in a separate file.
Hi! How will it work with Microsoft Authentication? Codegen opens chrome in incognito mode by default, which doesn't support MFA. If you can share that idea too.
There is a way, I have read in this playwright GitHub issue.
You can check there.
awesome 😊,
how can we know if the cookie is expired or not ?
or we have to check the element wiht the login if it's present, thanks
It differs based on implementation, you can ask your developer.
Hi Koushik, I tried this code but this opens two browsers one blank and other with logged in state, due to which further steps fails as it tries to search for locators on blank browser, can you suggest some solution here
Hi, did you find out why 2 browsers are opening? I guess you have invoked twice.
@@letcode Not able to figure out why 2 browsers are opening, I am using
async loginUsingCookies( browser, baseURL) {
const context = await browser.newContext({
storageState: "./auth.json"
});
const page = await context.newPage();
await page.goto(`${baseURL}`);
await page.waitForTimeout(10000);
}
Can you pls help me here?
How can i use skip login while generating tests in different hook ..???
Within the test files you can use the test.use and within that you can pass the storage state
Hi koushik, while I'm trying to store the cookies using the same way, After giving the mail id. I'm getting this error in my chrome. Security issue is observed. What could be the issue? anyone please help if you have any views on it/ you faced the same?
Couldn’t sign you in
This browser or app may not be secure. Learn more
Try using a different browser. If you’re already using a supported browser, you can try again to sign in.
Yes, this is because of Google security.
You can create a new Google account and don't link your mobile, then you can use that account.
@@letcode thank you for the reply, will try & share the results.
Awesome bro...Keep it up...Thanks to you!
Thank you, Koushi. I have a question: when I log in to google, I get the following message: "This browser or app may not be safe" error when trying to log in with Google in desktop apps. I'm using python
Hi, that is because Google doesn't allow to automate their site, might be the issue i guess
@@letcode
Do you know how to solve this I need google login for my project
@@fernandomdcn2920 Google doesn't allow, if it's specific to gmail, then u can use the gmail API
Hi Kaushik, Thanks for sharing your knowledge, I have scenario where need to test my application with multiple users at a time for load testing, can you help me to achieve this, Please share if any reference or docs.
Hi, to do load testing, use Jmeter.
@@letcode we already have J meter but we are not able to test the UI
If u want to run the same script with multiple data, then refer to this video.
th-cam.com/video/CzQm-mVl4Hg/w-d-xo.html
Hi kaushik, can we do performance testing using playwright?
No, playwright is for functional UI and API testing.
Hello Koushik, is there a way we could add this to an before each hook so I do. Or need to type all of this into all of my test cases?
You can use it in hooks i think, but i didn't tried.
Hi all, is it possible to call an api to get a token, save it in the session storage, and navigate the application? My problem is that the application needs a token from a SSO and I didn't find how to deal with it. Thanks!
There is direct way to reuse the authentication using session storage.
Hi Koushik, My application uses Firebase authentication, so I can't use this. What are the other alternatives to bypass the OTP? Could you please help me?
OTP cannot be automated, you can disable the otp in the lower environment.
Have you tried with Jira? It seems cookies-based authentication doesn't work with Jira
As i said in the video, not all cookies will work, you have to ask developer help to understand how are the cookies work in the website 😊.
@@letcode I just retried and it worked normally. It was my mistake because I didn't wait for page to finish loading before storing the state.
@@thachnguyen5776 great 😊
My application uses MFA to login how can i automate the process of login where MFA requires Code to login? i am waiting for your reply :)
Not possible, MFA should be disabled in a lower environment..
How can I do this, handle 2 context and reuse cookies.json in python?
I don't know that much python, you can check the official documents concepts is same
Awesome bro. Great work. Is there any way to save cookie by writing code in test because the cookie is expiring in middle of tests.
It depends on the website bro, some cookies expires soon.
You can ask the dev team about it, they will tell about the expiration time.
@@letcode Thanks for replying on such short notice.
@letcode , I see that my application only saves the cookies but not the local storage . can i still use this ?
I guess so. U can give it a try
it did work without storing the local storage.Thanks @@letcode
Thanks, Koushig. It is great work. I've got problem. I use stroge method as you explained. But website logout. Do you know what is problem? I will be appreciate:)
Thank you ☺️.
It's depends on the website implementation, might be your application won't work based on session or storage.
Please confirm with your dev team.
@@letcode I tried on another application. It works. Thank you👍
Hi Koushik,
Getting 'Canva has experienced a technical issue. Please try again.' error message while logging with codegen
Might be issue with the application itself.
Not sure .
Is that auth.json file get expire? If yes what is tge validity period of that auth.json file.
It depends on the website, you have to ask your dev team about it.
Hey Koushik. Thank you for this. How can we get past the Azure AD authentication?
Hi, sorry i didn't get your question.
@@letcode I meant to ask, how do we handle single sign-on situations where the application uses the logged in user credentials directly.
First we have to generate the auth.json. then we can use it.
very informative !
I want to pass a token from api response in the storage state. In that case can you help me how to do that
I'll look into it
Hi Koushik is it possible to use this in POM model ?
Hi. Yes, you can generate the auth file, then in the test you can use test.use{
Storage state: auth.json
@@letcode tried and it works perfectly Thx
Hi Koushik , Thank you for the playwright tutorial. Can you please add video for How to get browser specific cookie value using Playwright. many thanks
Ok sure ☺️
Is there any video to bypass the captcha in Playwright?
That is not possible, in a lower environment it should be disabled.
@@letcode Thanks. That I know but I read somewhere about `playwright-stealth` library. I tried that but was facing some issues so just asked here.
I haven't used it.
Hey I m recently facing issue while using waitForLoadState in build agent using CI/CD pipeline. Same code previously worked properly on build agents but now it's throwing error as TimeoutError: page.waitForLoadState: Timeout 30000ms exceeded.
Is it working in local environment?
it's not logging in, it only shows the log in page without logging in....
It will work if everything is done properly.
Can you please put a video , how playwright works with browser extension. thanks
You mean to ask, how to add chrome extension?
How can we use this in test.beforeall , what we need to do in playwright.config ?
I have to check that bro 😊
Thanks Man. 😊😊😊
Welcome 😄
Super video
Thanks
what if i log out, do i need to change the auth.json again and again?
Yeah.
@@letcode can we do it in automation job?.. if yes then how?
How to update the auth.json since in video I can only see creation of auth.json using playwright code gen..
It will help me a lot
Hello Koushik, I'm sorry to write this in comment but I don't know how I can talk to you otherwise, I'm the guy with the problem of uplloading. I find your videos very interesting and thank you for those tutorials. I'm trying to test if a button of copy is working on my page but I don't know how to see what's in my clipboard once I clicked on copy.
Thank you for your help, tou're the boss.
Hi, I have a solution for this in java.
th-cam.com/video/Bt3v6ivGRxI/w-d-xo.html
I'll check the same for node.
Feel free to ask anything in comments ☺️.
Thank u
How do you do this with just APIs?
With extrahttps header you can pass the credentials or token.
Check the playwright API video.
There must be a better way as auth.json values will eventually expire and you won't be logged in.
Yes it will expire.
It is based on the session expiry settings.
Bro how to authenticate the TOTP (one time Password) ..in playwright
This cannot and should not be automated.
😄
Pls creat cucumber frame work tutorial 🙏
😱 3 vídeos. ....
When I started the channel I have uploaded 6 videos in a day 😂.
@@letcode One question, is there another way to save cookies? Is that when creating a test for someone would not want to release the code and the person has to use npx. Thanks.
@@letcode I've already used the user-agent but it's very instave.
Extension like cookies manager can be b used I guess.