Playwright Tutorial | Save and Reuse Authentication State | Skip Login

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ต.ค. 2024

ความคิดเห็น • 30

  • @WishInfinite
    @WishInfinite  7 หลายเดือนก่อน +4

    Playwright with TypeScript Series - th-cam.com/play/PL83cimSRP5ZmwhC6u255huRwSi9tlP-nc.html
    Recording Video - th-cam.com/video/JCpYFqdu2-c/w-d-xo.html
    Page Fixture Creation Video - th-cam.com/video/hEmTT4FV3-Q/w-d-xo.html
    POM with Fixtures - th-cam.com/video/qyCPtbEztvw/w-d-xo.html
    Playwright Shorts Series - th-cam.com/play/PL83cimSRP5ZlgDL11AGCufbTmADTOwHhO.html

  • @abhishekbhardwaj7764
    @abhishekbhardwaj7764 5 หลายเดือนก่อน +1

    This video is just awesome......Hats off bro...

    • @WishInfinite
      @WishInfinite  5 หลายเดือนก่อน +2

      @abhishekbhardwaj7764 Thank you so much for the kind words! I'm thrilled you enjoyed the video. Feel free to share it with your friends and spread the awesomeness! Let's keep the positivity flowing! 🚀✨

  • @MaheshJoshi_wellington
    @MaheshJoshi_wellington 7 หลายเดือนก่อน +1

    Just amazing 🎉

    • @WishInfinite
      @WishInfinite  7 หลายเดือนก่อน +1

      Thanks a ton! 😊

  • @roblesrt
    @roblesrt 6 หลายเดือนก่อน +1

    Thanks for sharing!

    • @WishInfinite
      @WishInfinite  6 หลายเดือนก่อน +1

      My pleasure!

  • @chandanav1290
    @chandanav1290 3 หลายเดือนก่อน +1

    Thanks sir 😊

    • @WishInfinite
      @WishInfinite  3 หลายเดือนก่อน +1

      Most welcome

  • @vigneshkumars8937
    @vigneshkumars8937 7 หลายเดือนก่อน +1

    explanation was amazing i saw the whole video and apply the concepts really amazing it works 😊 can you give explanation for playwright drag and drop

    • @WishInfinite
      @WishInfinite  7 หลายเดือนก่อน +1

      @vigneshkumars8937 Thank you for your kind words! Your support means a lot. 😊
      I have covered basic actions in Playwright, and addressing advanced actions is part of the plan. I will be including drag and drop functionality in that section.

    • @WishInfinite
      @WishInfinite  6 หลายเดือนก่อน +1

      @vigneshkumars8937 here is the video for Drag & Drop in Playwright - th-cam.com/video/Z2yAkGiDmBY/w-d-xo.html.

  • @eco89
    @eco89 7 หลายเดือนก่อน +1

    Keep it up.

    • @WishInfinite
      @WishInfinite  7 หลายเดือนก่อน

      Thank you for the encouragement!

  • @shreyanshjain2347
    @shreyanshjain2347 23 วันที่ผ่านมา +1

    Why can't we directly use the page fixture in the global setup file?
    Why do we need to get the page using chromium?

    • @WishInfinite
      @WishInfinite  22 วันที่ผ่านมา +2

      @shreyanshjain2347 In 3rd way which I explained, there you can use the page fixture directly, at 29:50 I used the page fixture and also explained why, you can revisit this section starting at 27:30 to get more information.

  • @yasirarfath4852
    @yasirarfath4852 22 วันที่ผ่านมา +2

    Hello sir, could you please assist me? I have a scenario with two users: one user logs in and submits a form, and the other user needs to approve it. How can I accomplish this? Your help would be greatly appreciated.

    • @WishInfinite
      @WishInfinite  17 วันที่ผ่านมา +2

      @yasirarfath4852 Do you want to perform above scenario by reusing authentication state ?

    • @yasirarfath4852
      @yasirarfath4852 16 วันที่ผ่านมา

      Yes, save and reuse authentication worked for other open source project but it didn't worked for my project ,Sir I am working on a project which is related to security ,here issue is one cookie is generated with that csrf token is also generated after login the token gets expired and we cannot reuse the cookie or or csrf token.And there is case where I submit the application form and then user has logout and another user have to login and then approve the form..
      How should I deal this scenario.What should be my approach should I use hooks or is there any better method for this.I have been stuck to this very long.More then 7 days.

    • @WishInfinite
      @WishInfinite  11 วันที่ผ่านมา

      @yasirarfath4852 If you're using the Page Object Model (POM) pattern, you can call the login and logout methods at any point in your test. The login method should accept username and password as parameters, allowing you to switch credentials during the test.
      In my video on Page Object Models, I created a login method that accepts username and password as inputs. You can check it out here: th-cam.com/video/IvaPYWteABc/w-d-xo.html .
      Feel free to ask any questions in the comments!

  • @paulofabiano6966
    @paulofabiano6966 5 หลายเดือนก่อน +1

    Hello, I am facing the following problem.
    When I use codegen I can capture Cookies and use the authentication state to perform other tests.
    However, when I try to use the other two ways, a JSON file is generated, but I cannot use the authentication state because the "value" field has no data.
    Would you help me

    • @WishInfinite
      @WishInfinite  5 หลายเดือนก่อน +2

      @paulofabiano6966 As you are getting blank storage state , what I am able to understand is that you are saving auth state before user is getting logged in properly.
      Into your Global.setup.js file just after logging in v you should provide waitForUrl and also one assertion for the element which is appearing after logging in successfully.
      These 2 lines of code should be there before using the storageState method.
      In this video at 30:49 I have mentioned it, try adding it and let me know the result.

    • @paulofabiano6966
      @paulofabiano6966 5 หลายเดือนก่อน +1

      @@WishInfinite Thank you my friend, the problem was with the variable. My code was not correctly inserting the login and password, when I passed the information instead of a variable, the JSON file saved the browser state and I was able to use it in subsequent tests.
      Thanks again for your help. Have a good day.

  • @MaksudaIslamLima
    @MaksudaIslamLima 4 หลายเดือนก่อน +1

    what if I want to pass the value of login credentials as parameter?

    • @WishInfinite
      @WishInfinite  4 หลายเดือนก่อน

      You can pass login credentials as by including them in a JSON file. I explain this process in my video at th-cam.com/video/8Xk48boYUJs/w-d-xo.html. If you want to configure different credentials for different environments, you can use DotEnv. I'll be adding a video about this to my playlist.

    • @MaksudaIslamLima
      @MaksudaIslamLima 4 หลายเดือนก่อน +1

      @@WishInfinite Thanks for the reply. I will look into it.
      Meanwhile another question, suppose I have different login credentials for different spec and one spec file can even have multiple login session. How can I handle it using global setup?
      N.B: What is Spec? Suppose I want to run the spec file for Login functionality, then I will run this comment:
      " npx playwright test --headed --project=chromium login.spec.js"
      Here, I am referring login.spec.js as spec file.

    • @WishInfinite
      @WishInfinite  4 หลายเดือนก่อน +1

      @@MaksudaIslamLima I would be creating one video for using different credentials for different environment, that should solve your problem of using different login credentials.
      And for running multiple session you can use parallel execution by setting fullyParallel and workers values in playwright.config.ts file.

  • @hameethaahamed7933
    @hameethaahamed7933 6 หลายเดือนก่อน +1

    how can we implement the same in js, I tried but when using the globalsetup it is not working

    • @WishInfinite
      @WishInfinite  6 หลายเดือนก่อน +1

      @hameethaahamed7933 Can you please share your playwright.config file, global file and test script file on wishinfinite01@gmail.com. I will have a look at it.

    • @WishInfinite
      @WishInfinite  5 หลายเดือนก่อน +1

      I received your mail related to your issue.
      As you are getting blank storage state , what I am able to understand is that you are saving auth state before user is getting logged in.
      Into your Global.setup.js file after clicking on submit button you should provide waitForUrl and also one assertion for the element which is appearing after logging in successfully.
      These 2 lines of code should be there before using the storageState method.
      In this video at 30:49 I have mentioned it, try adding it and let me know the result.