Playwright Beginner Tutorial 3 | How to run tests

Sdílet
Vložit
  • čas přidán 1. 06. 2024
  • ▬ ALL FREE COURSES ► automationstepbystep.com/
    ▬ ASK RAGHAV ► bit.ly/2CoJGWf
    QUIZ - forms.gle/TXRXbM8URRXppwem6
    ▬▬ T I M E S T A M P S ⏰ ▬▬
    00:00 Introduction
    01:41 npx playwright test runs all tests on all browsers in headless mode
    04:20 npx playwright test --workers 3 runs with 3 workers in parallel
    05:14 npx playwright test one.spec.js runs a specific test file
    05:54 npx playwright test one.spec.js two.spec.js runs the files specified
    06:04. npx playwright test one two runs files that have one or two in the file name
    06:40. npx playwright test -g "check title" runs test with the title
    08:04 npx playwright test --project=chromium runs on specific browser
    08:56 npx playwright test --headed runs tests in headed mode
    09:51 npx playwright test --debug debug tests
    11:40 npx playwright test example.spec.js --debug debug specific test file
    12:04 npx playwright test example.spec.js:21 --debug debug starting from specific line where test(.. starts
    14:08 All commands screenshot
    #playwright #automation #testing
    ▬▬ CI CD DEVOPS ▬▬
    JENKINS BEGINNER ► bit.ly/2MIn8EC
    JENKINS TIPS & TRICKS ►bit.ly/2LRt6xC
    JENKINSFILE ► bit.ly/3JSMSZ7
    DOCKER ► bit.ly/2MInnzx
    KUBERNETES ► bit.ly/2MJIlMK
    ▬▬ UI TESTING ▬▬
    SELENIUM BEGINNERS ► bit.ly/2MGRS8K
    SELENIUM JAVA FRAMEWORK ► bit.ly/2N9xvR6
    SELENIUM PYTHON ► bit.ly/2oyMp5x
    SELENIUM TIPS ► bit.ly/2owxc50
    SELENIUM BUILDER ► bit.ly/2MKNtlq
    SELENIUM 4 ► bit.ly/3AiJOlP
    KATALON STUDIO ► bit.ly/2wARFdi
    ROBOT FRAMEWORK with RIDE ► bit.ly/2Px6Ue9
    ROBOT FRAMEWORK with Eclipse► bit.ly/2N8DZxb
    PROTRACTOR ► bit.ly/2KtqVkU
    ACCELQ ► bit.ly/3PlsAsh
    TEST PROJECT ► bit.ly/2DRNJYE
    CUCUMBER BDD ► bit.ly/3Cnno4z
    CYPRESS ► bit.ly/3PpEukM
    XPATH & WEB LOCATORS ► bit.ly/3PpEvoQ
    ▬▬ API TESTING ▬▬
    WEB SERVICES (API) ► bit.ly/2MGafL7
    SOAPUI ► bit.ly/2MGahmd
    POSTMAN ► bit.ly/2wz8LrW
    POSTMAN 2022 ► bit.ly/3JWm4qX
    JMETER API TESTING ► bit.ly/3AgVPar
    GENERAL ► bit.ly/2PYdwmV
    KATALON STUDIO API ► bit.ly/2BwuCTN
    REST ASSURED ► bit.ly/3zUdhRD
    KARATE API ► bit.ly/3w3H5Ku
    API MOCKING ► bit.ly/3bYPsjS
    ▬▬ MOBILE TESTING ▬▬
    APPIUM ► bit.ly/2ZHFSGX
    MOBILE TESTING ►bit.ly/2PxpeUv
    ▬▬ PERFORMANCE TESTING ▬▬
    JMETER BEGINNER ► bit.ly/2oBbtIU
    JMETER INTERMEDIATE ► bit.ly/2oziNVB
    JMETER ADVANCED ► bit.ly/2Q22Y6a
    JMETER TIPS & TRICKS ► bit.ly/2NOfWD2
    PERFORMANCE TESTING ► bit.ly/2wEXbLS
    GATLING ► bit.ly/3QrWfkV
    ▬▬ IDE ▬▬
    ECLIPSE ► bit.ly/3AnRhQP
    INTELLIJ IDEA ► bit.ly/3AnyDZ8
    Visual Studio Code ► bit.ly/2V15yvt
    ▬▬ PROGRAMMING ▬▬
    JAVA BEGINNERS ► bit.ly/2PVUcXs
    JAVA TIPS & TRICKS ► bit.ly/2CdcDnJ
    GROOVY ► bit.ly/2FvWV5C
    JAVASCRIPT ► bit.ly/2KJDZ8o
    TYPESCRIPT ► bit.ly/3dvJBmz
    PYTHON ► bit.ly/2Z4iRye
    ▬▬ BUILD TOOLS ▬▬
    MAVEN ► bit.ly/2NJdDRS
    GRADLE ► bit.ly/30l3h1B
    ▬▬ SOURCE CODE MANAGEMENT ▬▬
    GIT & GITHUB ►bit.ly/2Q1pagY
    GITLAB ► bit.ly/2kQPGyQ
    ▬▬ CLOUD SERVICES ▬▬
    BROWSERSTACK ► bit.ly/3w7kxZn
    SAUCELABS ► bit.ly/3w7kAo1
    LAMBDATEST ► bit.ly/3C6TBwM
    ▬▬ DATA FORMATS ▬▬
    JSON ► bit.ly/3w450tq
    XML ► bit.ly/3PqRneH
    ▬▬ VIRTUALIZATION ▬▬
    VIRTUALIZATION ► bit.ly/2SItIL9
    ▬▬ MOCK INTERVIEWS ► bit.ly/3QGwwVJ ▬▬
    ▬▬ OTHERS ▬▬
    QnA FRIDAY ► bit.ly/2NgwGpw
    SUNDAY SPECIAL ► bit.ly/2wB23BO
    GITHUB PROJECTS ► github.com/Raghav-Pal/
    STORIES BY RAGHAV ► automationstepbystep.com/stor...
    Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you
    You can support my mission for education by sharing this knowledge and helping as many people as you can
    If my work has helped you, consider helping any animal near you, in any way you can
    NEVER STOP LEARNING
    Raghav Pal

Komentáře • 260

  • @ruixue6955
    @ruixue6955 Před 5 měsíci +2

    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  Před 5 měsíci

      Thanks for adding 🙏🏻

  • @user-yy5zi4cv4l
    @user-yy5zi4cv4l Před 8 měsíci +1

    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  Před 8 měsíci

      Thanks a lot for the message Zhiyuan

  • @richakambo2636
    @richakambo2636 Před rokem +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  Před rokem +1

      Hi Richa, Great Score, all the best

  • @socialnetworkingtube
    @socialnetworkingtube Před 11 měsíci +1

    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  Před 11 měsíci

      You're very welcome Sujata

  • @IIvanNuno
    @IIvanNuno Před 2 měsíci +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 👍

  • @lisazhou7776
    @lisazhou7776 Před rokem +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

  • @cosminmatic5987
    @cosminmatic5987 Před 2 měsíci +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  Před 2 měsíci +1

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

  • @barehandstudio
    @barehandstudio Před rokem

    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.

  • @sinthujaa
    @sinthujaa Před 9 měsíci

    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

  • @monushh
    @monushh Před rokem

    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  Před rokem

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

  • @knucklesmarks
    @knucklesmarks Před rokem

    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.

  • @misn757
    @misn757 Před 5 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 5 měsíci

      Thanks a lot for the support

  • @francesjen9093
    @francesjen9093 Před 2 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 2 měsíci +1

      Great to know this Frances.. all the best

  • @ashishnaidu2487
    @ashishnaidu2487 Před měsícem

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

    • @RaghavPal
      @RaghavPal  Před měsícem

      You are most welcome Ashish

  • @Floweenka
    @Floweenka Před rokem

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

  • @user-bg5dk1xo9w
    @user-bg5dk1xo9w Před 5 měsíci

    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  Před 5 měsíci

      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.

  • @SahilRajput03
    @SahilRajput03 Před rokem

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

  • @Exerb1a
    @Exerb1a Před rokem

    Great series , thank you

  • @MiSsGaByCiTa
    @MiSsGaByCiTa Před 7 měsíci

    This is awesome thank you so much!

  • @nisharani4624
    @nisharani4624 Před 5 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 5 měsíci

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

  • @JAYLATHIA
    @JAYLATHIA Před rokem

    Fast and easy teaching of commands...!

  • @Kaiser0109
    @Kaiser0109 Před rokem

    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  Před rokem +1

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

  • @Antoniogross1239
    @Antoniogross1239 Před rokem +1

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

  • @DJChan-dn9tb
    @DJChan-dn9tb Před 15 dny

    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  Před 13 dny

      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
      ---

  • @user-tj9ri7zq1d
    @user-tj9ri7zq1d Před rokem

    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  Před rokem

      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.

  • @debayudhchattopadyay5056

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

    • @RaghavPal
      @RaghavPal  Před rokem +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.

  • @bajafurious
    @bajafurious Před rokem +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  Před rokem

      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 Před 9 měsíci +2

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

  • @TC-wg2do
    @TC-wg2do Před rokem

    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  Před rokem

      you can use command and give the folder location

  • @prashanthikonduru
    @prashanthikonduru Před rokem

    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  Před rokem +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.

  • @manojkumar-wt2sv
    @manojkumar-wt2sv Před rokem

    Thanks for your dedication sir 🙏

  • @chandansharma-op9ik
    @chandansharma-op9ik Před 3 měsíci

    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  Před 3 měsíci

      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.
      ..

  • @abhilashrainchu4113
    @abhilashrainchu4113 Před 11 měsíci

    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  Před 11 měsíci

      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

  • @bhagyalakshmibadiginchala38
    @bhagyalakshmibadiginchala38 Před 11 měsíci

    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  Před 11 měsíci +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

  • @sergiovillagomez7322
    @sergiovillagomez7322 Před rokem

    Thanks for your dedication :)

  • @swapnakulkarni3758
    @swapnakulkarni3758 Před 8 měsíci

    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  Před 8 měsíci

      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.

  • @abdullahrashid12
    @abdullahrashid12 Před 4 měsíci

    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  Před 4 měsíci

      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 Před 4 měsíci

      @@RaghavPal Thanks you it worked.

  • @juanlofredo7044
    @juanlofredo7044 Před rokem

    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  Před rokem

      will need to check on this Juan

  • @ashishnaidu2487
    @ashishnaidu2487 Před 3 měsíci

    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  Před 3 měsíci

      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 Před 3 měsíci

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

  • @NafisaAtiyaKhan
    @NafisaAtiyaKhan Před rokem

    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  Před rokem

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

  • @harishkce1989
    @harishkce1989 Před rokem

    Hello Raghav..how to execute the test only in one browser ? i mean you have shown option npx playwright test--project=chrominum ..but can it be controlled in the playwright.config.js file ? for ex : i wanted to use npx playwright test - but only executed in one browser

    • @RaghavPal
      @RaghavPal  Před rokem

      Hi Harish, yes, you can set in config file
      module.exports = {
      browser: 'chromium' // The browser you want to use for your test
      }
      For multiple browsers
      module.exports = {
      browser: ['chromium', 'firefox', 'webkit'] // The browser you want to use for your test
      }

    • @harishkce1989
      @harishkce1989 Před rokem

      @@RaghavPal Hello raghav..unfortunately i am not sure how to edit the config file ... in the playwright docs offical page ... const config = {
      use: {
      baseURL: 'localhost:3000',
      browserName: 'firefox',
      headless: true,
      },
      }; ---------------- but seems to be different from the default config.js file content

    • @RaghavPal
      @RaghavPal  Před rokem

      just ensure the config file playwright.config.json should be in the root project folder
      Add the following config:
      {
      "browser": "chromium"
      }

  • @adithyakiransekar
    @adithyakiransekar Před rokem

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

    • @RaghavPal
      @RaghavPal  Před rokem

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

  • @bhagyalakshmibadiginchala38
    @bhagyalakshmibadiginchala38 Před 11 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 11 měsíci +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

  • @TheSamimaks
    @TheSamimaks Před 3 měsíci

    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 Před 3 měsíci

      no worries, it's resolved now :)

    • @RaghavPal
      @RaghavPal  Před 3 měsíci

      Great, can post your solution here to help others

  • @jaiasreepalanivel1604
    @jaiasreepalanivel1604 Před 3 měsíci

    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  Před 3 měsíci

      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

  • @ahadjamshed7135
    @ahadjamshed7135 Před rokem

    Hello Raghav. I am facing one issue. Once I run this command npx playwright test then the test is running with the 3 workers instead of 1 worker that is running one after another. can you please tell me where I am doing a mistake?

    • @RaghavPal
      @RaghavPal  Před rokem

      Hi Ahad, you can set the workers count in config file OR can mention in the command
      npx playwright test --workers=1

    • @ahadjamshed7135
      @ahadjamshed7135 Před rokem

      @@RaghavPal ok Thank you Raghav.

  • @ramutalari8473
    @ramutalari8473 Před rokem +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  Před rokem

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

    • @ramutalari8473
      @ramutalari8473 Před rokem

      @@RaghavPal Okay, thank you Raghav!!

  • @bafalo992
    @bafalo992 Před rokem

    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  Před rokem

      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.

  • @cosminmatic5987
    @cosminmatic5987 Před 2 měsíci

    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  Před 2 měsíci

      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.

  • @poornimaa2246
    @poornimaa2246 Před rokem

    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  Před rokem +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

  • @SouravKumarDey-rh5fn
    @SouravKumarDey-rh5fn Před 2 dny

    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  Před dnem

      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
      --

  • @benvu4769
    @benvu4769 Před 27 dny

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

    • @RaghavPal
      @RaghavPal  Před 27 dny

      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

  • @binitpatel
    @binitpatel Před rokem

    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  Před rokem

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

  • @abhishek150987
    @abhishek150987 Před rokem

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

  • @petlaughtv
    @petlaughtv Před rokem

    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  Před rokem

      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

  • @sridharkatkam1852
    @sridharkatkam1852 Před 5 měsíci

    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  Před 5 měsíci

      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.

  • @rajkumaraadepu3951
    @rajkumaraadepu3951 Před rokem

    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  Před rokem

      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

  • @saadshakil
    @saadshakil Před 11 měsíci

    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  Před 11 měsíci

      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

  • @arshqureshi5388
    @arshqureshi5388 Před rokem

    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  Před rokem

      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 Před 9 měsíci

      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.

  • @zwiterrion12
    @zwiterrion12 Před měsícem

    Thank you. Quiz score 10/10

    • @RaghavPal
      @RaghavPal  Před měsícem

      Great Kelly. keep learning

  • @sagarikamandal8977
    @sagarikamandal8977 Před 9 měsíci

    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  Před 9 měsíci

      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 Před 9 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 9 měsíci

      will need to check with some online help on this

  • @michaeledmondson6193
    @michaeledmondson6193 Před 8 měsíci

    Hey Raghav when trying 'npx playwright test .\tests\example.spec.js' in the terminal its saying no test found. do you know why?

    • @RaghavPal
      @RaghavPal  Před 8 měsíci

      Michael
      The error message "No tests found" means that the Playwright test runner could not find any tests to run. There are a few possible reasons for this:
      * The file `.\tests\example.spec.js` does not exist.
      * The file `.\tests\example.spec.js` is not a valid Playwright test file. Playwright test files must have the .spec.ts extension and they must import the `@playwright/test` module.
      * The Playwright configuration file is not set up correctly. The Playwright configuration file tells Playwright how to find and run your tests.
      Here are some things you can check to troubleshoot the issue:
      * Make sure that the file `.\tests\example.spec.js` exists and that it is a valid Playwright test file.
      * Open the Playwright configuration file and make sure it is set up correctly.
      If you are still having trouble, you can try the following:
      * Restart your computer.
      * Clear the Playwright cache. To do this, open a terminal and run the following command:
      ```
      npx playwright cache clean
      ```
      * Reinstall Playwright.
      If you are still having trouble, you can ask for help on the Playwright forum or the Playwright Discord server.
      Here are some additional things to check:
      * Make sure that the file `.\tests\example.spec.js` is in the current working directory.
      * Make sure that the file `.\tests\example.spec.js` is not being ignored by a git ignore file.
      * Make sure that the Playwright test runner is installed and that it is in your path.
      I hope this helps

    • @michaeledmondson6193
      @michaeledmondson6193 Před 8 měsíci

      So i Updated my testDir: from './e2e' to './tests' and it worked is there anyway i can have both of these in here at one time?@@RaghavPal

    • @RaghavPal
      @RaghavPal  Před 8 měsíci

      will need to check on this

  • @hildajose1226
    @hildajose1226 Před 5 měsíci

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

  • @cherryblue4
    @cherryblue4 Před rokem +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  Před rokem

      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.

  • @aliisatas5576
    @aliisatas5576 Před rokem

    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  Před rokem

      The command is *npx playwright test*

  • @arsman_ahmad
    @arsman_ahmad Před 10 měsíci

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

  • @shikshacomplete5049
    @shikshacomplete5049 Před rokem

    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  Před rokem +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 Před rokem

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

  • @thelet3878
    @thelet3878 Před rokem

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

  • @aasthasingh2424
    @aasthasingh2424 Před 5 měsíci

    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  Před 5 měsíci

      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']}")
      ```

  • @ihouyung
    @ihouyung Před rokem

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

    • @RaghavPal
      @RaghavPal  Před rokem +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.

  • @kvsindhura
    @kvsindhura Před rokem

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

  • @perumallasravanthi7666

    Hi Raghav,
    I am facing issue in vscode Test explorer keep on loading and not able to run the tests.
    Same with the commands as well as it's very slow ..
    Any solution for this issue to resolve ??
    Using windows system..

    • @RaghavPal
      @RaghavPal  Před rokem

      Hi Perumal, not sure, will need to check logs, can try using a diff version

    • @perumallasravanthi7666
      @perumallasravanthi7666 Před rokem

      Any specific version do I need to download
      As of now I am using version 1.74.0

    • @RaghavPal
      @RaghavPal  Před rokem

      no specific ver that I know of, it was a suggestion to change and check

  • @vinuthac-wu8ws
    @vinuthac-wu8ws Před měsícem

    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  Před měsícem

      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 Před měsícem

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

  • @user-th7ud8rt6q
    @user-th7ud8rt6q Před 4 měsíci

    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  Před 4 měsíci

      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.

    • @user-th7ud8rt6q
      @user-th7ud8rt6q Před 3 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 3 měsíci

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

  • @rohinidhavile1129
    @rohinidhavile1129 Před 16 dny

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

    • @RaghavPal
      @RaghavPal  Před 16 dny

      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
      ```
      ---

  • @manishapatel9695
    @manishapatel9695 Před rokem

    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  Před rokem

      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 Před rokem

      @@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.

  • @ankitarawat3298
    @ankitarawat3298 Před rokem

    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  Před rokem

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

    • @abhayranjan6595
      @abhayranjan6595 Před rokem +1

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

    • @AvanthiGuntupalli
      @AvanthiGuntupalli Před 11 měsíci +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

  • @premsudheer2092
    @premsudheer2092 Před rokem

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

    • @RaghavPal
      @RaghavPal  Před rokem

      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.

  • @user-up8ld9tm6z
    @user-up8ld9tm6z Před 3 měsíci

    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  Před 3 měsíci

      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.
      ..

    • @user-up8ld9tm6z
      @user-up8ld9tm6z Před 3 měsíci

      @@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  Před 3 měsíci

      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.

  • @shahzilbaloch5210
    @shahzilbaloch5210 Před rokem

    Great video

  • @bhagyalakshmibadiginchala38
    @bhagyalakshmibadiginchala38 Před 11 měsíci

    Hi Raghav, May I know command used to run the tests one by one in the browsers?

    • @RaghavPal
      @RaghavPal  Před 11 měsíci +1

      Hi Bhagyalakshmi
      Here are the commands you can use to run tests one by one in browsers using Playwright:
      * **To run a single test file:**
      ```
      npx playwright test
      ```
      For example, to run the `landing-page.spec.ts` file, you would use the following command:
      ```
      npx playwright test landing-page.spec.ts
      ```
      * **To run a set of test files:**
      ```
      npx playwright test ...
      ```
      For example, to run the `landing-page.spec.ts` and `login-page.spec.ts` files, you would use the following command:
      ```
      npx playwright test landing-page.spec.ts login-page.spec.ts
      ```
      * **To run tests that match a specific pattern:**
      ```
      npx playwright test -g
      ```
      For example, to run all tests that have the word "login" in the file name, you would use the following command:
      ```
      npx playwright test -g login
      ```
      * **To run tests in a specific browser:**
      ```
      npx playwright test --browser
      ```
      For example, to run the `landing-page.spec.ts` file in Chrome, you would use the following command:
      ```
      npx playwright test landing-page.spec.ts --browser chrome
      ```
      * **To run tests in all browsers:**
      ```
      npx playwright test --browsers all
      ```
      This will run all tests in Chrome, Firefox, and Edge.
      * **To run tests in headless mode:**
      ```
      npx playwright test --headed false
      ```
      This will run the tests in headless mode, which means that the browsers will not open a visible window.
      * **To run tests in debug mode:**
      ```
      npx playwright test --debug
      ```
      This will run the tests in debug mode, which allows you to step through the tests line by line.
      I hope this helps

    • @bhagyalakshmibadiginchala38
      @bhagyalakshmibadiginchala38 Před 10 měsíci

      @@RaghavPal I think you are not getting my question properly.If we use "npx playwright test -headed" this command we can see parallel execution. But I would like to get the execution one by one without parallel execution.

    • @bhagyalakshmibadiginchala38
      @bhagyalakshmibadiginchala38 Před 10 měsíci

      @@RaghavPal Anyhow the below commands are not working. I am getting the errors.
      * *To run tests in a specific browser:* ``` npx playwright test --browser ``` For example, to run the `landing-page.spec.ts` file in Chrome, you would use the following command:
      npx playwright test landing-page.spec.ts --browser chrome
      *To run tests in all browsers:* ``` npx playwright test --browsers all ``` This will run all tests in Chrome, Firefox, and Edge

    • @RaghavPal
      @RaghavPal  Před 10 měsíci

      thanks for adding

  • @anilpoet4978
    @anilpoet4978 Před 3 měsíci

    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  Před 3 měsíci

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

  • @imenegherbi9339
    @imenegherbi9339 Před 7 měsíci

    I have a problem when running "npx playwright test .\tests\example.spec.js" in the new folder it's saying test not found!

    • @RaghavPal
      @RaghavPal  Před 7 měsíci +1

      Imene
      Try using forward slashes in the path

    • @imenegherbi9339
      @imenegherbi9339 Před 7 měsíci

      Thank you i found the issue, and now i have another problem I launched my test to log in to my app. After filling in the login boxes, it stops at the login screen@@RaghavPal it keeps waiting until the time runs out.

    • @imenegherbi9339
      @imenegherbi9339 Před 7 měsíci

      How can i reach you, i have a weird bug@@RaghavPal

    • @RaghavPal
      @RaghavPal  Před 7 měsíci +1

      There are a few possible reasons why your Playwright test might be stopping at the login screen and waiting until the time runs out:
      * The login form is not submitting correctly.
      * The login form is submitting, but the response from the server is taking too long to arrive.
      * The login form is submitting correctly, but Playwright is not waiting for the login to complete before moving on to the next step in the test.
      To resolve this issue, you can try the following:
      * Check the console for any errors that might be preventing the login form from submitting correctly.
      * Use the `page.waitForNavigation()` method to wait for the page to navigate to the next page after the login form is submitted.
      * Use the `page.waitForLoadState()` method to wait for the page to load completely after the login form is submitted.
      Here is an example of how to use the `page.waitForNavigation()` method to wait for the page to navigate to the next page after the login form is submitted:
      ```typescript
      import { test, expect } from '@playwright/test';
      test('should log in to the app', async ({ page }) => {
      await page.goto('example.com/login');
      // Fill in the login form.
      await page.locator('button[type="submit"]').click();
      // Wait for the page to navigate to the next page.
      await page.waitForNavigation();
      // Verify that the user is logged in.
      await expect(page.locator('h1')).toContainText('Welcome, user!');
      });
      ```
      Here is an example of how to use the `page.waitForLoadState()` method to wait for the page to load completely after the login form is submitted:
      ```typescript
      import { test, expect } from '@playwright/test';
      test('should log in to the app', async ({ page }) => {
      await page.goto('example.com/login');
      // Fill in the login form.
      await page.locator('button[type="submit"]').click();
      // Wait for the page to load completely.
      await page.waitForLoadState('domcontentloaded');
      // Verify that the user is logged in.
      await expect(page.locator('h1')).toContainText('Welcome, user!');
      });
      ```

    • @imenegherbi9339
      @imenegherbi9339 Před 7 měsíci

      Thank you i appreciateyour help it's working now@@RaghavPal

  • @prabaldutta
    @prabaldutta Před rokem

    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  Před rokem

      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 Před rokem

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

    • @RaghavPal
      @RaghavPal  Před rokem

      ok

  • @mohan3492
    @mohan3492 Před rokem

    can we use java for playwright in vs code?

  • @Venkateshvenky-vy1dd
    @Venkateshvenky-vy1dd Před 3 dny

    Which one best for java or JavaScript to use playwright

    • @RaghavPal
      @RaghavPal  Před 3 dny

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

  • @user-yd8wd2nz1x
    @user-yd8wd2nz1x Před 4 měsíci

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

    • @RaghavPal
      @RaghavPal  Před 4 měsíci

      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.

  • @ganimed11111
    @ganimed11111 Před 6 měsíci

    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  Před 6 měsíci

      will check this. Thanks for adding here

  • @chistar5988
    @chistar5988 Před 29 dny

    Thank you si much, I got 10/10

    • @RaghavPal
      @RaghavPal  Před 28 dny

      Great Chistar.. keep learning

  • @ConvenientCCLink
    @ConvenientCCLink Před 3 měsíci

    Please do video on load testing with playwright and locust

  • @barbaroscelik1084
    @barbaroscelik1084 Před rokem

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

    • @RaghavPal
      @RaghavPal  Před rokem

      Not yet, will do a session on this

  • @ashakiran7885
    @ashakiran7885 Před 10 měsíci

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

  • @ahadjamshed7135
    @ahadjamshed7135 Před rokem

    I Got 10/10 in the Quiz

  • @Anto-fz2kw
    @Anto-fz2kw Před 4 měsíci

    my score is 10/10. thank

    • @RaghavPal
      @RaghavPal  Před 4 měsíci

      Wow Anto. all the best...

    • @Anto-fz2kw
      @Anto-fz2kw Před 4 měsíci

      your welcome. I like your video simple and easy to understand@@RaghavPal

  • @manimegalai2394
    @manimegalai2394 Před 4 měsíci

    I am getting 6 tests using 4 workers running for a long time and 3 are failed at last

    • @RaghavPal
      @RaghavPal  Před 4 měsíci

      Mani
      I need some more information:
      1. What type of tests are you running? (e.g., UI tests, API tests, etc.)
      2. What are the specific errors or failures you're encountering? Please share any logs or error messages you have.
      3. What browser(s) are you using with Playwright?
      4. Have you tried any debugging steps so far? (e.g., setting timeouts, increasing resources, using `console.log` statements)

    • @manimegalai2394
      @manimegalai2394 Před 4 měsíci

      1. Ui testing
      2.getting error with one of browser firefox with messages with has title and get started link
      3.reports are generated in edge browser
      4.no i didnt try debugging

    • @RaghavPal
      @RaghavPal  Před 4 měsíci

      Okay I have covered some topics here - automationstepbystep.com/
      Will plan to add more

    • @manimegalai2394
      @manimegalai2394 Před 4 měsíci

      @@RaghavPal thanks sir

  • @SanjuJS-to6ne
    @SanjuJS-to6ne Před měsícem

    Running 6 tests using 2 workers. Why its shown like this.

    • @RaghavPal
      @RaghavPal  Před měsícem

      Sanju
      The message "Running 6 tests using 2 workers" typically appears during test execution in Playwright. Let me explain what it means:
      - Tests: This refers to the total number of test cases you have defined in your test suite.
      - Workers: Playwright can parallelize test execution by distributing the workload across multiple workers (threads or processes). Each worker runs a subset of the tests concurrently.
      - In your case, Playwright is using 2 workers to execute the 6 tests.
      - This parallelization helps speed up test execution, especially when you have a large number of tests.
      Think of it as Playwright efficiently managing the execution of your tests to optimize time and resources.

  • @nomandladube5087
    @nomandladube5087 Před 10 měsíci

    Hi i got 5/10 il keep learning and going back to the videos😔

  • @ngayathri1818
    @ngayathri1818 Před 9 měsíci

    8 out of 10

  • @rolantb895
    @rolantb895 Před rokem

    good content. but... dark mode plss

    • @RaghavPal
      @RaghavPal  Před rokem +2

      Hi Rolan, I got many feedbacks that light mode is more clear for tutorials, I hope it is clear for you

  • @aylinbekem3701
    @aylinbekem3701 Před měsícem

    Total points
    8/10

    • @RaghavPal
      @RaghavPal  Před měsícem +1

      Great score Aylin. Keep learning and scoring

    • @aylinbekem3701
      @aylinbekem3701 Před měsícem

      @@RaghavPal 🙏🏻🥰

  • @ishanpal9779
    @ishanpal9779 Před rokem

    👍