Playwright Beginner Tutorial 3 | How to run tests

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

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

  • @ruixue6955
    @ruixue6955 9 หลายเดือนก่อน +3

    2:39 meaning of *1 worker*
    4:42 parallel run option
    5:15 run by giving test file name
    8:05 run on specific browser
    8:57 headed mode
    9:51 debug
    12:04 breakpoint by giving line number

    • @RaghavPal
      @RaghavPal  9 หลายเดือนก่อน

      Thanks for adding 🙏🏻

  • @ZhiyuanShi-g3g
    @ZhiyuanShi-g3g ปีที่แล้ว +3

    thank you so much! you video is the ONLY one I can find that start from scratch and mentioned EVERY little details for a totally clueless beginner. Also, love the way you make your keypoints in one page for us to screenshot for later use.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Thanks a lot for the message Zhiyuan

  • @richakambo2636
    @richakambo2636 ปีที่แล้ว +6

    Hi Raghav, I have done first 3 tutorials on Playwright so far and got 10/10 on all 3 quizzes :) Thank you so much for taking the time and effort to explain the automation tool in simple and easy way.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Richa, Great Score, all the best

  • @lisazhou7776
    @lisazhou7776 2 ปีที่แล้ว +2

    I follow your video all the time. I used cypress to automate my project, that has many limitations. I found PlayWright is much better to open multiple tabs. Waiting for your video: 1 upload files from a folder 2 verify downloaded file 3 how to split test cases in multiple workers. Great job! really appreciate your hard work

  • @socialnetworkingtube
    @socialnetworkingtube ปีที่แล้ว +2

    Thank you so much for your tutorials - These are the best tutorials i have used so far
    I am new and beginner to Playwright and just by watching your tutorials i have developed interest in learning the tool
    Thank you so much again
    Lots of Good Wishes

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      You're very welcome Sujata

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

    Simple and straight to the point, thank you so much! you saved me a lot of time, now I can start automating with Playwright 👍

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

      Most welcome Ivan

  • @barehandstudio
    @barehandstudio ปีที่แล้ว +1

    i love how you over explain things, its boring but that is the important stuff that help you master it. thank you so much for your video.

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

    Hello Raghav Sir, thank you so much for your tutorials on Playwright.

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      You are most welcome Ashish

  • @cosminmatic5987
    @cosminmatic5987 7 หลายเดือนก่อน +2

    For the ones getting "No tests found": please make sure the file wanted to be run is saved in the location. An empty file could cause the error

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

      Thanks for adding Cosmin.. also try using forward slashes '/' in you file path

  • @sinthujaa
    @sinthujaa ปีที่แล้ว

    Hi Raghav! Your videos are very helpful and I'm learning automation in a easy way. Thank you! I took the quiz and scored 8/10

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Excellent Sinthuja

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

    brilliant and i really loved the way you demonstrated

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

      Thanks

  • @misn757
    @misn757 9 หลายเดือนก่อน

    Thank you for the gift of knowledge that you give so generously!

    • @RaghavPal
      @RaghavPal  9 หลายเดือนก่อน

      Thanks a lot for the support

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

    Hi Raghav, i cant see the details from code in the test report. This cannot be opened any further. I only see the main fields with the text and steps. Is there another way to show us how to make a POM and especially in combination with the recording function?

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

      Ahmed
      When using Playwright for testing, you can explore test reports in a few ways:
      1. HTML Reporter:
      - After your test completes, an HTML report is generated. It shows a full breakdown of your tests, including browsers used, test durations, and individual steps.
      - You can filter the report by browsers, passed tests, failed tests, skipped tests, and flaky tests.
      - Clicking on each test allows you to explore errors and view each step of the test
      2. Command Line Report:
      - You can see a concise report directly in the terminal using the `list` reporter. It prints a line for each test being run.
      - To enable step rendering, you can pass the `printSteps: true` configuration option¹.
      - Example usage:
      ```bash
      npx playwright test --reporter=list
      ```
      3. Browser Window Report (Debbie Codes):
      - Run the following command to open a browser window with a detailed report of your tests:
      ```bash
      npx playwright show-report
      ```
      - This report includes information about browsers used, test durations, and individual steps
      Remember that Playwright's built-in reporters provide different levels of detail, so choose the one that best suits your needs. If you're interested in creating a Page Object Model (POM) in combination with the recording function
      -

  • @bajafurious
    @bajafurious ปีที่แล้ว +1

    Hello Raghav. I need to say that you're very good teacher. Very clear and simple to understand. I have one question ... why, when I run any tests from Terminal, using (for example) command: npx playwright test .\tests\example.spec.js ... I got message : Error: No tests found ... ?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi,
      If you are running tests in Playwright using the command npx playwright test, you need to make sure that your tests are organized in a certain way so that Playwright can discover and run them.
      By default, Playwright looks for test files in a directory named tests, and for test files that have a name ending in .spec.js or .test.js. So if your test file is named example.spec.js, make sure it is located in a folder named tests in the root of your project directory.
      If your test file is located in a different directory or has a different name, you can specify the file or directory using the --test-match option when running the npx playwright test command.
      For example, if your test file is located in a directory named my-tests and has a name ending in .test.js, you can run the test using the following command:
      npx playwright test --test-match="./my-tests/**/*.test.js"
      Make sure to specify the correct path to your test file or directory.
      If you are still getting the error "No tests found", make sure that your test file contains at least one test case that is defined using the test function from a test runner such as Jest or Mocha. For example:
      const { test, expect } = require('@playwright/test');
      test('example test', async ({ page }) => {
      await page.goto('example.com');
      expect(await page.title()).toBe('Example Domain');
      });
      This test case uses the test function from the @playwright/test package to define a test named "example test". Make sure that your test file contains at least one test case defined in this way.

    • @erikpugh7028
      @erikpugh7028 ปีที่แล้ว +2

      try: npx playwright test example.spec.js (Just skip the '.\tests\' part and it should work)

  • @MicheleScianatico
    @MicheleScianatico ปีที่แล้ว +1

    Hi raghav, do you have a video in which you explain how to implement cucumber with playwright? Thank you

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Not yet, will work on it

  • @avex7447
    @avex7447 7 วันที่ผ่านมา

    I got 10/10 seems like i understand everything in the video! tysm seeyou next vid

    • @RaghavPal
      @RaghavPal  6 วันที่ผ่านมา

      Great job.. keep learning

  • @chandansharma-op9ik
    @chandansharma-op9ik 7 หลายเดือนก่อน

    Hi Raghav, thanks a lot for wonderful content, i am getting below error, seems command is correct and folder is also present :
    PS C:\Playwright_Test> npx playwright test .\tests\example.spec.js
    Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments.

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

      Chandan
      There are other comments with the same issue... pls check if any of those solutions work for you.. else you can check this:
      1. Check Test File Path:
      - Ensure that the path to your test file (`example.spec.js`) is correct.
      - Verify that the file exists in the specified location (`.\tests\example.spec.js`).
      2. Regular Expressions and Special Characters:
      - The error message suggests that you might need to escape special characters like "$" or "*".
      - Make sure your test file path doesn't contain any special characters that need escaping.
      3. Quoting Arguments:
      - If your test file path contains spaces or other special characters, consider enclosing it in double quotes:
      ```
      npx playwright test ".\tests\example.spec.js"
      ```
      4. Check File Content:
      - Ensure that your `example.spec.js` file contains valid test cases.
      - Verify that the test cases are correctly defined using Playwright's syntax.
      5. Update Playwright:
      - Make sure you're using the latest version of Playwright. Update it if necessary:
      ```
      npx playwright update
      ```
      6. Run with Absolute Path:
      - Try running the test with an absolute path instead of a relative path:
      ```
      npx playwright test C:\Playwright_Test\tests\example.spec.js
      ```
      7. Check Test Naming Convention:
      - Ensure that your test functions follow the correct naming convention (e.g., `test('should do something', async () => {...})`).
      8. Check Test Configuration:
      - Verify that your test configuration (e.g., `jest.config.js` or `playwright.config.js`) points to the correct test files.
      9. Debugging Logs:
      - If the issue persists, check the debug logs for more details:
      ```
      npx playwright test --debug .\tests\example.spec.js
      ```
      10. Reinstall Playwright:
      - If none of the above steps work, consider reinstalling Playwright:
      ```
      npm uninstall -g playwright
      npm install -g playwright
      ```
      Remember to adapt these steps based on your specific setup and requirements.
      ..

  • @monushh
    @monushh 2 ปีที่แล้ว

    Thanks, Raghav. Scored 9/10. It would have been great if the recording was made on a picture quality of more than 720p. Not sure if there is a setting on your side whilst recording that can be adjusted to provide better quality? But content is good as usual :)

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      I will see if I can do anything for Quality from my end Mohan

  • @JAYLATHIA
    @JAYLATHIA 2 ปีที่แล้ว

    Fast and easy teaching of commands...!

  • @Floweenka
    @Floweenka ปีที่แล้ว

    I had 10/10 in your quiz, it was nicely explained, thanks a lot!

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Well done Floweenka

  • @shwetawanjare5481
    @shwetawanjare5481 2 หลายเดือนก่อน

    Thanks Raghav for your efforts. My score was 8

    • @RaghavPal
      @RaghavPal  2 หลายเดือนก่อน

      Great Shweta.. keep learning and sharing

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

    Hi Raghav
    Can you advise based on screen shot,the error I'm getting
    PS C: ........................ \Documents\PLAYWRIGHT_VS_CODE> npx playwright test .\tests\example.spec.js
    Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments.
    To open last HTML report run:
    npx playwright show-report
    C: ........................ \Documents\PLAYWRIGHT_VS_CODE> npx playwright test .\tests\example.spec.js

    • @RaghavPal
      @RaghavPal  13 วันที่ผ่านมา

      Sinawo
      Try to use forward slashes in the path of your test file in the command like:
      npx playwright test ./tests/example.spec.js
      -

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

    I am using visual studio code and trying to learn playwright using C#. I want to run the code in HEADED mode and used command set HEADED=1 dotnet test but it is not running. Could you please help in this.

    • @RaghavPal
      @RaghavPal  2 หลายเดือนก่อน +1

      Ankita
      The command `set HEADED=1` is used to set an environment variable `HEADED` to `1`. This is correct.
      However, the `dotnet test` command is used to run unit tests in.NET, but it doesn't directly relate to Playwright or Headed mode.
      Check the Playwright configuration
      To run Playwright tests in Headed mode, you need to configure Playwright to use Headed mode. You can do this by setting the `headless` option to `false` in your Playwright configuration.
      In C#, you can do this by creating a `PlaywrightOptions` instance and setting the `Headless` property to `false`:
      ```csharp
      using Microsoft.Playwright;
      // Create a new instance of PlaywrightOptions
      var options = new PlaywrightOptions
      {
      Headless = false
      };
      // Launch the browser with the options
      using var playwright = await Playwright.CreateAsync(options);
      ```
      Run the tests
      Once you've configured Playwright to use Headed mode, you can run your tests as usual using the `dotnet test` command.
      Verify the environment variable
      Although you've set the `HEADED` environment variable, it's not necessary to set it explicitly. The `Headless` property in the `PlaywrightOptions` instance should be enough to run the tests in Headed mode.
      However, if you still want to use the environment variable, make sure it's set correctly before running the tests. You can do this by running the command `set HEADED=1` in your terminal or command prompt before running the `dotnet test` command.
      To summarize, you need to configure Playwright to use Headed mode by setting the `Headless` property to `false` in your Playwright configuration. Then, you can run your tests using the `dotnet test` command
      -

    • @ankitanag6753
      @ankitanag6753 2 หลายเดือนก่อน

      It's very detailed explanation thanks a lot.

  • @francesjen9093
    @francesjen9093 6 หลายเดือนก่อน

    Awesome posts!!!!!!!!It really helpfull and easy to understand !!!!!!Looking forward more videos !

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

      Great to know this Frances.. all the best

  • @SahilRajput03
    @SahilRajput03 ปีที่แล้ว

    Thankyou so much..!! Its very very amazing. I wish I had seen this video before!!! Amazing.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      You are welcome Sahil

  • @zwiterrion12
    @zwiterrion12 5 หลายเดือนก่อน

    Thank you. Quiz score 10/10

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      Great Kelly. keep learning

  • @AnushkaRamesh-v2n
    @AnushkaRamesh-v2n 9 หลายเดือนก่อน

    Hi Ragav! Thank you for posting detailed videos.They are very helpful for anyone starting to learn Playwright with no background. I want to know why some tests fail in "webkit" or "firefox" browser libraries but pass with just chromium.However the error shows that page timed out, in the terminal we see the reason is "the webpage has been blocked by our organization".If that's the case we shouldn't be able to run the testcase in chromium as well, right?

    • @RaghavPal
      @RaghavPal  9 หลายเดือนก่อน

      Anushka
      Here are potential reasons for the inconsistencies you're experiencing with Playwright tests across different browsers, along with troubleshooting steps:
      1. Browser-Specific Rendering or Behavior:
      Websites might render or behave differently in different browsers due to varying JavaScript engines, CSS implementations, or browser extensions.
      Inspect the website's behavior in each browser manually to identify discrepancies.
      Adapt your tests to handle browser-specific variations using conditional logic or Playwright's browser-specific selectors and actions.
      2. Browser Configuration or Settings:
      Check for inconsistencies in browser configurations like privacy settings, content blocking, or proxy settings.
      Ensure consistent configurations across browsers using Playwright's browser launch options.
      3. Playwright Version or Browser Compatibility:
      Update to the latest Playwright version for compatibility fixes.
      Consult Playwright's documentation for known compatibility issues between specific browser versions and Playwright.
      4. Network Issues or Firewall Rules:
      Investigate network restrictions or firewall rules that might selectively block certain browsers or websites.
      Review organization-wide policies and collaborate with IT if necessary.
      5. Timing Issues:
      Adjust timeout settings for page loads or actions to accommodate potential differences in loading times across browsers.
      Use explicit waits for specific elements or conditions to ensure tests proceed only when the page is ready.
      6. Debugging and Troubleshooting:
      Enable verbose logging or debugging in Playwright to gather more information about browser interactions.
      Isolate the problematic tests to narrow down the root cause.
      Test in different environments to rule out environment-specific issues.
      Specific to the "webpage blocked" error:
      Double-check organization policies and firewall rules to understand the exact restrictions.
      Check if Chromium has any exceptions or bypasses for these restrictions.
      Consider using a VPN or proxy to temporarily bypass restrictions for testing purposes if allowed within your organization.

  • @anilpoet4978
    @anilpoet4978 8 หลายเดือนก่อน

    PS F:\playwright> npx playwright test .\tests\example.spec.js
    Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments.
    Error came

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Anil
      Try to replace backslashes \ with forward slashes / in the path of test file in the command

  • @ramutalari8473
    @ramutalari8473 2 ปีที่แล้ว +1

    Hi Raghav, I found only 3 videos in Playwright tutorial. Could you please confirm only 3 videos posted so far OR Am I missing other videos?

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Hi Ramu, yes, will upload 4th today and rest coming in next few days

    • @ramutalari8473
      @ramutalari8473 2 ปีที่แล้ว

      @@RaghavPal Okay, thank you Raghav!!

  • @ashishnaidu2487
    @ashishnaidu2487 3 หลายเดือนก่อน

    Hi Raghav, could you please let me know what is End-to-End testing testing for a user story and how can we write an E2E tests as a manual tester?

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Ashish
      End-to-End (E2E) testing is a comprehensive approach that evaluates the entire software system by simulating real-world user scenarios from start to finish. Here's what you need to know:
      1. What is E2E Testing?
      - E2E testing ensures that the application works as expected from the end user's perspective
      - It covers the entire workflow, including the user interface, backend services, databases, and network communication
      - The goal is to validate overall behavior, functionality, reliability, performance, and security.
      2. Writing E2E Tests as a Manual Tester:
      - Identify test scenarios: Understand the user stories and identify the critical scenarios.
      - Map the steps in each scenario: Break down the user flow into specific steps.
      - Perform manual testing: Execute the steps manually to verify functionality.
      - Automate the tests: Once you've validated the manual steps, consider automating them using testing tools or frameworks.
      - Add your tests to the continuous integration (CI) pipeline for regular execution
      Remember, E2E testing helps ensure that your application behaves correctly across different layers and interfaces, providing a seamless experience for users
      --

    • @ashishnaidu2487
      @ashishnaidu2487 3 หลายเดือนก่อน

      @@RaghavPal Thank you so much for such a detailed explanation.
      Thanks a lot on guiding on how to write and perform E2E testing as a manual and automation tester, this really helps me a lot in understanding E2E testing in a broader way.

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

    Hi Raghav
    I was getting an error for web kit like below..version 1.44.1
    Running 6 tests using 6 workers
    1) [webkit] › example.spec.js:4:1 › has title ────────────────────────────────────────────────────
    Error: browserContext.newPage: Target page, context or browser has been closed
    2) [webkit] › example.spec.js:11:1 › get started link ────────────────────────────────────────────
    Error: browserContext.newPage: Target page, context or browser has been closed
    2 failed
    [webkit] › example.spec.js:4:1 › has title ─────────────────────────────────────────────────────
    [webkit] › example.spec.js:11:1 › get started link ─────────────────────────────────────────────
    4 passed (9.0s), out of 6 only 4 are passed

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Ramya
      The error you're encountering with Playwright and WebKit-specifically, the "Error: browserContext.newPage: Target page, context, or browser has been closed"-can be tricky to troubleshoot. Let's explore some potential solutions:
      1. Browser Context Lifecycle:
      - This error often occurs when a browser context or page is closed prematurely. Ensure that you're managing browser contexts correctly.
      - Make sure you're not closing a context or page before attempting to use it in subsequent steps.
      2. Webkit-Specific Issues:
      - WebKit might have specific quirks or limitations. Consider checking the Playwright documentation for any known issues related to WebKit.
      - Update Playwright to the latest version. Sometimes, newer versions include fixes for specific browser-related problems.
      3. Network Idle vs. DOMContentLoaded:
      - You mentioned using `networkIdle` for Chrome. Try using `domcontentloaded` instead for WebKit.
      - WebKit might behave differently during page navigation events. Adjust the wait strategy accordingly.
      4. Headless Mode:
      - You mentioned running the tests in headless mode. Try running them without headless mode to see if the issue persists.
      - If the issue disappears, it might be related to headless mode in WebKit.
      5. Debugging:
      - Add logging statements to your test steps. Print messages before and after each navigation action to see where the issue occurs.
      - Use `console.log` or similar methods to track the flow of your test.
      6. Playwright Updates:
      - Ensure you're using the latest version of Playwright. Run `npm install -D @playwright/test@latest` to update.
      - Check the release notes for any browser-specific fixes.
      Remember that debugging browser automation can be challenging, but systematically narrowing down the issue will help you find a solution.
      Good luck
      --

  • @prabaldutta
    @prabaldutta ปีที่แล้ว

    Hi @Raghav. You should have put video 4 in the position of 3 and swap them. You need to show how to write test before you run them.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Prabal, I added this first as we get a prebuilt set of tests on installing Playwright and it will be good to run something and see

    • @prabaldutta
      @prabaldutta ปีที่แล้ว

      @@RaghavPal Just gave my feedback as someone learning from your videos. It made more sense watching 4 then 3.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      ok

  • @AmirAlamgir-bh7ix
    @AmirAlamgir-bh7ix หลายเดือนก่อน

    Dear Sir i have faced below issue PS D:\playwright> npx playwright test .\tests\demo_orange.spec.js --project chromium --headed
    Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments

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

      mir
      in the path of test file try using single forward slashes /
      e.g
      D:\playwright> npx playwright test ./tests/demo_orange.spec.js --project chromium --headed
      also make sure path is correct

  • @ganimed11111
    @ganimed11111 10 หลายเดือนก่อน

    Question "Command to run with 3 workers in parallel" in the quiz, answers "npx playwright test --workers=3" and "npx playwright test --workers 3" are both correct and equal.
    Same with "Command to run on specific browser", "npx playwright test --project chromium" and "npx playwright test --project=chromium" are equal and will execute tests in chromium

    • @RaghavPal
      @RaghavPal  10 หลายเดือนก่อน

      will check this. Thanks for adding here

  • @abhishek150987
    @abhishek150987 ปีที่แล้ว

    Thank you Raghav for such a wonderfull series, Can you do some sessions on adding BDD to playwright ?

  • @hildajose1226
    @hildajose1226 9 หลายเดือนก่อน

    Thank you sir. You are really awesome! I got 10/10

    • @RaghavPal
      @RaghavPal  9 หลายเดือนก่อน

      Excellent Hilda

  • @kvsindhura
    @kvsindhura ปีที่แล้ว

    Hi Raghav.. your tutorials are excellent.. can you please do a tutorial on playwright with typescript please

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Sindhura, will plan for it

  • @cherrybros3
    @cherrybros3 ปีที่แล้ว +1

    Hello sir I'm a new suscriber I was trying to run a test on my Work tools however I may need to authenticate my Okta account otherwise the test will fail since it will not proceeded to the actual webpage, Is there any easy way to implement OKTA authentication to my tests, thanks and cheers

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Cherry,
      Yes, you can use the auth option of Playwright's Page.goto() method to authenticate with Okta. Here's an example:
      const { chromium } = require('playwright');
      const expectWebauthn = require('expect-webauthn');
      (async () => {
      const browser = await chromium.launch();
      const context = await browser.newContext();
      // Go to the Okta login page
      const page = await context.newPage();
      await page.goto('example.okta.com/');
      // Click the login button to trigger Okta authentication
      await page.click('#login-button');
      // Wait for the WebAuthn/FIDO2 authentication flow to appear
      await expectWebauthn(page).toDisplay({ timeout: 30000 });
      // Perform the authentication flow using a test credential
      await expectWebauthn(page).toAutoSubmit({
      timeout: 30000,
      credential: {
      id: 'test-credential-id',
      rawId: 'dGVzdC1jcmVkZW50aWFsLWlk',
      response: {
      authenticatorData: 'test-authenticator-data',
      clientDataJSON: 'test-client-data-json',
      signature: 'test-signature',
      userHandle: 'test-user-handle',
      },
      type: 'public-key',
      },
      });
      // Okta authentication should now be successful and you can proceed to test the actual webpage
      await page.goto('example.okta.com/my-account');
      // ...
      })();
      This example assumes that you have already registered a test credential in your Okta account and have its id, rawId, response, and type values. If you don't have these values, you can create a test credential using the webauthn-test-data library.
      Note that this is just a basic example and you may need to modify it based on your specific authentication flow and webpage.

  • @ConvenientCCLink
    @ConvenientCCLink 8 หลายเดือนก่อน

    Please do video on load testing with playwright and locust

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

      I will check and plan

  • @MiSsGaByCiTa
    @MiSsGaByCiTa 11 หลายเดือนก่อน

    This is awesome thank you so much!

    • @RaghavPal
      @RaghavPal  11 หลายเดือนก่อน

      You're so welcome!

  • @Venkateshvenky-vy1dd
    @Venkateshvenky-vy1dd 4 หลายเดือนก่อน

    Which one best for java or JavaScript to use playwright

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

      Venkatesh
      Both are good, its the users choice and project requirements that you will have to go with

  • @benvu4769
    @benvu4769 5 หลายเดือนก่อน

    Hi Raghav, my test cases failed with firefox and webkit, just passed with chromium. Can you tell me the problem? Thank you.

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      Ben
      It's not uncommon to encounter differences in test behavior across different browsers when using Playwright. Let's explore some potential reasons for the discrepancies you're observing:
      1. Browser-Specific Issues:
      - Firefox: Playwright tests may fail in Firefox due to various reasons. Some common issues include:
      - Network Logs: Network logs might not work out of the box for `playwright-firefox`. You can try specifying `ignoreHTTPSErrors: true` while creating a new context to enable network logs
      - Missing Dependencies: Ensure that all dependencies are installed. You can check the [Playwright CLI documentation](playwright.dev/docs/cli) for details on required dependencies
      - Webkit: You mentioned that Webkit fails with errors like "Element out of the ViewPort." This could be due to differences in rendering or viewport handling between Webkit and other browsers.
      2. Flakiness and Race Conditions:
      - Flakiness in test results can occur due to race conditions, timing issues, or asynchronous behavior. Here are some things to consider:
      - Await Statements: Ensure that you're using `await` correctly in your test code. Missing `await` can lead to unpredictable behavior.
      - Dependencies: Double-check that all asynchronous operations (e.g., network requests, element interactions) are properly awaited.
      - Parallel Execution: When running multiple tests with multiple workers, there might be race conditions. Consider using proper synchronization mechanisms (e.g., `Promise.all`, `waitFor`, etc.).
      3. Debugging Techniques:
      - To diagnose the issue further:
      - Set the `DEBUG=pw:api` environment variable to see detailed logs when Playwright interacts with the page
      - Inspect the failing test cases and look for patterns or commonalities in the failures.
      - Consider isolating specific test cases to narrow down the problem.
      4. Storage State Reuse:
      - You mentioned reusing the storage state from login to complete other tests. Ensure that the state is correctly maintained across tests.
      - Verify that the login state is consistent and not causing unexpected side effects.
      5. Viewport and Element Visibility:
      - For the "Element out of the ViewPort" issue, check if the viewport size differs between browsers. Adjust the viewport size if needed.
      - Verify that elements are consistently visible and interactable across browsers.
      Remember that cross-browser testing is essential to ensure robust test coverage

  • @sridharkatkam1852
    @sridharkatkam1852 10 หลายเดือนก่อน

    Error: Project(s) "Microsoft" not found. Available named projects: "chromium", "Microsoft Edge", "firefox", "webkit" - Error while running the test on edge. added the name: 'Microsoft Edge',
    use: { ...devices['Desktop Edge'], channel: 'msedge' },
    },
    in the config file. What is causing this error

    • @RaghavPal
      @RaghavPal  10 หลายเดือนก่อน

      Sridhar
      The error message "Error: Project(s) 'Microsoft' not found. Available named projects: 'chromium', 'Microsoft Edge', 'firefox', 'webkit'" indicates that Playwright is unable to find the project named "Microsoft" when you're running your tests on Edge. This error occurs despite having the following configuration in your file:
      ```
      name: 'Microsoft Edge',
      use: { ...devices['Desktop Edge'], channel: 'msedge' },
      ```
      This suggests that there might be a mismatch between the project name used in your test script and the one defined in your configuration file.
      Here are some potential causes and solutions for this error:
      *1. Inconsistent Project Names:*
      * Ensure the project name used in your test script and the configuration file matches exactly.
      * Verify if you're accidentally using "Microsoft" instead of "Microsoft Edge" anywhere in your code.
      * Double-check the spelling and case sensitivity of the project names.
      *2. Outdated Playwright Version:*
      * Make sure you're using the latest version of Playwright. Older versions might have different project names or require specific configurations.
      * Update your Playwright version to ensure compatibility and bug fixes.
      *3. Incorrect Configuration Syntax:*
      * Double-check the syntax of your configuration file, especially around the project name and `use` properties.
      * Refer to the Playwright documentation for the correct syntax for configuring projects.
      *4. Missing Browser Binaries:*
      * Playwright might not have downloaded the necessary browser binaries for Microsoft Edge.
      * Run `playwright install --with-edge` to download the required browser binaries.
      *5. Playwright Bugs:*
      * In rare cases, there might be bugs in Playwright affecting project recognition or configuration.
      * Check the Playwright bug tracker for any reported issues related to Edge project configuration.
      * If you suspect a bug, consider reporting it to the Playwright team with a detailed description and test case.
      *Here are some additional tips:*
      * Share your test script and the complete configuration file for further analysis.
      * Provide the version of Playwright you're using for specific troubleshooting steps.
      * Consult the Playwright documentation and community forums for assistance with your specific use case.
      By systematically analyzing the error message, exploring the potential causes, and implementing the suggested solutions, you should be able to resolve the "Error: Project(s) 'Microsoft' not found" issue and successfully run your Playwright tests on Edge.

  • @SouravKumarDey-rh5fn
    @SouravKumarDey-rh5fn 4 หลายเดือนก่อน

    Hello Raghav Sir,
    While running this , I am getting below error. Can you please guide me with this
    PS D:\Vs-Code> npx playwright test .\tests\example.spec.js
    Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments.

    To open last HTML report run:
    npx playwright show-report
    PS D:\Vs-Code>

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

      Sourav
      The error message you're encountering, "No tests found," is a common issue when running Playwright tests. It typically occurs due to configuration or path-related problems. Let's troubleshoot this together! Here are some steps you can take to resolve it:
      1. Check Your Test File Path:
      - Ensure that the path to your test file (`example.spec.js`) is correct.
      - Double-check that the file exists in the specified location (`.\tests\example.spec.js`).
      - Make sure there are no typos or missing directories in the path.
      2. Use Correct File Paths:
      - When specifying the test file path, use forward slashes (`/`) instead of backslashes (`\`) to separate directories.
      - Example:
      ```sh
      npx playwright test ./tests/example.spec.js
      ```
      3. Quotes and Special Characters:
      - If your test file path contains spaces or special characters, enclose it in double quotes.
      - Example:
      ```sh
      npx playwright test "./tests/my test file.spec.js"
      ```
      4. Escape Symbols:
      - If your test file path contains symbols like `$` or `*`, escape them using a backslash (`\`).
      - Example:
      ```sh
      npx playwright test "./tests/my\$test\*file.spec.js"
      ```
      5. Check Test File Content:
      - Ensure that your `example.spec.js` file contains valid test cases.
      - Verify that you have defined test functions (e.g., `it`, `test`, or `describe`) within the file.
      - If the file is empty or doesn't contain any tests, you'll encounter the "No tests found" error.
      6. Update Playwright:
      - Make sure you're using an up-to-date version of Playwright.
      - Run the following command to check your current version:
      ```sh
      npx @playwright/test --version
      ```
      - If needed, update Playwright to the latest version:
      ```sh
      npm install @playwright/test@latest
      ```
      7. Install Browsers:
      - Ensure that you've installed the necessary browsers (Chromium, Firefox, or WebKit) for Playwright.
      - Run the following command to install browsers:
      ```sh
      npx playwright install
      ```
      8. Run the Test Again:
      - After making the necessary adjustments, try running your test again:
      ```sh
      npx playwright test ./tests/example.spec.js
      ```
      Remember to adapt the commands above to match your specific file paths and test file names
      --

  • @arsman_ahmad
    @arsman_ahmad ปีที่แล้ว

    Thank you. You are really awesome! I got 10/10

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Most welcome Arsman

  • @binitpatel
    @binitpatel ปีที่แล้ว

    How to set headed by default? Like you always want to run test with browser Open. How can I set that in config file?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi, you can do from command line using --headed option, Not sure on config file, will need to check online

  • @knucklesmarks
    @knucklesmarks ปีที่แล้ว

    I love your videos, they're super helpful!
    Can I ask what tool you use to create the red squares in the video as seen at 2:30.
    I do lots of screen recordings when demonstrating bugs to my team and I would love to be able to bring attention to a section of the screen like that.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      I use mac annotation tools

    • @knucklesmarks
      @knucklesmarks ปีที่แล้ว

      @@RaghavPal Awesome, thanks so much!

  • @thelet3878
    @thelet3878 ปีที่แล้ว

    thank you ! can you do a video about comparing selenium playwright and puppeteer ?

  • @adi_sekar
    @adi_sekar ปีที่แล้ว

    Is there a watch mode to run tests, so we can make changes and run failing tests while developing

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Adithya, here is a discussion on this github.com/microsoft/playwright-test/issues/33

  • @chistar5988
    @chistar5988 5 หลายเดือนก่อน

    Thank you si much, I got 10/10

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      Great Chistar.. keep learning

  • @pawanpathak2728
    @pawanpathak2728 3 หลายเดือนก่อน

    I am getting this error while running npx playwright test command.
    1) [chromium] › example.spec.ts:10:5 › get started link ──────────────────────────────────────────
    Error: browserType.launch: spawn EPERM

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Pawan
      The error message you're encountering-`Error: browserType.launch: spawn EPERM`-indicates a permissions issue when launching Chromium. Let's explore some potential solutions:
      1. Permissions Issue:
      - Ensure that the user running the `npx playwright test` command has the necessary permissions to execute processes.
      - If you're on Windows, try running the terminal as an administrator.
      2. Browsers Installation:
      - Make sure you've installed the browsers required by Playwright. You can do this by running:
      ```
      npx playwright install
      ```
      - If you're using a custom installation path for browsers, set the `PLAYWRIGHT_BROWSERS_PATH` environment variable to point to the correct location. For example:
      ```
      export PLAYWRIGHT_BROWSERS_PATH=/path/to/your/browsers
      ```
      3. Docker Image Version (if applicable):
      - If you're using Playwright within a Docker container, consider pinning your Docker image to a specific Playwright version. For example:
      ```
      docker pull mcr.microsoft.com/playwright:v1.20.0-focal
      ```
      4. Use @playwright/test:
      - You don't need to have both `playwright` and `jest` installed. `@playwright/test` is sufficient for running Playwright tests.
      - Remove any unnecessary installations of `playwright` or `jest`.
      Remember to adapt these solutions based on your specific environment and requirements
      --

  • @Exerb1a
    @Exerb1a ปีที่แล้ว

    Great series , thank you

  • @saadshakil
    @saadshakil ปีที่แล้ว

    sir i got an error when i run the command "npx playwright test .\tests\example.spec.js"
    the error is "Error: No tests found"
    but when i run "npx playwright test"
    the commands runs successfully

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Saad
      The error "Error: No tests found" means that the Playwright test runner cannot find any tests to run. This can happen for a number of reasons, including:
      * The test file does not exist. Make sure that the test file exists and that it is in the current directory.
      * The test file is not a valid Playwright test file. Make sure that the test file is a valid Playwright test file. A valid Playwright test file must have the .spec.js extension and it must contain a function that is annotated with the @test() decorator.
      * The test file is not included in the test suite. Make sure that the test file is included in the test suite. The test suite is a list of files that are to be run by the Playwright test runner. You can specify the test suite by using the --suite option.
      Here are some steps on how to fix the error "Error: No tests found" in Playwright:
      1. Make sure that the test file exists.
      2. Make sure that the test file is a valid Playwright test file.
      3. Make sure that the test file is included in the test suite.
      If you have followed all of these steps and you are still getting the error "Error: No tests found", you can try searching for help online. There are a number of forums and websites that can help you troubleshoot this issue
      Here are some additional tips for running Playwright tests:
      * Use the --suite option to specify the test suite. This will allow you to run a specific test suite from the command line.
      * Use the --watch option to run the test suite continuously. This will allow you to see the results of the tests as they are run.
      * Use the --headless option to run the tests in headless mode. This will allow you to run the tests without a graphical user interface.
      I hope this helps

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

    Hi Raghav Sir, I am getting "Cannot find node module", How to resolve this?

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

      Rohini
      If you're encountering the "Cannot find module" error while using Playwright, there are a few steps you can take to resolve it:
      1. Check Playwright Installation:
      - First, ensure that you have Playwright installed in your project. You can install it using npm:
      ```
      npm install -D playwright
      ```
      - Make sure it's listed in your `package.json` under the `"dependencies"` or `"devDependencies"` section.
      2. Transpile TypeScript Manually (for @playwright/test):
      - If you're using TypeScript with `@playwright/test`, note that it doesn't consider your `tsconfig.json` when transpiling your TS files. Custom path mappings might not work as expected.
      - To transpile TypeScript manually, follow the instructions in the [Playwright documentation](playwright.dev/docs/test-typescript).
      - This workaround ensures that your custom path mappings are taken into account.
      3. Check Your tsconfig.json:
      - Verify that your `tsconfig.json` is correctly configured.
      - Ensure that the paths for your custom modules (like `@common/common`) are correctly defined.
      - Make sure the TypeScript compiler options match your project setup.
      4. Restart TypeScript Server (if needed):
      - Sometimes, IDEs might cache TypeScript information. Try restarting your IDE or the TypeScript server.
      - For Visual Studio Code, open the command palette (Mac: cmd+shift+p, Windows: ctrl+shift+p), type "restart ts," and select "TypeScript: Restart TS server."
      5. Check Your Project Structure:
      - Confirm that your project structure aligns with your TypeScript configuration.
      - Verify that your test files are in the correct location (usually `cypress/integration` for Playwright tests).
      6. Reinstall Playwright (if needed):
      - If you've tried everything else, consider reinstalling Playwright:
      ```
      npx playwright install
      ```
      ---

  • @cosminmatic5987
    @cosminmatic5987 6 หลายเดือนก่อน

    Hi Raghav! I tried to run a recorded test in debug mode but it got blocked. I quit the test and i got 'Testing stopped early after 1 maximum allowed failures. 1 failed [chromium] > record4_iPhone11_demo.spec.js:7:5 > test 2 did not run'. Could you please let me know what's the possible reason? I mention that when running without debug mode it works fine

    • @RaghavPal
      @RaghavPal  6 หลายเดือนก่อน

      When running your recorded test in debug mode, you encountered an issue where the test got blocked and stopped early. The error message you received indicates that there was a failure during the test execution. Let's explore some possible reasons for this behavior:
      1. Breakpoints and Pausing:
      - Debug mode allows you to set breakpoints in your test code. When a breakpoint is hit, the test execution pauses, allowing you to inspect variables, step through code, and troubleshoot.
      - Check if you have any breakpoints set in your test file. If a breakpoint is causing the test to pause indefinitely, it could lead to the test being blocked.
      2. Timeouts:
      - Debugging can sometimes cause tests to run slower due to additional processing and interactions with the debugging environment.
      - Ensure that your test has appropriate timeouts set. If a test step takes longer than the specified timeout, it may result in a failure.
      3. Browser Profile:
      - By default, Playwright uses the Chromium profile for debugging. However, you can debug your tests on different browsers.
      - Verify that the browser profile you're using for debugging is configured correctly. You can switch profiles to see if the issue persists.
      4. Strict Mode Violations:
      - Debugging may reveal strict mode violations or other issues that were not apparent during regular test execution.
      - Review your test code for any strict mode violations or other potential issues.
      5. VS Code Extension:
      - If you're using Visual Studio Code (VS Code), consider using the Playwright extension for a better debugging experience.
      - The extension allows you to set breakpoints, step through tests, and see error messages directly in VS Code.
      6. Live Debugging:
      - Take advantage of live debugging features in VS Code. You can interactively edit locators, pick elements, and see changes live in the browser window.
      - Ensure that you're using the correct locators for your test steps.

  • @shikshacomplete5049
    @shikshacomplete5049 ปีที่แล้ว

    Hi Raghav, I am working in an organisation and doing just manual testing .. but now in my project need to work with playwright.. but still I have no idea for automation.. ( know some basic knowledge)
    can you please help me that how can I learn automation step by step.. what I need to learn first .. I have seen your video for playwright but still not understanding from where I need to start to learn automation.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      If you need to work with Playwright, just start with it and learn whatever is needed along with Playwright. Basically you will be able to use playwright to automate basic web testing in a few days and then you can add to it as needed

    • @shikshacomplete5049
      @shikshacomplete5049 ปีที่แล้ว

      @@RaghavPal thank you 👍🏻.. You are doing great.. God bless you 🙏🏻

  • @munisamy.s4814
    @munisamy.s4814 22 วันที่ผ่านมา

    Hi Raghav, I have query related to browser.
    Whether playwright able to handle IE browser applications. Please confirm.

    • @RaghavPal
      @RaghavPal  21 วันที่ผ่านมา +1

      Muni
      Short Answer: No, Playwright does not support Internet Explorer (IE) browser applications out of the box
      Longer Explanation: Playwright is built on top of the browser's DevTools protocol, which is not available in Internet Explorer. IE uses a different automation API, called Internet Explorer Automation (IEA), which is not compatible with Playwright
      Workaround: If you need to automate IE, you can use other tools like Selenium WebDriver with the IE driver or Microsoft's own UI Automation API. However, these solutions have their own limitations and may not offer the same level of functionality as Playwright
      -

    • @munisamy.s4814
      @munisamy.s4814 21 วันที่ผ่านมา

      @@RaghavPal Thanks Raghav for your quick response

  • @poornimaa2246
    @poornimaa2246 ปีที่แล้ว

    Hi sir ..
    Whatever u showed in video..same thing I followed..
    Using this command npx playwright test it will run example.spec.js file ..
    While using specific file name like npx playwright test .\tests\example.spec.js
    It shows Error: no tests found ??

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Poornima
      When running Playwright tests using the command `npx playwright test`, you may encounter the "Error: no tests found" message if Playwright cannot locate any test files in the specified directory. This error typically occurs when there are no test files present or if the path to the test files is incorrect
      To resolve this issue, make sure to check the following:
      1. Verify the test file path: Double-check the path you provided for the test file (`.\tests\example.spec.js`). Ensure that the path is correct and that the file exists in the specified location. It's important to provide the correct relative or absolute path to the test file
      2. Check the file extension: Ensure that the test file has the `.spec.js` extension. Playwright looks for test files with this specific extension. If your test file has a different extension or if the file is not recognized as a test file, Playwright will not be able to find any tests
      3. Confirm the correct working directory: Make sure you are running the command from the correct working directory. The path you provide should be relative to the current working directory. Check that you are in the right directory when executing the command
      4. Verify the test file structure: Ensure that the test file follows the proper structure and contains valid tests. Each test file should have at least one test function defined using a test framework such as Jest or Mocha. Make sure your test file contains valid test cases that can be discovered by the test runner
      Once you have verified these aspects, try running the command again with the correct test file path. If the issue persists, consider checking for any additional error messages or logs that may provide further information about the problem
      It's also worth noting that Playwright supports various test frameworks, and you need to have the appropriate test runner and configuration set up to execute the tests correctly. Ensure that you have the necessary dependencies installed and the proper test framework configuration in place
      By following these steps and ensuring the correct file paths and test configurations, you should be able to run Playwright tests successfully using the specified file name

  • @debayudhchattopadyay5056
    @debayudhchattopadyay5056 ปีที่แล้ว

    Hi Raghav, how do we implement data driven testing with playwright? Read and write from excel or csv ?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +3

      Hi Debayudh,
      You can implement data-driven testing in Playwright by reading test data from external files like Excel or CSV, and then passing that data into your test scripts.
      Here's an example of how you can read data from a CSV file and use it in your Playwright test scripts:
      Install the csv-parser npm package using the following command:
      npm install csv-parser
      Create a CSV file containing your test data, with each row representing a separate set of test data. For example:
      username,password
      testuser1,pass123
      testuser2,pass456
      testuser3,pass789
      Create a Playwright test script that reads the data from the CSV file, and then iterates through each row to run the test with each set of data. Here's an example of what the test script could look like:
      const playwright = require('playwright');
      const csv = require('csv-parser');
      const fs = require('fs');
      // Read the CSV file containing test data
      const testData = [];
      fs.createReadStream('testdata.csv')
      .pipe(csv())
      .on('data', (row) => {
      testData.push(row);
      })
      .on('end', () => {
      // Iterate through each row of test data and run the test
      for (const data of testData) {
      describe(`Test with data: ${JSON.stringify(data)}`, () => {
      let browser;
      let context;
      let page;
      beforeAll(async () => {
      // Launch the browser and create a new context and page
      browser = await playwright.chromium.launch();
      context = await browser.newContext();
      page = await context.newPage();
      });
      afterAll(async () => {
      // Close the browser when the test is finished
      await browser.close();
      });
      test('Test Login', async () => {
      // Use the test data to fill in the login form
      await page.goto('example.com/login');
      await page.fill('#username', data.username);
      await page.fill('#password', data.password);
      await page.click('#submit');
      // Assert that the login was successful
      await page.waitForSelector('#welcome-message');
      const welcomeMessage = await page.textContent('#welcome-message');
      expect(welcomeMessage).toBe(`Welcome, ${data.username}!`);
      });
      });
      }
      });
      This test script reads the test data from the CSV file using the csv-parser package, and then iterates through each row of test data to run the test with that data. In this example, the test script logs in to a website using the username and password from the test data, and then asserts that the login was successful.
      You can modify this example to read test data from other types of external files, such as Excel or JSON, by using the appropriate libraries or packages to parse those file formats.

  • @adorevijayss
    @adorevijayss 27 วันที่ผ่านมา

    Hi Raghav, I need to get videos for Playwright with Java..language added over

    • @RaghavPal
      @RaghavPal  27 วันที่ผ่านมา

      I will plan on this Vijayan

  • @manojkumar-wt2sv
    @manojkumar-wt2sv 2 ปีที่แล้ว

    Thanks for your dedication sir 🙏

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว +1

      Most welcome Manoj

  • @jesuss0777
    @jesuss0777 ปีที่แล้ว

    Hello
    I followed all steps but when I come to run test with "npx playwright tests" I got this ------> error: unknown command 'tests' . Can you please help me

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      The command is *npx playwright test*

  • @ashishnaidu2487
    @ashishnaidu2487 8 หลายเดือนก่อน

    Hi Raghav, I have query please that we can use C# language in writing code for automation in Playwright, but while installation we have selected JavaScript language. So, how can we change it to C# please or will it allow to run the tests when we write code in C# please?

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Ashish
      Unfortunately, you cannot directly use C# for writing automation tests in Playwright when you've installed it with JavaScript language selected. Playwright is designed with specific language bindings for each supported language, and the installation process sets up the necessary files and configurations for the chosen language.
      However, there are a few options to address your situation:
      1. Reinstall Playwright with C# support:
      The recommended approach is to reinstall Playwright with C# support enabled. Here's how:
      * Uninstall the current Playwright installation.
      * Use the following command to reinstall Playwright with C# support:
      ```
      npm install --save-dev playwright @playwright/csharp
      ```
      * This will install the necessary C# libraries and configure Playwright for C# development.
      2. Use the Playwright Sharp library:
      While not officially supported by the Playwright team, the Playwright Sharp library allows you to write automation tests in C# for Chromium, WebKit, and Firefox. Here's what you need to do:
      * Install Playwright Sharp using NuGet:
      ```
      Install-Package PlaywrightSharp
      ```
      * Configure Playwright Sharp by referencing the appropriate libraries and setting up drivers. Refer to the Playwright Sharp documentation for detailed instructions:
      3. Consider alternative tools:
      If C# is a strict requirement for your project, other automation testing tools like Selenium offer better support for C#. While Playwright offers some unique features, tools like Selenium may be a suitable alternative.
      Important Note:
      Regardless of the approach you choose, remember that writing tests in a language different from the installation language requires additional configuration and maintenance. Consider the long-term implications and maintenance overhead before choosing a solution.
      I hope this clarifies your options and helps you move forward with your automation project

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

      @@RaghavPal Thank you so much for explaining it in detailed manner and guiding me in the right path for my query.

  • @swapnakulkarni3758
    @swapnakulkarni3758 ปีที่แล้ว

    I want to run the code only in chrome and edge, but since i have selected chrome, edge and firefox browsers while doing 'Test: Install playwright', all the 3 browsers are being used. How to unselect firefox now?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Swapna
      There are two ways to unselect Firefox in Playwright:
      1. **Using the Playwright API:**
      ```js
      // Import the Playwright API.
      const { chromium, edge } = require('playwright');
      // Create a new browser context using the Chromium browser.
      const browser = await chromium.launch({ headless: true });
      // Create a new page in the browser context.
      const page = await browser.newPage();
      // Unselect Firefox from the list of available browsers.
      await browser.use({ browsers: [chromium, edge] });
      // Navigate to the desired URL.
      await page.goto('example.com');
      // ...
      ```
      2. **Using the Playwright CLI:**
      ```
      npx playwright test --browsers chromium edge
      ```
      This will launch the test runner with only the Chromium and Edge browsers.
      To unselect Firefox permanently, you can edit the `PLAYWRIGHT_BROWSERS` environment variable. This variable specifies the browsers that Playwright will use by default. To unselect Firefox, set the `PLAYWRIGHT_BROWSERS` environment variable to a comma-separated list of the browsers that you want to use, excluding Firefox.
      For example, to unselect Firefox and use only Chromium and Edge, you would set the `PLAYWRIGHT_BROWSERS` environment variable to the following:
      ```
      export PLAYWRIGHT_BROWSERS=chromium,edge
      ```
      Once you have unselected Firefox, you can run your Playwright tests as usual and only the Chromium and Edge browsers will be used.

  • @bhagyalakshmibadiginchala38
    @bhagyalakshmibadiginchala38 ปีที่แล้ว

    Hi Raghav, Also May I know in which file I can see the execution time of steps?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Sure, you can see the execution time of steps in the Playwright test report. The test report is a file that is generated after you run your tests. It contains information about each test, including the execution time of each step.
      To view the execution time of steps in the Playwright test report, you can use the following command:
      ```
      npx playwright test --report playwright-report.html
      ```
      This will generate a file called `playwright-report.html` in the current directory. You can open this file in a web browser to view the test report.
      The execution time of each step is shown in the "Steps" section of the test report. The time is shown in milliseconds

  • @cardozclive
    @cardozclive 2 หลายเดือนก่อน

    @Raghav for me npx playwright test .\tests\example.spec. doesn't work. It shows an error "Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments."

    • @RaghavPal
      @RaghavPal  2 หลายเดือนก่อน +1

      Clive
      Please try by adding a single forward slash / in the path of file in your command, e.g.:
      npx playwright test tests/example.spec.js
      Here are a few things you can check to resolve the "No tests found" error:
      1. File Naming: Ensure your test file has the correct suffix, such as `.spec.js` or `.test.js`. Playwright looks for these specific suffixes to identify test files⁴.
      2. File Path: Double-check the file path you're providing. It should be relative to the root of your project. For example, if your test file is located in the `tests` folder, the command should be:
      ```bash
      npx playwright test tests/example.spec.js
      ```
      3. Escaping Symbols: If your file path contains special characters like `$` or `*`, make sure to escape them or quote the entire path. For example:
      ```bash
      npx playwright test "tests/example.spec.js"
      ```
      4. Configuration File: Verify that your `playwright.config.js` or `playwright.config.ts` file is correctly set up and points to the directory containing your tests. The `testDir` property should be set to the folder where your test files are located
      5. Empty Test Files: Ensure that your test files are not empty and contain valid test cases. Playwright will throw an error if it doesn't find any test cases in the specified files
      -

    • @Arunkumar-tn5bk
      @Arunkumar-tn5bk หลายเดือนก่อน

      @@RaghavPal Thanks Raghav, I am facing same error but it got resolved by changing testDir folder path

  • @juanlofredo7044
    @juanlofredo7044 2 ปีที่แล้ว

    can you, like, press a button(that you amde with html), thtas trigger the test?? so you dont have to no npx test all day long?

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      will need to check on this Juan

  • @jaiasreepalanivel1604
    @jaiasreepalanivel1604 8 หลายเดือนก่อน

    When we run the test script "npx playwright test --project=chromium" it Running on 2 test using 2 workers . What actually it mean ? It should run only on one browser specfic ? Can you please clarify it ?

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Jaiasree
      When you run `npx playwright test --project=chromium`, the command tells Playwright to execute your tests using the Chromium browser. Playwright uses workers to parallelize test execution for efficiency. In the message you received, Running on 2 tests using 2 workers means:
      2 Tests: There are 2 test files/suites to be executed in your project.
      2 Workers: Playwright has launched 2 separate worker processes to run these tests in parallel. This improves execution speed by running both tests concurrently on your machine.
      It will not necessarily run only on one browser. By default, Playwright runs tests in parallel across all browsers specified in your project configuration. So, if you don't have any specific browser configured, it will use all available browsers (usually Chromium, Firefox, and WebKit).
      To run tests only on a specific browser:
      1. Use the `--browser` flag:
      ```
      npx playwright test --project=chromium --browser=chromium
      ```
      This will execute tests only in Chromium. You can replace `chromium` with `firefox` or `webkit` for other browsers.
      2. Configure the project:
      You can set the default browser in your `playwright.config.js` or `playwright.config.ts` file:
      ```javascript
      module.exports = {
      projects: [
      {
      name: 'chromium',
      use: {
      browser: 'chromium',
      },
      },
      ],
      };
      ```
      This configures the `chromium` project to use only the Chromium browser by default.
      Remember that running tests in parallel can benefit from multiple cores or threads on your machine. If you have limited resources, consider adjusting the number of workers with the `--workers` flag:
      ```
      npx playwright test --project=chromium --browser=chromium --workers=1
      ```
      This will run tests in Chromium with only 1 worker, effectively simulating single-browser execution.
      I hope this clarifies how Playwright handles test execution and options for running tests in specific browsers

  • @bhagyalakshmibadiginchala38
    @bhagyalakshmibadiginchala38 ปีที่แล้ว

    Hi Ragav,
    I can see 4 workers in my pc but in the report i could see only 3 browsers "chromium,firefox and webkit". Could you please let me know why there is difference in number?
    Running 6 tests using 4 workers
    6 passed (21.9s)

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Bhagyalakshmi
      here is why you might see a difference in the number of workers and browsers in Playwright:
      *You are running different tests on different browsers:* If you are running different tests on different browsers, each test will be run in a separate worker. For example, if you are running 6 tests, each using a different browser, you will see 6 workers and 6 browsers in the report
      *You are using different browser versions:* If you are using different browser versions, each version will be run in a separate worker. For example, if you are running 6 tests, each using a different version of Chrome, you will see 6 workers and 6 browsers in the report
      *You are using different browser profiles:* If you are using different browser profiles, each profile will be run in a separate worker. For example, if you are running 6 tests, each using a different profile of Chrome, you will see 6 workers and 6 browsers in the report
      In your case, it sounds like you are running 6 tests, each using a different browser. This would explain why you see 4 workers and 3 browsers in the report.
      Here are some additional things to keep in mind:
      *The number of workers and browsers may not match exactly:* The number of workers and browsers may not match exactly, depending on the specific tests that you are running. For example, if you are running a test that requires two browsers, it will be run in a single worker
      *The number of workers and browsers may change over time:* The number of workers and browsers may change over time, depending on the resources that are available on your machine. For example, if you are running a lot of tests at the same time, Playwright may create more workers and browsers to handle the load.
      I hope this helps

  • @ihouyung
    @ihouyung ปีที่แล้ว

    help me please, I run npx playwright test .\tests\test-1.js" but returned "Error: No tests found " What can I do ?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      If you are encountering the error "Error: No tests found" when running `npx playwright test`, it typically means that Playwright was unable to locate any test files in the specified directory.
      Here are a few suggestions to resolve the issue:
      1. Check the test file path: Double-check that the path you provided, `.\tests\test-1.js`, is correct and that the test file actually exists in that location. Make sure the file extension is `.js` for JavaScript test files.
      2. Confirm the test file structure: Ensure that your test file follows the correct structure for Playwright tests. It should typically include imports for Playwright, test functions or test suites, and assertions. Here's a basic example:
      ```javascript
      const { chromium } = require('playwright');
      (async () => {
      const browser = await chromium.launch();
      const page = await browser.newPage();
      // Your test code here
      await browser.close();
      })();
      ```
      3. Verify the test framework: Make sure you are using a supported test framework (e.g., Jest, Mocha, or Jasmine) to define and execute your tests. Playwright integrates with these frameworks to run tests.
      4. Install necessary dependencies: Ensure that you have all the required dependencies installed. Run `npm install` to make sure you have the necessary packages specified in your `package.json` file.
      5. Check Playwright version: Ensure that you have the latest version of Playwright installed. You can run `npm outdated playwright` to check for updates and `npm update playwright` to update to the latest version.
      By verifying these aspects, you should be able to resolve the "Error: No tests found" issue and successfully run your Playwright tests.

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

    Hi Raghav, i am following the same steps but i don't know when I am running npx playwright test to run the sample it says ERROR: no tests found. Even though i can see 'example.spec.js' under test folder. Could you please guide asap. Thanks

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

      no worries, it's resolved now :)

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

      Great, can post your solution here to help others

  • @nisharani4624
    @nisharani4624 10 หลายเดือนก่อน

    Hi Raghav, could you let me know the keyboard short key to get the .\test\filename while writing command in terminal

    • @RaghavPal
      @RaghavPal  10 หลายเดือนก่อน

      Nisha, You just start typing and press tab on your keyboard

  • @DJChan-dn9tb
    @DJChan-dn9tb 4 หลายเดือนก่อน

    I am trying to find the best opensource automation tool to automate an application that the main functionality is in an html canvas. I need to select things from the canvas and drag and drop them. Coordinates are not preferred as they can change so looking for a tool that can locate an image within an image and then perform mouse operations. Any help is appreciated.

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

      Sure, I can suggest a few tools that might be helpful for automating operations on an HTML canvas:
      1. Cypress: Cypress is a powerful end-to-end testing framework that can interact with the DOM, making it a good choice for testing applications with an HTML canvas. There's also a plugin called `cypress-plugin-snapshots` that supports visual regression testing, which could be useful for your use case
      2. Selenium: Selenium is another popular open-source automation tool that supports multiple browsers and operating systems. It allows you to write automated tests for web applications and has wide community support.
      3. Telerik Test Studio: Although not open-source, Telerik Test Studio has added support for many of the HTML5 tags like Canvas, Audio, and Video tags. All the HTML tags are accessible using code and are under the `ArtOfTest.WebAii.HtmlControls` namespace. For the `HtmlCanvas`, you actually have access to the 2D Context of the control
      Remember, each tool has its own strengths and weaknesses, and the best tool often depends on your specific needs and context. It's a good idea to try out a few different tools to see which one works best for your application
      ---

  • @sergiovillagomez7322
    @sergiovillagomez7322 2 ปีที่แล้ว

    Thanks for your dedication :)

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Most welcome

  • @premsudheer2092
    @premsudheer2092 ปีที่แล้ว

    Hi Raghav,
    How to maximize browser during launch in playwright ??

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Prem
      To maximize the browser window during launch in Playwright, you can use the `--maximize` flag when launching the browser. Here's an example in JS:
      const { chromium } = require('playwright');
      (async () => {
      const browser = await chromium.launch({ headless: false, args: ['--start-maximized'] });
      const context = await browser.newContext();
      const page = await context.newPage();
      // Rest of your code...
      })();
      In this example, the `--start-maximized` argument is passed to the browser's `launch` function, which will maximize the browser window when it is launched. Adjust the code according to the browser you are using (e.g., `chromium`, `firefox`, `webkit`).
      By setting `headless=False`, the browser window will be visible. If you want to run in headless mode, you can remove the `headless=False` argument.
      Remember to import the necessary modules and adjust the code based on your specific use case.

  • @savithabs-f9e
    @savithabs-f9e 7 หลายเดือนก่อน

    What is the difference between cmd using debug with line number and cmd with specifying the test & debugging. I saw no difference . if no difference what is the use?

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

      Savitha
      In Playwright, when it comes to debugging tests, there are two primary methods using the command line:
      1. Using `debug` with Line Number:
      - Syntax: `npx playwright test --debug /:`
      - Purpose: Sets a breakpoint directly on the specified line number within a test file, pausing execution upon reaching that point.
      - Advantages:
      - Granular control over test execution, allowing you to inspect variables, step through code line by line, and examine the page state at a specific point.
      - Useful for isolating complex issues within a single test.
      - Disadvantages:
      - Requires knowing the exact line number where the problem occurs, which might not always be easy to pinpoint.
      - Can be time-consuming for debugging multiple issues or when the exact line is unclear.
      2. Specifying the Test & Debugging:
      - Syntax: `npx playwright test --debug --grep ""`
      - Purpose: Runs the entire test suite or a group of tests matching the provided regular expression, launching the Playwright Inspector for debugging.
      - Advantages:
      - More efficient for debugging multiple tests or broader issues affecting parts of the test suite.
      - Provides an interactive UI for examining page elements, inspecting network requests, and experimenting with changes on the fly.
      - Disadvantages:
      - Less precise than direct line-number breakpoints, requiring some exploration within the Inspector to diagnose problems.
      - Debugging all tests can be slow for large test suites.
      Choosing the Right Approach:
      - For pinpoint debugging or isolated issues: Use `debug` with line number.
      - For broader debugging or issues affecting multiple tests: Specify the test & debug.
      Additional Considerations:
      - Browser Selection: Use `--browser ` (e.g., `--browser chromium`) to target specific browsers.
      - Headless/Headed Mode: Control browser visibility with `--headed` or `--headless`.
      - Configuration Overrides: Modify Playwright settings using command-line arguments or a configuration file.
      Example:
      Suppose you suspect an issue on line 25 of `test_login.spec.ts` within the `login` test:
      ```bash
      npx playwright test --debug login/test_login.spec.ts:25
      ```
      This sets a breakpoint on line 25, allowing you to step through the test execution and investigate the problem in detail.
      ..

    • @savithabs-f9e
      @savithabs-f9e 7 หลายเดือนก่อน

      @@RaghavPal Thanks for the information, I kind of understood , but given the line number for the debug , it has to be the start of test right ? (where we use test as the keyword). I might be wrong , please clarify

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

      Savitha
      Here are the different ways to debug tests and their purposes:
      1. Debugging Tests with Line Numbers:
      - When you run a test using the command line with a specific line number, Playwright opens the inspector at that exact line in your test file.
      - Purpose:
      - Allows you to set breakpoints directly in your test code.
      - You can step through the test line by line, inspect variables, and analyze the flow.
      - Useful for pinpointing issues within a specific test case.
      - Command:
      ```
      npx playwright test your-test-file.spec.ts:line-number --debug
      ```
      2. Debugging Tests with Test Name:
      - When you specify the test name (instead of a line number), Playwright runs that specific test and opens the inspector.
      - Purpose:
      - Focuses on a particular test scenario.
      - Useful for debugging a specific test without navigating through the entire test file.
      - Command:
      ```
      npx playwright test your-test-file.spec.ts --test "Your Test Name" --debug
      ```
      3. Playwright Inspector:
      - The Playwright Inspector is a GUI tool that provides a visual interface for debugging.
      - Purpose:
      - Allows you to step through your tests, live edit locators, pick locators, and see actionability logs.
      - Provides a more interactive debugging experience.
      - Command:
      ```
      npx playwright test your-test-file.spec.ts --debug
      ```
      - The `--debug` flag opens the inspector.
      4. VS Code Extension for Debugging:
      - For an even better developer experience, use the VS Code extension for debugging.
      - Purpose:
      - Debug your tests directly in VS Code.
      - Set breakpoints, step through tests, and see error messages.
      - Live edit locators and pick locators.
      - Benefits:
      - Error messages are shown in the editor.
      - You can interactively debug your tests.
      - Easily switch between different browsers for debugging.
      - Use the Playwright Inspector within VS Code.

  • @KusumdeviVishwakarma-i3g
    @KusumdeviVishwakarma-i3g ปีที่แล้ว

    Hi Raghav, i am not able to go in my folder by command can you help me with this 'npx Playwright test .\tests\example.spec.js example.spec.js' getting no tests found error.
    And also if i don't give no of worker still getting 6 workers sometime 3 workers

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Kusumdevi,
      To navigate to the folder containing your Playwright tests, you can use the cd command in your terminal. For example, if your tests are located in a folder named tests, you can navigate to that folder by running the following command:
      cd tests
      Once you are in the tests folder, you can run your Playwright tests using the following command:
      npx playwright test example.spec.js
      To navigate to the folder containing your Playwright tests, you can use the cd command in your terminal. For example, if your tests are located in a folder named tests, you can navigate to that folder by running the following command:
      bash
      Copy code
      cd tests
      Once you are in the tests folder, you can run your Playwright tests using the following command:
      bash
      Copy code
      npx playwright test example.spec.js
      This assumes that your example.spec.js file is located in the tests folder.
      Regarding the number of workers, Playwright by default uses the number of logical cores on your CPU to determine the number of workers to use for parallel test execution. If you want to override this default behavior and set the number of workers explicitly, you can use the --workers option. For example, to set the number of workers to 3, you can use the following command:
      npx playwright test --workers=3 example.spec.js
      If you do not specify the --workers option, Playwright will use the default behavior of determining the number of workers based on your CPU's logical cores.

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

    Hi I have a doubt that if I need to run a playwright script that is present in another folder not in same folder which the test folder of playwright script is present is that possible to run that script which command do I need to use

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

      You can run a Playwright script from a different folder using the npx command. Here's an example:
      Let's say your script is located in a folder called scripts and your test folder is located in a folder called tests. The directory structure would look like this:
      project/
      scripts/
      script.js
      tests/
      test.js
      ...
      To run the script.js from the tests folder, you can use the following command:
      npx playwright run scripts/script.js
      This will execute the script.js script located in the scripts folder.
      If you want to run the script from a specific folder, you can use the --cwd option to specify the working directory. For example:
      npx playwright run --cwd ../scripts script.js
      This will run the script.js script from the scripts folder, but with the working directory set to the scripts folder.
      Note that you can also use the --config option to specify a custom configuration file. For example:
      npx playwright run --config ../scripts/playwright.config.js script.js
      This will use the playwright.config.js file located in the scripts folder as the configuration file for the script
      -

  • @rajkumaraadepu3951
    @rajkumaraadepu3951 ปีที่แล้ว

    Hi Sir,
    I tried to run the test using the following command
    npx playwright test .\tests\example.spec.js
    but it is saying no tests found.
    Please reply for this.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Rajkumar,
      There could be several reasons why the tests are not being found by the npx playwright test command. Here are some possible solutions to try:
      Check the file path:
      Make sure that the file path to the test file is correct. Double-check that the file is located in the specified directory and that the file name is spelled correctly.
      Check the test file name:
      Make sure that the test file is named with a .spec.js extension. If the file extension is different, the test runner might not recognize the file as a test file.
      Check the test function name:
      Make sure that the test function in the test file is named with the prefix "test". For example, a test function should be named "testExample" rather than "example".
      Check the test runner configuration:
      Check the configuration file for the test runner to ensure that it is configured correctly. The configuration file is usually named playwright.config.js. Make sure that the file is located in the correct directory and that it specifies the correct test directory.
      Check the test runner version:
      Make sure that you have the latest version of the test runner. Run npx playwright test --version to check the version number, and then compare it with the latest version available on the official Playwright website.
      Check for syntax errors:
      Make sure there are no syntax errors in the test file or any of the imported modules. Syntax errors can cause the test runner to fail to recognize the test file.
      Hopefully, one of these solutions helps you resolve the issue

  • @barbaroscelik1084
    @barbaroscelik1084 ปีที่แล้ว

    Is there a videoe where you show how playwright works with github?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Not yet, will do a session on this

  • @MohitSrivastava-c9c
    @MohitSrivastava-c9c 8 หลายเดือนก่อน

    Can we test accessibility using playwright if yes can pls guide me

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Mohit
      Yes, you can test accessibility using Playwright. While it doesn't have built-in accessibility-specific features, its capabilities and integration with axe-core make it a powerful tool for accessibility testing.
      Here's a guide to conducting accessibility tests with Playwright:
      1. Install axe-core:
      - Axe-core is a popular open-source accessibility testing library. Add it to your project using npm or yarn:
      ```bash
      npm install axe-core --save-dev
      ```
      2. Integrate with Playwright:
      - Import axe-core in your Playwright test script:
      ```javascript
      const { axe, injectAxe } = require('axe-core');
      ```
      3. Inject axe-core into the page:
      - Use Playwright's `evaluate` function to inject axe-core into the page context:
      ```javascript
      await page.evaluate(injectAxe);
      ```
      4. Run accessibility checks:
      - Trigger accessibility checks using axe-core's `run` function:
      ```javascript
      const results = await page.evaluate(() => axe.run());
      ```
      5. Analyze results:
      - The `results` object contains identified accessibility violations. Iterate through them for reporting and analysis:
      ```javascript
      for (const result of results.violations) {
      console.log(`Violation: ${result.id} - ${result.description}`);
      // Handle the violation (e.g., log, report, highlight element)
      }
      ```
      Additional Considerations:
      - Multiple Pages: Test each page individually for comprehensive coverage.
      - Dynamic Content: Handle dynamic content loading or updates if applicable.
      - Interaction Testing: Simulate user interactions (e.g., keyboard navigation, focus management) to test accessibility in various scenarios.
      - Reporting: Use axe-core's reporting capabilities or integrate with other tools for detailed reports and issue tracking.
      Example:
      ```javascript
      const { test, expect } = require('@playwright/test');
      const { axe, injectAxe } = require('axe-core');
      test('Homepage accessibility', async ({ page }) => {
      await page.goto('www.example.com');
      await page.evaluate(injectAxe);
      const results = await page.evaluate(() => axe.run());
      expect(results.violations.length).toBe(0); // Assert no violations
      });
      ```
      Key Points:
      - Playwright's ability to interact with the browser at a low level and its support for modern web features make it well-suited for accessibility testing.
      - Axe-core provides comprehensive accessibility checks based on WCAG guidelines.
      - By combining Playwright's automation capabilities with axe-core's accessibility expertise, you can create robust accessibility test suites.

  • @aasthasingh2424
    @aasthasingh2424 9 หลายเดือนก่อน

    Hello, can you please tell me the cmd to install testrail cli, actually i want to integrate testrail with playwright. can you please help.

    • @RaghavPal
      @RaghavPal  9 หลายเดือนก่อน

      Aastha
      Absolutely! Integrating TestRail with Playwright using the TestRail CLI is straightforward. Here's how you can do it:
      *1. Install TestRail CLI:*
      *Prerequisite:* Ensure you have Python 3.10 or higher installed on your system.
      *Option 1 (Recommended):* Use pip to install the TestRail CLI:
      ```
      pip install trcli
      ```
      *Option 2 (Alternative):* Download the appropriate wheel file for your operating system from the TestRail CLI releases page ([github.com/gurock/trcli](github.com/gurock/trcli)) and install it manually:
      ```
      python3 -m pip install /path/to/trcli--py3-.whl
      ```
      *2. Configure TestRail CLI:*
      * Run `trcli config init` to set up your TestRail configuration.
      * Enter your TestRail base URL, username, and password when prompted.
      * Optionally, provide a project ID and save the configuration file for future use.
      *3. Integrate TestRail with Playwright:*
      * Import the `trcli` package in your Playwright test script:
      ```python
      from trcli import Client
      # Replace these values with your details
      client = Client(base_url="YOUR_TESTRAIL_BASE_URL", username="YOUR_USERNAME", password="YOUR_PASSWORD")
      ```
      * Use the `trcli` client to interact with TestRail throughout your tests:
      *Create test runs:*
      ```python
      client.runs.create(project_id=1, name="My Playwright Test Run")
      ```
      *Add test results:*
      ```python
      # For passed tests
      client.results.add(run_id=run_id, case_id=1, status=1)
      # For failed tests
      client.results.add(run_id=run_id, case_id=1, status=5, comment="Test failed due to...")
      ```
      *Get test details:*
      ```python
      test_case = client.tests.get(project_id=1, case_id=1)
      print(f"Test Case Title: {test_case['title']}")
      ```

  • @NafisaAtiyaKhan
    @NafisaAtiyaKhan ปีที่แล้ว

    When I run example.spec.js using 'npx playwright test' command from VS Code terminal only one test passed. firefox and webkit tests fail. Is it a configuration issue?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Nafisa, cannot say for sure, will need to check the report and logs

  • @vinuthac-wu8ws
    @vinuthac-wu8ws 5 หลายเดือนก่อน

    I am getting error while executing npx playwright test one spec .js [Error - could not determine executable to run and no tests found . how to resolve this

    • @RaghavPal
      @RaghavPal  5 หลายเดือนก่อน

      The error message you're encountering, "could not determine executable to run and no tests found," typically indicates that Playwright was unable to locate any test files to execute. This can happen for a few reasons:
      1. Incorrect File Path: Ensure that the file path to your test file is correct. If you're in the same directory as the test file, you can try running it with a relative path like `./one.spec.js`. Try using forward slashes / in your path
      2. File Naming Convention: Playwright expects test files to follow a specific naming convention, usually `*.spec.js` or `*.test.js`. Make sure your test file's name matches these patterns.
      3. Configuration Issue: Check your Playwright configuration file (if you have one) to ensure it's not misconfigured in a way that would exclude your test file from being recognized.
      4. Version Mismatch: There might be a version mismatch issue if you have multiple versions of Playwright installed. Ensure that you're using the correct version of Playwright that corresponds with your test files.
      5. Syntax Error: A syntax error in the test file can sometimes cause this issue. Verify that your test file is free of syntax errors and is properly structured.
      6. Grep Pattern: If you're using command line arguments or configuration settings to set a filter on tests to run, make sure that the grep pattern isn't excluding all of your tests.
      Here's a command you can try to execute your test file:
      ```shell
      npx playwright test one.spec.js
      ```
      If you're still facing issues, you might want to check the documentation for Playwright or seek help from the community forums where you can share more details about your setup and the exact commands you're using. Remember to replace `one.spec.js` with the actual name of your test file.

    • @vinuthac-wu8ws
      @vinuthac-wu8ws 5 หลายเดือนก่อน

      Thanks for the quick reply will check and get back to you! 🙂

  • @manishapatel9695
    @manishapatel9695 ปีที่แล้ว

    Hi Raghav.. I am following your tutorials. While running any test I am getting an error message -
    PS C:\Users\manis\Desktop\Playwright_Automation> npx playwright test --project=chromium
    Error: EPERM: operation not permitted, rmdir 'C:\Users\manis\Desktop\Playwright_Automation\test-results\.playwright-artifacts-0'
    how do I sort this?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Manisha
      The error message indicates that the operation to remove a directory is not permitted due to a permission issue. You can try the following steps to sort this issue:
      Make sure that you have sufficient permissions to access the directory where the test results are being stored.
      Check if the directory is currently in use by another process or program. If so, close that program and try running the test again.
      You can try running the command with administrative privileges. Open the terminal or command prompt as an administrator and try running the command again.
      Try deleting the directory manually from the file system and then run the test again.
      If none of these steps work, you can try updating or reinstalling the Playwright framework to see if that resolves the issue.

    • @manishapatel9695
      @manishapatel9695 ปีที่แล้ว

      @@RaghavPal thank you so much Raghav. I had to reinstall playwright in my google drive and now the issue is resolved. Thank you so much!! Really appreciate all your timely assistance.

  • @Kaiser0109
    @Kaiser0109 ปีที่แล้ว

    Hello Raghav, I am at the beginning, so when I want to run a specific test ovber vs code, I cant run it, I did exactly the same as you, but it says 0 tests using 0 workers, however if I use npx Playwright test it runs the tests

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Kaiser, what command did you use initially, check the path location

  • @Lofisavan-yt
    @Lofisavan-yt ปีที่แล้ว

    hii sir, Can we schedule test in playwright ? that test will run automatically on schedule time and will produce report pls guide on this ! thank you

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi, not aware if there is some in-built feature in playwright, but you can always do this using command line, Can create a batch file having the run commands and can schedule it to run using windows scheduler or any other way
      Another option will be to use a CI CD tool like Jenkins

  • @prashanthikonduru
    @prashanthikonduru ปีที่แล้ว

    Hi Gavrav, when i run this command "npx playwright test .\tests\example.spec.js" says "no tests found", but when i ran 'npx playwright test' it executed. Could you please help me ?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +2

      Hi Prashanthi,
      The error message "no tests found" is indicating that the Playwright test runner cannot find any test files to run. This error is likely occurring because the test runner is not able to locate the test file specified in the command npx playwright test .\tests\example.spec.js.
      Here are a few things to check:
      File path: Verify that the file path specified in the command .\tests\example.spec.js is correct and that the file exists in the specified location. Make sure the path is relative to the current directory and not an absolute path.
      File extension: Verify that the file has the correct extension, in this case '.spec.js', which is commonly used for Playwright test files.
      Test syntax: Verify that the test file contains valid JavaScript code and that the tests are written in a format that Playwright can understand.
      If you continue to experience this issue, it may be helpful to check the Playwright documentation for more information or to seek assistance from the Playwright community.

  • @arshqureshi5388
    @arshqureshi5388 ปีที่แล้ว

    Hi Sir, The series are great, I have an issue. When I try to run a specific test it says "no test found."
    Can you please help me on this

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Arsh,
      If you're trying to run a specific test in Playwright and it's saying "no test found", there could be a few possible causes:
      Check the test file name: Make sure that the name of the test file and the test function that you're trying to run are correct. Playwright looks for test files that have a .test.js extension, and the test function must be defined with the test keyword.
      Check the path to the test file: Make sure that the path to the test file is correct. If the file is not in the same directory as the test runner, you will need to provide a relative or absolute path to the file.
      Check the test function name: Make sure that the name of the test function that you're trying to run is correct. The test function must be defined with the test keyword and have a unique name within the test file.
      Check if the test function is commented out: Make sure that the test function you're trying to run is not commented out. Playwright will not run any tests that are commented out.
      Check if there are any typos or syntax errors: Make sure that there are no typos or syntax errors in the test function or in the test file. A syntax error or typo can prevent the test from being found by Playwright.
      Check the test runner configuration: Make sure that the test runner you're using is correctly configured to find and run your tests. For example, if you're using Jest, you may need to specify the path to your test files in the Jest configuration.
      By checking these possible causes, you should be able to identify why Playwright is not finding your test and resolve the issue

    • @erikpugh7028
      @erikpugh7028 ปีที่แล้ว

      Don't add the '.\tests\' part. Just type: npx playwright test example.spec.js
      That should work. I had the same issue, but that solved it for me.

  • @bafalo992
    @bafalo992 ปีที่แล้ว

    hey man, can you help me? I wanted to run only one test so i said:npx playwright test .\tests\sometest.test.ts
    but i got the error message: Error: No tests found
    My Playwright folder is located on the desktop but everything else is the same as for you.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      There could be several reasons why you are getting the "No tests found" error message when trying to run a single test using Playwright.
      Here are a few possible solutions you can try:
      Check the path of the test file you are trying to run: Ensure that the path to the test file you want to run is correct. In your case, the test file is located in the "tests" folder. Make sure that the path to the folder is correct.
      Check the name of the test file: Ensure that the name of the test file you want to run is correct. Double-check that the file name is spelled correctly, including the file extension.
      Check the name of the test function: Ensure that the name of the test function you want to run is correct. Double-check that the name of the function is spelled correctly, including any capitalization or punctuation.
      Ensure the test is exported: Make sure that the test function is exported from the test file. You should have something like export test('My Test', async () => {...});
      Ensure you have installed the required dependencies: Make sure that you have installed all the necessary dependencies for your project, including Playwright, Jest or Mocha, and any other required packages. You can do this by checking the dependencies section of your package.json file.
      Try running all tests: If none of the above solutions work, try running all tests in your project to see if any tests are found. You can do this by running npx playwright test without specifying a test file.
      Check the configuration file: Ensure that the configuration file is set up correctly. In your case, the configuration file should be playwright.config.ts and should include a reference to the folder containing your test files, like this:
      module.exports = {
      testMatch: ["**/tests/*.test.ts"],
      };
      By following these steps, you should be able to identify and resolve the issue preventing your test from running.

  • @SandeepNagpal-r7r
    @SandeepNagpal-r7r 21 วันที่ผ่านมา

    Playwright Quiz 3
    Total points: 8/10

    • @RaghavPal
      @RaghavPal  21 วันที่ผ่านมา

      Great.. keep going

  • @ankitarawat3298
    @ankitarawat3298 ปีที่แล้ว

    Hi Raghav,
    When I am trying to execute a single file in tests folder, I am getting error 'no tests found'. Below are the lines from terminal.
    PS C:\Projects\Playwright_Automation> npx playwright test .\tests\example.spec.js
    Running 0 tests using 0 workers
    =================
    no tests found.
    =================
    To open last HTML report run:
    npx playwright show-report

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Ankita, check if this helps
      npx playwright test loginPage.spec.ts change the filename only.
      github.com/microsoft/playwright/issues/13092

    • @abhayranjan6595
      @abhayranjan6595 ปีที่แล้ว +1

      Don't use tab to complete file path. Instead use npx playwright test ./tests/example.spec.js

    • @AvanthiGuntupalli
      @AvanthiGuntupalli ปีที่แล้ว +1

      @@RaghavPal I had same issue. As you advised, I have run the command with only file name. It worked now. e.g. npx playwright test example.spec.js

  • @ashakiran7885
    @ashakiran7885 ปีที่แล้ว

    Just watched the video and attempted the quiz..scored 8.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Great score Asha

  • @abdullahrashid12
    @abdullahrashid12 8 หลายเดือนก่อน

    Hi,
    If I have a second folder with another test script in it, what would be the command to run that specific test only. i.e.
    tests > example.spec.js
    test-demo > demo.spec js
    What would be the command to run the demo.spec.js only. I have tried npx playwright test demo.spec.js it showed "Error: No tests found".

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Abdullah
      To run the specific test script `demo.spec.js` located in the `test-demo` folder, use the following command:
      ```bash
      npx playwright test test-demo/demo.spec.js
      ```
      Give single forward slash / in the path of the test file and after typing few characters press 'tab' to auto-complete (this is to ensure you do not make any typing errors)

    • @abdullahrashid12
      @abdullahrashid12 8 หลายเดือนก่อน

      @@RaghavPal Thanks you it worked.

  • @TC-wg2do
    @TC-wg2do ปีที่แล้ว

    Hi, if I have 2 folders ".\folderOne" and ".\folderTwo" in my directory, but I only want to run the tests inside "folderOne", is there a way to do this? Thank you.

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      you can use command and give the folder location

  • @sagarikamandal8977
    @sagarikamandal8977 ปีที่แล้ว

    Hi Raghav, I tried running test file in terminal with command npx playwright test .\tests\example.spec.js and getting the error as no tests found. Can you help me understand the same? Thanks

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Sagarika
      The error message "no tests found" means that the Playwright test runner could not find any test files in the specified directory. There are a few possible reasons for this:
      * The test file is not in the correct directory. The Playwright test runner will only look for test files in the directory that you specify. In your case, you are specifying the directory `.\tests\example.spec.js`. However, there is no test file called `example.spec.js` in that directory.
      * The test file is not a JavaScript file. The Playwright test runner can only run JavaScript test files. If your test file is in a different language, you will need to use a different test runner.
      * The test file does not contain any tests. A test file must contain at least one test function. If your test file does not contain any test functions, the Playwright test runner will not be able to find any tests.
      To fix the error, you need to make sure that the test file is in the correct directory, that it is a JavaScript file, and that it contains at least one test function.
      Here are some additional things to keep in mind when running Playwright tests:
      * The Playwright test runner uses the file extension to determine the type of file. For example, a file with the extension `.spec.js` is considered to be a JavaScript test file.
      * The Playwright test runner will only run files that match the specified test match criteria. The default test match criteria is `. *(test|spec)\. (js|ts|mjs)`. This means that the Playwright test runner will only run files that have the `test` or `spec` suffix and that are written in JavaScript, TypeScript, or MJS.
      I hope this helps

    • @sagarikamandal8977
      @sagarikamandal8977 ปีที่แล้ว

      @@RaghavPal when I run only example.spec.js it's running..

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      will need to check with some online help on this

  • @ArtificialIntelligence-u3z
    @ArtificialIntelligence-u3z 8 หลายเดือนก่อน

    Hi Raghav, I am getting error "No named projects are specified in the configuration file" when trying command npx playwright test --project=chromium

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      Here are the steps to address it:
      1. Check Configuration File:
      - Ensure Existence: Verify that a Playwright configuration file (`playwright.config.js` or `playwright.config.ts`) exists in your project's root directory. Create one if it's missing.
      - Project Definition: Make sure the configuration file includes a valid `projects` section defining a project named "chromium". Here's an example:
      ```javascript
      module.exports = {
      projects: [
      {
      name: 'chromium',
      use: {
      browserName: 'chromium',
      },
      },
      ],
      };
      ```
      2. Verify Project Name:
      - Case Sensitivity: Double-check that the project name in your command (`npx playwright test --project=chromium`) matches the name defined in the configuration file, including capitalization.
      3. Resolve File Path Issues:
      - Correct Path: If the configuration file is located in a non-standard directory, specify its path using the `--config` flag:
      ```bash
      npx playwright test --config=path/to/playwright.config.js --project=chromium
      ```
      4. Handle Missing Dependencies:
      - Install Playwright: If you haven't already, install Playwright globally using `npm install -g playwright` or `yarn global add playwright`.
      5. Consider Conflicting Global Installations:
      - Local Version: If you have both global and local Playwright installations, use the local version with `npx playwright test` instead of directly using the `playwright` command.

    • @ArtificialIntelligence-u3z
      @ArtificialIntelligence-u3z 7 หลายเดือนก่อน

      @@RaghavPal Thanks for your response, tried all above but still same error.

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

      ok,.. keep looking. If I get more info.. will add here

  • @abhilashrainchu4113
    @abhilashrainchu4113 ปีที่แล้ว

    Hi Raghav, Playwright inspector is not opening when i run the test in debug mode, I am using plawright-1.35.1, do i need to install any extension for it ?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Abhilash
      The Playwright inspector should open automatically when you run your tests in debug mode. If it is not opening, there are a few things you can check:
      * Make sure that you are using the latest version of Playwright.
      * Make sure that you have the `PWDEBUG` environment variable set to `1`.
      * Make sure that you are not running your tests in headless mode.
      If you have checked all of these things and the Playwright inspector is still not opening, you may need to install the Playwright DevTools extension. This extension is available for Chrome, Firefox, and Edge.
      To install the Playwright DevTools extension, follow these steps:
      * Open the Chrome Web Store.
      * Search for "Playwright DevTools".
      * Click on the "Add to Chrome" button.
      * Click on the "Add extension" button.
      Once the Playwright DevTools extension is installed, you should be able to open the Playwright inspector by pressing `Ctrl`+`Shift`+`I`.
      If you are still having trouble opening the Playwright inspector, you can try the following:
      * Restart your computer.
      * Uninstall and reinstall Playwright.
      * File an issue on the Playwright GitHub repository.
      I hope this helps

  • @mohan3492
    @mohan3492 ปีที่แล้ว

    can we use java for playwright in vs code?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Yes you can do Mohan

  • @Shahzilrind
    @Shahzilrind 2 ปีที่แล้ว

    Great video