Playwright Beginner Tutorial 4 | How to write 1st Test

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

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

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

    3:46 browse the *module* with IDE
    4:20 how to include a module in a different script/module
    5:18 *require* is a node.js built-in function, 5:21 it is not a Javascript function
    5:51 a demo directory inside tests, then create hello.js
    8:10 *exports*
    8:57 use the module inside demo - *require*
    11:59 use *import* instead
    16:54 error in the demo code
    17:07 solution: *async* + *await*
    17:28 async before a function makes the function return a *promise*

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

      Thanks a lot for adding timestamps

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

      @@RaghavPal I have watched a few others' tutorials about Playwright as almost a greenhand on nodejs, but eventually found your tutorial and decided to focus on yours :) I should thank you

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

      Most welcome

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

    Great thumbs-up to you Raghav.
    You never stop making latest technology videos which will always empower Devs and QA engineers to grow in their organization.
    Love all your videos.
    Thanks and keep making such tech videos in future too.

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

      Most welcome Jay, sure will continue teaching

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

    This is awesome! Worked like a charm. You explain things so clearly and it's so easy to follow and understand.

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

      Thanks for watching

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

    I have went through 3 topics and look like I am on the right path of learning Playwright tool.. hope I don't get disappointed at the end 😊

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

      I hope so too Prakash.. Let me know if you face any issues

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

    Really appreciate the attention to detail, and trying to explain why things works the way they do.

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

      Glad to know this helped

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

    Hey Raghav! Like you see a detailed report at 21:26, I don't see that. I have just been getting the final passed or failed update in the terminal. What needs to be done? I am new to learning a code-based automation tool

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

      Megha
      it's likely because you're missing an assertion. An assertion is a statement that verifies that something is true about your application.
      To fix the issue and see a detailed report try adding an assertion to your test
      -

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

    Best tutor and I am grateful that I started my career under your guidance.

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

      Thanks, humbled..

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

    Thanks

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

      Thanks a lot Jay

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

    Thank you for the detailed video! I took the quiz and scored 8/10

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

      Excellent Sinthuja

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

    Hi Raghav
    am unable to see the execution in GUI, i think it is running headless. Can you please tell me how can i execute in headed?

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

      Jarvis
      Just add this when you launch your browser:
      const browser = await chromium.launch({ headless: false });
      Use code with caution.
      This tells Playwright to open a visible browser window. Easy peasy
      Remember: Playwright usually runs without showing the browser (it's faster that way) So, only use *headless: false* when you actually need to see what's going on
      Also, you can swap out chromium for firefox or webkit if you prefer a different browser
      -

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

      @@RaghavPal Thanks for the quick response:)
      am facing this below issue after adding the above code.
      SyntaxError: await is only valid in async functions and the top level bodies of modules
      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.
      can you please help here?

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

      Jarvis
      Okay, looks like adding headless: false is causing a bit of a hiccup. The error "SyntaxError: await is only valid in async functions" means you're trying to use the await keyword outside of an asynchronous function.
      Here's how you can fix it:
      Wrap it in an async function: You need to make sure the code that launches the browser and uses await is inside an async function.
      Here's a quick example:
      JavaScript
      import { test, expect } from '@playwright/test';
      test('basic test', async ({ page }) => {
      // Launch the browser in headed mode (with a visible window)
      const browser = await chromium.launch({ headless: false });
      const context = await browser.newContext();
      const page = await context.newPage();
      await page.goto('playwright.dev/');
      const title = page.locator('.navbar__inner .navbar__title');
      await expect(title).toHaveText('Playwright');
      // Close the browser when the test is done
      await browser.close();
      });
      Use code with caution.
      Key points:
      The test function itself is already async, so you can directly use await inside it.
      We've added await browser.close() at the end to make sure the browser window closes properly after the test finishes
      Give that a try, and hopefully, you'll be able to see the browser window and your test execution in action
      -

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

    Great learning Raghav sir as I am completely new to it but can implement with a good understanding step by step

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

      Most welcome Shivangi

  • @QualityInnovation
    @QualityInnovation 7 วันที่ผ่านมา +1

    Hello Raghav,
    When writing the below code, only 'hello' is getting printed. Why 'helloworld' is not getting printed? Please guide.
    const {test, expect} = require ('@playwright/test')
    const {hello, helloworld} = require('./demo/hello')
    console.log (hello());
    console.log (helloworld());
    PS C:\Users\imsmi\Desktop\Playwrite_Automation_VS_Code\tests> node my_first_test_specs.js
    hello

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

      Smita
      This happens because the `helloworld` function is likely not exported correctly in your `./demo/hello.js` file. Here's how to fix it:
      1. Check Your `hello.js` File:
      Ensure both `hello` and `helloworld` are exported properly.
      Example:
      ```javascript
      function hello() {
      return "hello";
      }
      function helloworld() {
      return "helloworld";
      }
      module.exports = { hello, helloworld };
      ```
      2. Verify Imports in Your Code:
      Ensure you are correctly importing the functions:
      ```javascript
      const { hello, helloworld } = require('./demo/hello');
      ```
      3. Re-run the Script:
      Save all files and run:
      ```bash
      node my_first_test_specs.js
      ```
      You should now see both `hello` and `helloworld` printed. 😊
      -

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

    Thanks for these videos. Very thorough intro to Playwright

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

      You're very welcome!

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

    Hi @RaghavPal , thank you for playwright series.
    I am working on npm --version "10.2.4" and node --version "v20.11.0"
    I have tried writing a test from timestamp 13:10 and tried to run the test. I am getting error "Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments."
    is there any change in latest version of playwright? what is the reason it is not working?
    I have also tried the other example where tried to print on console using console.log however even that is also not working for me.
    Please suggest.

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

      Yogesh
      What is the command you executed
      Just try to add forward slashes / in the path of the test file in the command
      The error message "Error: No tests found" indicates that Playwright couldn't find any test files to run. This could be due to several reasons:
      1. Test file patterns:
      * Make sure your test file names match the patterns used in your Playwright configuration file (`playwright.config.js`). The default pattern is `*.spec.js`, but you can customize it. Double-check your file names and patterns for typos or inconsistencies.
      2. File path:
      * Ensure you're running the test command from the correct directory. If your test files are in a different location than the Playwright configuration file, you need to specify the relative or absolute path to them in the command. For example, `npx playwright test --testDir="my-tests" `.
      3. Escaped characters:
      * If your test file names or paths contain special characters like "$" or "*", you might need to escape them using backslashes (`\`) or enclose them in quotes (`" ").
      4. Latest Playwright version:
      * There have been no recent changes in Playwright that should cause the "no tests found" error. However, it's always good to ensure you're using the latest version by running `npm install playwright --save-dev`.
      5. Console.log issue:
      * If even console.log isn't working, it could indicate a larger problem with your Playwright setup. Try restarting your terminal or computer and ensure Playwright is installed correctly.
      Here are some additional suggestions:
      * Run `npx playwright test --help` to see a list of available options and confirm you're using the correct command format.

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

      Thank you @@RaghavPal. This information helped me.
      After reading your comment I tried with below commands and those worked for me.
      npx playwright test my_first_test.spec.js --headed
      npx playwright test tests/my_first_test.spec.js --headed
      However, I was trying command :
      npx playwright test .\tests\my_first_test.spec.js --headed
      to run the tests written in my_first_test.spec.js file.
      This command is giving me error mentioned in my first comment.
      After writing when I press tab button it is suggesting me folders and I can navigate to file using tab button. But after hitting enter key. it is giving me same error. Same command worked in you video. Is there any setting I am missing?

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

      Here: npx playwright test .\tests\my_first_test.spec.js --headed
      try changing backslashes \ with forward slash /

  • @leelamanjari122
    @leelamanjari122 10 หลายเดือนก่อน +2

    Hi Raghav. I followed the same steps as you did in the video. When I try to execute I’m getting an error as No tests found. Make sure the arguments are regular expressions matching test files. You may need to escape symbols like “$” or “*” and quote the arguments. I also tried using forward slash but it still doesnt seem to work. What can I do to fix this?

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

      I fixed it. It was a PowerShell problem in the terminal. I killed the terminal and ran the tests in a new one. It worked.

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

      Great to know this Leela.. keep learning..

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

      @@leelamanjari122 hi leela, can u pls let me know the exact steps tat u followed. i am also facing te same issue

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

      @@sushak7958 hi did you get the solution for this error? can you pls explain me facing the same issue..

  • @24hrboss
    @24hrboss หลายเดือนก่อน +1

    When I ran the npx commnd I get "No tests found." ...why?
    npx playwright test .\tests\my_first_test.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  หลายเดือนก่อน +1

      Ensure the path is correct. On Windows, you might need to escape backslashes (\) or use forward slashes (/)
      npx playwright test ./tests/my_first_test.spec.js

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

    Thanks again, I got those issues with test-cases not found but I have found help in comments (double \\ ). I will definitely check more of yours videos not only about Playwright

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

      Glad it helped Floweenka

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

    Hello Raghav, I don't see test.js and expect.js under the folder @playwright/test. I see under other folder. How I fix this?

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

      Susel
      It seems like you're encountering an issue with the @playwright/test package. Let's troubleshoot this together! Here are a couple of steps you can take to resolve the problem:
      1. Install @playwright/test:
      Make sure you have the @playwright/test library installed in your project. If not, you can install it using npm:
      ```bash
      npm install -D @playwright/test
      ```
      This command will add the @playwright/test package as a development dependency to your project.
      2. Remove playwright-expect:
      You mentioned that you're using the playwright-expect library. However, Playwright already includes web-first assertions, so there's no need to use an additional library to extend `expect`. Remove any unused code related to playwright-expect:
      ```javascript
      // Remove this line
      const { matchers } = require('playwright-expect');
      ```
      3. Check Your Test File Naming:
      Ensure that your test files are named correctly. By default, Playwright Test looks for files matching the pattern `*(test|spec).(js|ts|mjs)`. If your test file doesn't follow this naming convention, you might encounter the "No tests found" issue.
      - Rename your test file to something like `first.test.js`.
      - Alternatively, you can specify a custom test match pattern in your Playwright Test configuration. For example:
      ```javascript
      // playwright.config.js
      import { PlaywrightTestConfig } from '@playwright/test';
      const config: PlaywrightTestConfig = {
      testMatch: /.*\.js/, // Match any .js file
      };
      export default config;
      ```
      4. Check Your File Paths:
      Verify that your file paths are correct. If you've moved your test files to a different folder, make sure the import paths are updated accordingly.
      5. Run Your Tests:
      After making the necessary adjustments, run your tests again:
      ```bash
      npx playwright test
      ```
      Hopefully, this should resolve the issue

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

    Hi Raghav , Thanks for detailed explaination., can i access the element with multiple attributes ? if my datatest-id is not unique in my webpage ?

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

      Yes, you can access elements with multiple attributes in Playwright even if the `data-test-id` is not unique. Here are several methods you can use:
      1. Combine multiple attributes using CSS selectors:
      - Use CSS selectors to target elements with specific combinations of attributes:
      ```javascript
      const element = await page.$('button[data-test-id="my-button"][type="submit"]');
      ```
      2. Use XPath:
      - XPath offers more flexibility for complex attribute combinations:
      ```javascript
      const element = await page.$x('//*[@data-test-id="my-button" and @type="submit"]');
      ```
      3. Employ Playwright's `locator` functions:
      - Use `page.locator` to build flexible selectors:
      ```javascript
      const element = await page.locator('button')
      .filter({ hasAttribute: 'data-test-id', value: 'my-button' })
      .filter({ hasAttribute: 'type', value: 'submit' })
      .first();
      ```
      4. Leverage JavaScript evaluation:
      - Use `page.$eval` to execute JavaScript within the page context for advanced filtering:
      ```javascript
      const elementHandle = await page.$eval('button', (buttons) => {
      return Array.from(buttons).find((button) => {
      return button.dataset.testId === 'my-button' && button.type === 'submit';
      });
      });
      ```
      Best Practices:
      - Prioritize unique attributes: If possible, work with developers to ensure unique `data-test-id` attributes for reliable targeting.
      - Choose clear and descriptive attribute names: This enhances code readability and maintainability.
      - Consider using accessibility attributes: Leverage `role` or `aria-label` for better test coverage and user experience.
      - Apply appropriate waiting mechanisms: Ensure elements are present and interactable before interacting with them.
      - Handle multiple matching elements: If multiple elements match your criteria, use `page.locatorAll` or refine your selector.
      By effectively combining these techniques, you can reliably access elements in Playwright even when dealing with non-unique attributes.

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

    I have followed all of your steps exactly, I have the latest playwright version, and I do not see the lib list under node_modules\@playwright\test. How do I correct this? I am also getting prompted that several extension are deprecated. The only way I could get the test in the lesson 4 was to run is using: import {test, expect} from '@playwright\test. Is there an update version of this series?'

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

      Jon
      Let's break down the issue step by step and find a solution.
      Issue 1: Missing `lib` list under `node_modules\@playwright\test`
      This issue is likely due to the fact that the `@playwright/test` package has undergone significant changes in recent versions. Starting from Playwright 1.25, the `test` package has been restructured, and the `lib` folder is no longer present.
      Solution:
      You don't need to worry about the missing `lib` folder. The new structure of `@playwright/test` is designed to work without it. You can simply ignore this issue and move on to the next one.
      Issue 2: Deprecated extensions
      When you run your tests, you're seeing warnings about deprecated extensions. This is because some of the extensions you're using are no longer supported or have been replaced by newer alternatives.
      Solution:
      To resolve this issue, you'll need to update your code to use the latest, non-deprecated extensions. You can do this by:
      1. Checking the Playwright documentation for the specific extensions you're using to see if they've been deprecated or replaced.
      2. Updating your code to use the recommended alternatives.
      3. If you're using a specific plugin or library that's causing the deprecation warnings, check if there's an updated version available that's compatible with the latest Playwright version.
      Issue 3: Importing `test` and `expect` from `@playwright/test`
      You've found a workaround by importing `test` and `expect` from `@playwright/test` using the following line:
      ```javascript
      import { test, expect } from '@playwright/test';
      ```
      This is the correct way to import these modules in the latest Playwright version.
      Solution:
      You're already doing this correctly.. This import statement is the recommended way to use `test` and `expect` in your Playwright tests
      Additional Tips:
      * Make sure you're running the latest version of Playwright by checking your `package.json` file or running `npm install @playwright/test@latest` (or `yarn add @playwright/test@latest` if you're using Yarn).
      * If you're still experiencing issues, try deleting your `node_modules` folder and running `npm install` (or `yarn install`) again to ensure you have the latest dependencies.
      * Take a look at the Playwright documentation and examples to ensure you're using the latest best practices and APIs.
      I hope this helps
      -

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

    Thank you. Quiz Score 9/10

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

      Great Kelly.. keep learning

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

    Hi @Raghav,
    Thanks for the session, really appreciative.
    i have one problem, if I am running "npx playwright test --project=chromium" it runs ver well
    but the moment I include file as "npx playwright test --project="chromium" .\tests\my_first_test.spec.js" it says "Error: No tests found.
    Make sure that arguments are regular expressions matching test files."
    Not able to figure out why?
    Can you please help

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

      Piyush
      Try to give the path with single forward slashes.. like :
      npx playwright test ./tests/my_first_test.spec.js
      Also make sure the path and names are correct.. one way to check this is while typing the path, type first few characters of the folder/file name and press tab to autocomplete.
      If this does not work, check the following:
      1. Test File Naming Convention:
      - Playwright Test expects test files to be suffixed with either `.spec.js` or `.test.js`.
      - Ensure that your test file name follows this convention. If your file is named `my_first_test.spec.js`, it should work correctly.
      2. Check Your File Name:
      - Verify that the file path you're providing is correct. In your case, it's `.\\tests\\my_first_test.spec.js`.
      - Make sure the file exists at that location and has the correct suffix (`.spec.js`).
      3. Configuration:
      - If you're using a configuration file (such as `playwright.config.js`), ensure that the `testMatch` property is correctly set.
      - The `testMatch` property specifies glob patterns or regular expressions that match test files. By default, Playwright Test looks for files with `.spec.js` or `.test.js` extensions.
      - If you don't have a configuration file, Playwright Test will use the default behavior.
      4. Quick Fix:
      - Sometimes, replacing backslashes (`\\`) with forward slashes (`/`) in the file path can resolve issues. Try running:
      ```
      npx playwright test ./tests/my_first_test.spec.js
      ```
      5. Example:
      - If your test file is named `my_first_test.spec.js`, make sure it's in the correct location and try running the command again.
      Remember to double-check the file name, path, and configuration
      --

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

      @@RaghavPal
      After your suggestion used "/" and it worked, Thank you🙂

  • @aw-or9pl
    @aw-or9pl ปีที่แล้ว +1

    Hello, thank you for the video, however I am running into the same issues as others where I receive an error of "No Tests Found". I verified in the testDir: that the file path is correct and I still receive the error. I have followed steps from the video exactly with only minor test name changes. The tests appear in the "Testing" section of VS code but I still receive the no tests found error. I'm unable to run any tests from the terminal.

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

      Hi,
      If you are getting a "No Tests Found" error when running your Playwright tests, it's likely that there's an issue with how you've structured your test files or with the configuration of your test runner. Here are some things you can check to resolve this issue:
      Make sure your test files are in the correct directory: Ensure that your test files are located in the directory specified in the testDir configuration option in your Playwright configuration file. By default, the testDir is set to ./tests, so make sure your test files are located in a folder called tests in the root directory of your project.
      Check that your test files are named correctly: Make sure your test files have the correct naming convention, which is to start with the word test followed by a descriptive name, and end with the .spec.js extension. For example, testHomePage.spec.js.
      Verify that your test files have the correct test functions: Ensure that your test files have at least one test function defined with the test keyword. For example:
      test('should display the correct title', async () => {
      // test code here
      });
      Check that your test runner is configured correctly: Make sure that your test runner is correctly configured to use Playwright. For example, if you're using Jest as your test runner, you'll need to install the jest-playwright package and add it to your Jest configuration file.
      Try running your tests from the command line: If you're unable to run your tests from within VS Code, try running them from the command line to see if you get the same error message. You can do this by navigating to the root directory of your project and running the npm test command.

    • @aw-or9pl
      @aw-or9pl ปีที่แล้ว +6

      @@RaghavPal Hello, thank you very much for the reply.
      I was able to get fixed. There are two issues/details that were causing this. I'll write it here in case others have the same problem.
      1. In order for tests to be found the file name MUST be titled xxx.spec.js (having just xxx.js will not work)
      2. If using a device with the Windows OS, the file name in the CLI must have 2 backslashes instead of one.
      so it should be "npx playwright test .\\tests\\my_first_test.spec.js

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

      thanks for adding

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

      ​@@RaghavPali followed this still no test found

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

      ​@@aw-or9plno test found still showing

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

    In pervious I score 100%, thanks for helping and guiding

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

      Well done Vishal

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

    Hi @Raghav, which automation tool/s are good for Salesforce web application?
    Playwright can use?

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

      Can use it, do a POC first

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

      @@RaghavPal Okay, thank you Raghav

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

    do you find more convenient working playwright with typescript? or in terms of automation testing framework, it does not have a big impact to decide work wether with ts or js ?

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

      TS is a wrapper over JS, and TS code ultimately transpiles down to JS, so if you are comfortable with TS, can go for it

  • @KrishnaKumar-vp3wg
    @KrishnaKumar-vp3wg ปีที่แล้ว +1

    Sir I don't have knowledge of node js should I continue further with this tutorial??

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

      You can continue, we do not need to learn Node JS, we just need to install and setup so that we can create Playwright project, all this is covered in the tutorial

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

    Hi Raghav,
    I have a question about the very last part, specifically the "expect..." section.
    Firstly, why did it show as an error? Shouldn't it have shown as "This is expected and this is what really is"?
    The next question is, why is the error shown at the beginning of ".toHaveTitle"?

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

      Please add the timestamp of the part, I will refer and check

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

      @@RaghavPal
      timestamp is 21.10

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

      Yes, so if you see the report.. it shows what was expected and what is actual. And it is pointing to the right function that failed

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

    Hi raghav, I am getting error like "Playwright Test did not expect test() to be called here." when i run my first test for opening google page. Could you please help on this

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

      Dinesh
      the error "Playwright Test did not expect test() to be called here" occurs when test() is used incorrectly.
      Fix:
      Correct Structure: Ensure your test is inside a valid test block:
      javascript
      const { test, expect } = require('@playwright/test');
      test('should open Google', async ({ page }) => {
      await page.goto('www.google.com');
      await expect(page).toHaveTitle(/Google/);
      });
      Avoid Calling test() in Functions: test() should not be inside other functions or blocks
      Ensure async/await is Used Properly
      --

  • @PraveenK-x7j
    @PraveenK-x7j ปีที่แล้ว +2

    Hi sir
    I need to one help
    how to use in Java from Playwright plz reply me sir
    i will wait for your reply

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

      Hi Praveen
      Here are the steps on how to use Playwright in Java:
      1. Install the Playwright Java library. You can do this using the following command:
      ```
      mvn install playwright-java
      ```
      2. Create a new Java project.
      3. Add the Playwright Java library to your project's dependencies.
      4. Create a new class that will use Playwright.
      5. In your class, create a new instance of the `Playwright` class.
      6. Use the `Playwright` class to create a new browser instance.
      7. Use the browser instance to navigate to a website.
      8. Use the browser instance to interact with the website.
      9. Close the browser instance.
      Here is an example of a Java code that uses Playwright:
      ```java
      import com.microsoft.playwright.*;
      public class PlaywrightExample {
      public static void main(String[] args) {
      Playwright playwright = Playwright.create();
      Browser browser = playwright.chromium().launch();
      Page page = browser.newPage();
      page.navigate("www.google.com");
      System.out.println(page.title());
      browser.close();
      }
      }
      ```
      This code will open a new Chromium browser and navigate to the Google website. The code will then print the title of the Google website to the console. Finally, the code will close the browser.
      I hope this helps

  • @DK-ik3bf
    @DK-ik3bf 10 หลายเดือนก่อน

    Hi I have a question, when I did the import--> import {hello, helloworld} from './demo/hello' and console.log one of the hello functions, I got this error message:
    import {hello, helloworld} from './demo/hello'
    SyntaxError: Cannot use import statement outside a module
    Do you happen to know what I missed? Thank you

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

      D K
      Understanding the Error:
      - This error arises when you attempt to use `import` statements in a non-module context, typically within a plain JavaScript file that hasn't been configured as a module.
      Resolving the Issue:
      1. Ensure Module Context:
      - ESM Modules (Recommended):
      - Use the `.mjs` file extension for your JavaScript files to explicitly signal ESM format.
      - Include a `type: "module"` field in your `package.json` if you prefer `.js` extensions.
      - CommonJS Modules:
      - If using CommonJS modules (e.g., in Node.js), leverage `require()` instead of `import`.
      - Consider a transpiler like Babel for compatibility if necessary.
      2. Check File Extensions:
      - Verify that both the importing and imported files have appropriate extensions (`.mjs` or `.js` with `type: "module"`).
      3. Inspect IDE/Tooling Configuration:
      - Ensure your IDE or testing environment supports and recognizes ESM modules.
      - If using Node.js, use a recent version (v14+) or enable experimental modules flag (`--experimental-modules`).
      4. Address Node.js Compatibility:
      - If working in Node.js, use `node --experimental-modules` or a tool like `esm` to run ESM code directly.
      - Consider a transpiler like Babel for broader compatibility.
      5. Correct Syntax:
      - Double-check for any typos or syntax errors in your import statements.
      Example (ESM Modules):
      ```javascript
      // test.mjs (or test.js with `type: "module"` in package.json)
      import { hello, helloworld } from './demo/hello.mjs';
      console.log(hello());
      ```
      Example (CommonJS Modules):
      ```javascript
      // test.js
      const { hello, helloworld } = require('./demo/hello.js');
      console.log(hello());
      ```
      Additional Tips:
      - Adhere to consistent module syntax throughout your project.
      - Stay updated with Node.js and Playwright versions for optimal module support.
      - Seek support from Playwright documentation or communities if issues persist.
      ..

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

    Hi sir, iam getting Test has unknown parameter "page" in Terminal and highlighting this line in code test('basic test', async({page}) => { can pls answer my query?

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

      Harsha
      The error occurs because test and page are part of Playwright Test’s fixtures. To fix it:
      Install Playwright Test:
      npm install @playwright/test
      Import Correctly:
      Add this at the top of your file:
      import { test, expect } from '@playwright/test';
      Run the Test Properly:
      Use this command to run your tests:
      npx playwright test
      This ensures Playwright Test's fixtures (like page) work correctly
      -

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

    I have followed everything step by step but when I go to run my own test file in the tests directory i get 'no tests found' during the google title demo. however, when i run the example test they provide, that one does work. i also have to cd into the tests directory in order to make the example.spec.js for it to work. no clue what could be wrong.

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

      Hi Mitch
      If you are facing a "no tests found" error when running your own test file with Playwright, there could be several reasons for this issue:
      Make sure your test file is located in the correct directory: By default, Playwright looks for test files in the tests directory. If your test file is located in a different directory, you may need to specify the correct path when running the test.
      Ensure that your test file has the correct naming convention: Playwright looks for files with the .spec.js extension in the tests directory. If your test file has a different extension or does not follow the naming convention, Playwright may not be able to find it.
      Check if you have the necessary dependencies installed: Make sure that all the required dependencies for running your test file are installed. This includes Playwright itself, as well as any other dependencies your test file may have.
      Verify that your test file has valid tests: Ensure that your test file contains valid tests that can be executed by Playwright. If there are no tests or if the tests are not written correctly, Playwright may not be able to find them.
      If you have checked these potential issues and still can't get your test file to run, you may want to reach out to the Playwright community or support team for further assistance.

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

      @@RaghavPal hi is it resolved? I am getting the same error - "No tests found"

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

      Hi, If you are getting the same issue "No Test Found" or "MOdule_Not_Found", make sure you have the correct content under the helo.js file and this following code under our file created under the tests folder "const {hello, helloworld} = require ('./demo/helo.spec')", in my case I renamd the file to a helo.spec.js, that's why I've used './demo/helo.spec' @@sarayum7934

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

      Hello Mitch and team, this can happen even when
      Test files are recognized by their name endings, such as .spec.js, .test.js, etc., for TypeScript and other languages. If you have named your test files in the required format, then it is fine; otherwise, they will not be recognized, and an error will be thrown.
      Example: If your test file has the name myPlayrightTest.js without the .test.js or .spec.js suffix then you will face the same issue. Change your file name to myPlayrightTest.spec.js or myPlayrightTest.test.js

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

    Thanks, sir for such an amazing video... Your videos are very simple and clear to follow along...

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

      You are most welcome

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

    Can I use Playwright in visual studio using C#. Currently I want to achieve a scenario where I can login and pick bearer token from network tab for further automation testing?

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

      Sheetal
      Yes, you can effectively use Playwright with C# in Visual Studio to achieve the scenario of logging in, capturing the bearer token, and using it for further automation testing. Here's a comprehensive guide:
      Prerequisites:
      - Install Playwright: Use NuGet Package Manager in Visual Studio to install the `Microsoft.Playwright` package.
      - Choose a Browser: Select the browser you'll use for testing (Chromium, Firefox, or WebKit).
      Steps:
      1. Create a Playwright Instance:
      ```csharp
      using Microsoft.Playwright;
      var playwright = await Playwright.CreateAsync();
      var browser = await playwright.Chromium.LaunchAsync(); // Or other browser
      ```
      2. Navigate to Login Page:
      ```csharp
      var page = await browser.NewPageAsync();
      await page.GotoAsync("your-login-page-url");
      ```
      3. Interact with Login Elements:
      - Use `page.FillAsync()` to fill in username and password fields.
      - Use `page.ClickAsync()` to submit the login form.
      4. Capture Bearer Token:
      ```csharp
      await page.RouteAsync("/*", async route =>
      {
      if (route.Request.Url.PathAndQuery.Contains("login-endpoint"))
      {
      var response = await route.Response();
      var bearerToken = response.Headers["Authorization"]; // Extract token
      // Store the token securely for later use
      }
      });
      ```
      5. Perform Additional Actions with Token:
      - Use the captured token in subsequent requests for authenticated actions.
      - Set the token in the `Authorization` header of subsequent requests.
      - Example:
      ```csharp
      await page.GotoAsync("authenticated-page");
      await page.SetHeaderAsync("Authorization", bearerToken);
      ```
      Additional Tips:
      - Isolate Authentication State: Store authenticated state to avoid repeated logins.
      - Secure Token Storage: Avoid storing tokens directly in code for security.
      - Handle Token Expiration: Implement logic to refresh tokens if needed.
      - Utilize Playwright's Features: Explore other Playwright features for testing scenarios.
      Remember to adapt the code snippets to your specific application's login process and token format.

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

      Thanks a lot. This really helps. I was able to achieve the scenario@@RaghavPal

  • @learning-Neha
    @learning-Neha 8 หลายเดือนก่อน

    thank u so much for such thorough explanations!

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

      You're very welcome Neha

  • @NicolaeDaian-x1y
    @NicolaeDaian-x1y ปีที่แล้ว

    Great tutorial, thank you for it!! I have an unrelated question, could you share what browser extension you use to highlight something (the red rectangle) and what extension you use for zooming (the zooming circle).

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

      Nicolae
      I am using mac annotation tools

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

    Hello :)
    I'm just wondering if we need to manually write when we want to run tests? There are no options like "Run the test" ?

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

      Also, I have some issues, in this tests (making)... Are you willing to give me any contact where I can send you screenshots?

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

      So we have to run the command *npm playwright test* to run the tests, and we can have multiple options with this command like selecting specific test file, browsers etc

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

    Hi, thanks you so much for the course! Really enjoying it. Could you please help me find what the issue is? When I run the test with the command, it says that there is no test. Thank you
    If I use the command - npx playwright test - everything is fine
    PS C:\Playwright examples> npx playwright test .\tests\my_first_test.spec.ts
    Error: No tests found.
    and the report shows this:
    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  6 หลายเดือนก่อน

      Elena
      Try using the path with single forward slash '/'
      npx playwright test ./tests/my_first_test.spec.ts
      Here are a few potential solutions based on the information available:
      1. Test Discovery Issue:
      - The error message "No tests found" suggests that Playwright is unable to discover any test files.
      - Make sure that your test files are correctly located and named. Ensure that they follow the expected naming conventions (e.g., ending with `.spec.ts`).
      - Verify that your test files contain valid test cases using the Playwright test framework.
      2. Configuration File Issue:
      - Check if you have a configuration file (usually named `playwright.config.js` or `playwright.config.ts`) in your project.
      - Ensure that the configuration file specifies the correct test directory and test file patterns.
      - If you're using a custom configuration, review it to make sure it's correctly set up.
      3. Test Execution Syntax:
      - When running tests with `npx playwright test`, you can specify test files using regular expressions.
      - Double-check that the path you're providing to `npx playwright test` matches the actual location of your test files.
      - If your test file path contains special characters (e.g., `$`, `*`), escape them properly.
      4. Parallel Execution Issues:
      - If you're running tests in parallel, ensure that there are no conflicts between test files.
      - Sometimes parallel execution can cause issues with shared resources (e.g., login sessions).
      - Consider running tests sequentially (`--workers 1`) to see if the problem persists.
      5. Azure DevOps Pipeline Specifics:
      - In your Azure DevOps Pipeline configuration (`azure-pipelines.yml`), you might need to adjust settings related to Node.js version, browsers, and parallel execution.
      - Review the pipeline steps and verify that they match your local setup.
      6. Unique Tags for Tests:
      - If you want to exclude specific tests from execution, consider adding unique tags to describe blocks in your test files.
      - Use the `--grep` and `--grep-invert` CLI parameters to selectively run or exclude tests based on these tags².
      Remember that debugging issues like this often involves trial and error. Start by checking the basics (file paths, configuration, etc.), and gradually narrow down the problem

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

      @@RaghavPal oh my. Thank you :) I knew there was something ridiculously simple :)

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

    Hey Raghav, I don't have the playwright\test folder in my node_modules folder. I do have the playwright and playwright-core folder. Did I forget to install something?

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

      To resolve this issue, you can install the `@playwright/test` package by running the following command in your terminal:
      ```
      npm i -D @playwright/test
      ```
      This command installs the `@playwright/test` package as a dev dependency for your project. After installation, you should see the `@playwright/test` folder within `node_modules`, and you'll be able to import and use functionalities from this package in your tests...
      Additionally, ensure that your `playwright.config.js` file is correctly set up with the `testDir` configuration pointing to the directory where your test files are located. This setup is necessary for Playwright to find and run your tests³. If you continue to face issues, you may want to refer to the official Playwright documentation or seek support from the community forums..

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

    @raghav Thanks for your effort in making best videos. In playwright-pytest should we use "sync_playwright" module or
    "async_playwright" module.

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

      When working with Playwright-Pytest, you have the choice between using the "sync_playwright" module or the "async_playwright" module. Let's explore the differences and decide which one suits your needs:
      1. Sync Playwright (sync_api):
      - The sync_api is a wrapper around the asyncio_api that abstracts away the usage of asyncio.
      - It provides a synchronous interface, making it easier to work with for developers familiar with synchronous programming.
      - You can use it for straightforward scenarios where you don't need advanced asynchronous features.
      - However, keep in mind that it blocks execution until the operation completes.
      - Use sync_playwright if you prefer simplicity and ease of use¹.
      2. Async Playwright (async_api):
      - The async_api directly exposes Playwright's asynchronous capabilities.
      - It allows you to work with async/await patterns, making it suitable for more complex scenarios.
      - If your Python project already uses the asyncio module (which stands for Asynchronous I/O), async_playwright is a natural fit.
      - With async, you can perform non-blocking I/O operations, allowing better concurrency.
      - Consider async_playwright if you need flexibility, especially for scenarios involving multiple threads or complex interactions¹².
      In summary:
      - Use sync_playwright for simplicity and ease of use.
      - Choose async_playwright if you need advanced asynchronous capabilities or if your project already utilizes asyncio.
      Remember to align your choice with your project requirements and familiarity with asynchronous programming. .

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

      @@RaghavPal Thanks a lot for your quick reply.

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

      @@RaghavPal One more thing if i understand it correctly, playwright async is useful in case you don't want to introduce a delay in the script. because async uses auto wait. In case of async and await, if promise is not returned, what will be the default time out. how actually execution happening with async and await. Thanks

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

      Let's dive into the world of Playwright, async/await, and how they work together.
      1. Async/Await in Playwright:
      - Async Functions: When you declare a function as `async`, you're telling Node.js that it contains asynchronous code. These functions return a Promise.
      - Await: The `await` keyword is used within an `async` function to pause execution until a Promise is resolved. It ensures that subsequent lines of code wait for the previous asynchronous operation to complete.
      - Promises: Playwright methods (like `.fill()`, `.click()`, or `.evaluate()`) return Promises. These methods perform actions asynchronously, and `await` ensures that the next line of code doesn't execute until the Promise is resolved.
      2. Execution Flow with Async/Await:
      - Let's break down your example:
      ```javascript
      test.only("Basic Login", async ({ page }) => {
      await page.goto("/");
      page.getByPlaceholder("Email Address").fill("foo@email.com");
      await page.getByPlaceholder("Password").fill("bar");
      await page.getByRole("button", { name: "Sign In" }).click();
      await expect(page).toHaveTitle("The Foobar Page");
      });
      ```
      - Here's what happens step by step:
      1. `await page.goto("/")`: The page navigates to the specified URL. The execution waits until this navigation is complete.
      2. `page.getByPlaceholder("Email Address").fill("foo@email.com")`: The `getByPlaceholder` method returns a locator (not a Promise). The `.fill()` method is initiated, which is asynchronous. However, since `getByPlaceholder` doesn't return a Promise, execution proceeds immediately.
      3. `await page.getByPlaceholder("Password").fill("bar")`: Similar to the previous step, the `.fill()` method is initiated, but there's no waiting for the previous `.fill()` to complete.
      4. `await page.getByRole("button", { name: "Sign In" }).click()`: Again, the `.click()` method is asynchronous, but it doesn't wait for the previous `.fill()` to finish.
      5. `await expect(page).toHaveTitle("The Foobar Page")`: The `expect` assertion is asynchronous, and it waits for the title check to complete.
      3. Chaining Promises:
      - Playwright methods don't return Promises directly. Instead, they return locators (like constructors) that can be chained.
      - For example:
      ```javascript
      await new Bicycle().ride(); // New Bicycle isn't async, but .ride() is.
      ```
      - In Playwright, locators don't use the `new Locator` syntax. Instead, you can chain methods directly:
      ```javascript
      await bicycle().ride(); // Or use an intermediate variable: const bike = bicycle(); await bike.ride();
      ```
      4. Timeouts:
      - Assertions (like `expect(locator).toHaveText()`) have their own timeout (default: 5 seconds) unrelated to the test timeout.
      - Test timeouts (default: 30 seconds) include time spent in test functions, hooks, and fixtures.
      - If you need to customize timeouts, you can set them in the test configuration or individually for specific tests using `test.setTimeout()`¹².
      Remember, async/await simplifies handling asynchronous code, but understanding how Promises work under the hood is crucial for effective debugging and writing robust tests.

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

      @@RaghavPal Thanks a lot.

  • @AnjaliSingh-h7c
    @AnjaliSingh-h7c ปีที่แล้ว

    Hi Raghav, I don't see lib under my playwright/tests

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

      Anjali
      The `lib` directory is not included in the default installation of Playwright. It is a custom directory that you can create to organize your own Playwright test utilities and code. If you need to use a `lib` directory, you will need to create it yourself.
      Here are the steps on how to create a `lib` directory and add it to your Playwright test project:
      1. Create a new directory named `lib` within your test project directory.
      2. Move any test utilities or code that you want to reuse across multiple test files into the `lib` directory.
      3. In your test files, import the utilities or code from the `lib` directory using the following syntax:
      ```javascript
      const myUtility = require('./lib/myUtility');
      ```
      This will allow you to use the `myUtility` function from the `lib` directory in your test file.
      Using a `lib` directory can help you organize your Playwright test code and make it easier to reuse common utilities across multiple tests

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

    Getting this error Error: No tests found.
    Make sure that arguments are regular expressions matching test files.
    You may need to escape symbols like "$" or "*" and quote the arguments.
    I tried in new terminal as well, Please help.

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

      Ankita
      Try to give single forward slashes / in your path in the command e.g.
      npx playwright test ./tests/first.spec.js
      If this does not work check other things as follows:
      1. Check Test File Path:
      Ensure that your test files are located in the correct directory. By default, Playwright looks for test files in the `tests` folder. Make sure your test file is in the right place
      2. Test File Naming Convention:
      Your test files should be suffixed with either `.spec.js` or `.test.js`. For example, if your file is named `first.js`, rename it to `first.spec.js` or `first.test.js`. Playwright expects this naming convention for test files
      3. Run Tests with Correct Path:
      When running tests, specify the correct path to your test file. Use the relative path from the root of your project. For example:
      ```bash
      npx playwright test ./tests/first.spec.js
      ```
      4. Escape Characters:
      If your test file path contains special characters like spaces, make sure to escape them properly. Enclose the path in quotes if needed:
      ```bash
      npx playwright test "./tests/my test file.spec.js"
      ```
      5. Configuration Check:
      Double-check your Playwright configuration (e.g., `playwright.config.js`). Ensure that the `testDir` property points to the correct folder where your test files reside.
      -

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

      @@RaghavPal thanks it worked.

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

      @@RaghavPal Hi Raghav. I tried all the above mentionedd steps. Still facing the same issue.

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

    After learning Playwright , do I still need to learn mobile testing tool Appium as well?

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

      Nidhi
      Great question! Both Playwright and Appium are powerful tools, but they serve different purposes.
      Playwright is primarily designed for web application testing across different browsers and platforms. It excels in automating web interactions and is known for its speed and reliability in handling modern web applications
      Appium, on the other hand, is specifically tailored for mobile app testing. It supports testing of native, hybrid, and mobile web applications on both iOS and Android platforms. Appium's cross-platform capabilities and large community support make it a versatile choice for mobile testing
      If your focus is on web applications, Playwright might be sufficient. However, if you need to test mobile applications, learning Appium would be beneficial. It really depends on your specific testing needs and the platforms you are targeting.
      -

  • @KrishnanP-hg8ff
    @KrishnanP-hg8ff วันที่ผ่านมา

    Those who are facing problem while executing the test by using npx playwright test .test/filename.spec.js
    The filename should not have test - for example first_test.spec.js. It should be anything but not include test in it for example First.spec.js.
    I hope it works fine.For me it took 10 minutes to find. Happy learning.

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

      Krishnan
      pls confirm on this. Those facing issues while running npx playwright test .test/filename.spec.js:
      Ensure the filename matches Playwright's default patterns (.spec.js or .test.js).
      For example: first_test.spec.js or first.spec.js works fine.
      Check your configuration if it still doesn't run
      -

  • @ArtiBhalerao-z1r
    @ArtiBhalerao-z1r 11 หลายเดือนก่อน

    Hi Sir, y cant i see the test and expect files under @playwright\test under lib..beacuse of which my first tests says not found

    • @ArtiBhalerao-z1r
      @ArtiBhalerao-z1r 11 หลายเดือนก่อน

      changed to forward slash and it worked

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

      Great

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

    Hi Raghav, why m unable to see expect.js under my playwright/test package

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

      Snehlata
      The issue you're experiencing is because the `expect` function from Playwright's test library is specifically designed to work in the context of Playwright's test runner. It doesn't quite play well when you try to run it within other contexts (such as Cucumber) because different test runners handle assertions differently.
      Here are some steps to resolve this:
      1. Remove playwright-expect:
      - You don't need to use the `playwright-expect` library. Playwright already includes web-first assertions, so there's no reason to use an additional library to extend `expect`.
      - Remove the following line from your code:
      ```javascript
      const { matchers } = require('playwright-expect');
      ```
      2. Install @playwright/test:
      - Make sure you have the `@playwright/test` library installed as a development dependency in your `package.json`.
      - If not, install it using:
      ```
      npm install -D @playwright/test
      ```
      3. Use Playwright's Built-in Assertions:
      - Playwright provides its own assertions, which are automatically available when you use `@playwright/test`.
      - You can directly use assertions like `expect(page).toHaveText('Hello, World!')` without any additional setup.
      4. Run Your Tests:
      - After making these changes, run your tests again using the following command:
      ```
      npx playwright test
      ```
      Remember that Playwright's test library is specifically designed for Playwright, and it provides a seamless experience for testing web applications. Stick to Playwright's built-in assertions, and you'll have a smoother testing process.
      ..

  • @arunkumar-987
    @arunkumar-987 ปีที่แล้ว

    Hi Raghav,
    I am trying to run the test as shown in the video but I am seeing "Error : No test found" in terminal
    Can you please guide??

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

      Arun
      Try using forward slashes in the path of test file

    • @arunkumar-987
      @arunkumar-987 ปีที่แล้ว

      @@RaghavPal Its working, Thanks

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

    My quiz score is 9/10 - good learning

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

      Great Tevan.. all the best for next

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

    node .\test\FirstTest.js is not working on my terminal
    but npx playwright test FirstTest.spec.js this will work can you please explain why?

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

      Let's troubleshoot this.
      1. File Naming Convention:
      - Playwright Test expects test files to be suffixed with either `.spec.js` or `.test.js`. Make sure your `FirstTest.js` file follows this convention.
      - If it doesn't, consider renaming it to `FirstTest.spec.js` or `FirstTest.test.js`.
      2. Configuration File:
      - Check if you have a configuration file (usually named `playwright.config.js` or similar) in your project.
      - Ensure that you're not calling `test.describe()` directly in the configuration file. Test descriptions should be in separate test files.
      - Also, avoid calling `test.describe()` in files imported by the configuration file.
      3. Dependencies:
      - Verify that you're using the correct version of `@playwright/test`.
      - Sometimes having different versions of `@playwright/test` can cause issues. Ensure consistency across your dependencies.
      4. Test Match Patterns:
      - If you're using a custom test match pattern, make sure it's correctly configured in your `playwright.config.js`.
      - By default, Playwright Test runs tests from files matching `(test|spec)`.
      -

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

    Can you make a video with typescript codegen?

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

      I will plan.. but will take some time. Let's get you started with Playwright and TypeScript. Here's a step-by-step guide:
      1. Install Node.js and npm:
      Make sure you have Node.js and npm (Node Package Manager) installed on your system.
      2. Create a New Project:
      Open your terminal or command prompt and create a new directory for your Playwright project. Navigate to that directory:
      ```bash
      mkdir my-playwright-project
      cd my-playwright-project
      ```
      3. Initialize a New Node.js Project:
      Run the following command to create a `package.json` file:
      ```bash
      npm init -y
      ```
      4. Install Playwright and TypeScript:
      Install Playwright and TypeScript as development dependencies:
      ```bash
      npm install playwright typescript --save-dev
      ```
      5. Create a TypeScript Configuration File:
      Create a `tsconfig.json` file in your project directory:
      ```bash
      npx tsc --init
      ```
      6. Write Your First Test:
      Create a new TypeScript file (e.g., `my-test.ts`) in your project directory. In this file, import Playwright and write your test code. For example:
      ```typescript
      import { chromium, Browser, Page } from 'playwright';
      describe('My First Playwright Test', () => {
      let browser: Browser;
      let page: Page;
      beforeAll(async () => {
      browser = await chromium.launch();
      page = await browser.newPage();
      });
      afterAll(async () => {
      await browser.close();
      });
      it('should navigate to a website and assert title', async () => {
      await page.goto('example.com');
      const title = await page.title();
      expect(title).toBe('Example Domain');
      });
      });
      ```
      7. Run Your Test:
      Compile your TypeScript code using:
      ```bash
      npx tsc
      ```
      Then run your test using:
      ```bash
      npx jest my-test.js
      ```
      8. Generate Tests with Codegen (Optional):
      Playwright comes with a test generator that can create tests based on your interactions with a website. To use it, follow these steps:
      - Install the VS Code extension for Playwright.
      - Record your actions in the browser using the extension.
      - The extension will generate test code directly in VS Code.
      - You can also generate assertions for visibility, text, and value.
      - For more details, refer to the official Playwright documentation
      That's it! You're all set to write and run Playwright tests with TypeScript. Happy testing
      --

  • @MUHAMMADHARIS-e1h
    @MUHAMMADHARIS-e1h ปีที่แล้ว

    Hi Raghav, why we include the spec word in our file name

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

      Haris
      The word `spec` in a Playwright test file name is a convention that is used to identify the file as a test file. This convention is not required, but it is recommended because it makes it easier to find and organize test files.
      There are a few benefits to including the `spec` word in Playwright test file names:
      * It makes it easier to identify test files at a glance. When you are looking through a directory of files, it is easier to spot files that end in `.spec.js` or `.spec.ts`.
      * It helps to organize test files into a logical structure. For example, you can group test files by feature or by test type.
      * It is compatible with other test frameworks and tools. Many other test frameworks, such as Jasmine and Mocha, also use the `spec` convention for test file names. This makes it easier to integrate Playwright tests with other test frameworks and tools.

    • @MUHAMMADHARIS-e1h
      @MUHAMMADHARIS-e1h ปีที่แล้ว

      @@RaghavPal Now I understood. Thank you for your quick response.

  • @lifechance1
    @lifechance1 8 หลายเดือนก่อน +1

    I have question how to maximize browser while running

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

      Kishore
      To maximize the browser window while running tests with Playwright, you can use the `--start-maximized` flag when launching the browser. Here's how you can do it in your Playwright script:
      For Chromium browsers:
      ```javascript
      const { chromium } = require('playwright');
      (async () => {
      const browser = await chromium.launch({
      headless: false,
      args: ['--start-maximized']
      });
      const context = await browser.newContext({
      viewport: null // Disables the default viewport to allow for maximization
      });
      const page = await context.newPage();
      // Your code here
      })();
      ```
      For other browsers, you might need to set the window size manually using the `viewport` option or other browser-specific methods[^10^]. Remember to set the `viewport` to `null` to disable the default viewport size and allow the window to maximize.
      Keep in mind that the `--start-maximized` flag is specific to Chromium-based browsers and may not work with others like Firefox or WebKit. In such cases, you can manually specify the window size using the `viewport` option or use browser-specific methods to maximize the window

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

    thanks for such detailed explanation.

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

      Most welcome Priti

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

    Hello, I have followed the instructions, but am encountering an internal error for webkit. "Error: page.goto: WebKit encountered an internal error". What might be my mistake here?

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

      GH
      There are a few possible reasons why you might be encountering an internal error for WebKit in Playwright:
      *A bug in Playwright or WebKit.* It is possible that there is a bug in Playwright or WebKit that is causing the error. If you are using the latest version of Playwright and WebKit and you are still getting the error, you can try reporting it to the Playwright team
      *A problem with your environment.* It is also possible that there is a problem with your environment that is causing the error. For example, if you are using a proxy server, the proxy server may be blocking the connection to WebKit
      *A problem with your test code.* It is also possible that there is a problem with your test code that is causing the error. For example, if you are trying to go to a website that does not exist, you will get an error
      To troubleshoot the error, you can try the following steps:
      1. Make sure that you are using the latest version of Playwright and WebKit.
      2. Check your environment to make sure that there are no problems with your proxy server or other network settings.
      3. Try running your test code on a different browser, such as Chromium or Firefox. If the test code runs successfully on a different browser, then the problem is most likely with WebKit.
      4. If you are still getting the error, you can try debugging your test code to see where the error is occurring.
      If you are unable to resolve the error, you can try searching for help online or contacting the Playwright team.
      Here are some additional tips for avoiding this error:
      * Make sure that you are using the correct browser version. Playwright only supports certain versions of each browser. You can check the supported browser versions on the Playwright website.
      * Make sure that you are using the correct browser binary. Playwright needs to be able to find the browser binary in order to launch the browser. You can set the `PLAYWRIGHT_BROWSER_BINARY` environment variable to specify the location of the browser binary.
      * Make sure that you are not trying to do anything that is not supported by the browser. For example, if you are trying to use a feature that is only available in Chromium, you will get an error if you use WebKit.
      I hope this helps

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

      @@RaghavPal thank you very much for such an in depth reply. Sincerely appreciated

  • @Pallavi-ky4mw
    @Pallavi-ky4mw ปีที่แล้ว

    Hello Raghav, thanks for the tutorial
    I am getting an error saying "module not found" on my mac. I am not able to post a screenshot here.please help

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

      Hi Pallavi
      The error "module not found" can occur in Playwright on Mac for a few reasons. Here are some possible solutions:
      1. Make sure that you have installed the latest version of Playwright. You can do this by running the following command in your terminal:
      ```
      npm install -g playwright
      ```
      2. Make sure that the Playwright module is installed in your project. You can do this by running the following command in your project directory:
      ```
      npm install playwright
      ```
      3. Make sure that the Playwright module is imported correctly in your code. You can do this by checking that the import statement is correct and that the Playwright module is installed in the same directory as your code.
      4. If you are still getting the error, try restarting your Mac.
      If you are still having trouble, you can try the following:
      1. Check the Playwright documentation for more information on troubleshooting errors.
      2. Ask for help in the Playwright community forum.
      3. Report the error to the Playwright team

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

    suppose i have create separate folder out side tests folder, then also i need to give file name as My_First_Test.spec.js ?

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

      If you have created a separate folder outside of the tests folder to store your test files, you can still use the naming convention of "My_First_Test.spec.js" to indicate that the file contains test specifications.
      However, you should make sure that the folder you created is included in the test configuration for your testing framework or tool. For example, if you are using Jest, you can specify the folder where your test files are located using the testMatch option in your Jest configuration file (jest.config.js):
      module.exports = {
      // other Jest configuration options...
      testMatch: [
      '**/tests/**/*.spec.js', // include test files in the "tests" folder and subfolders
      '**/mytests/**/*.spec.js' // include test files in the "mytests" folder and subfolders
      ],
      };
      In the above example, the testMatch option specifies that Jest should include test files with the ".spec.js" suffix located in either the tests folder or the mytests folder, and in any subfolders within those folders.
      So, as long as your test files follow the naming convention of "My_First_Test.spec.js" and are located in a folder that is included in your testing framework or tool's configuration, they will be detected and run as tests.

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

    Hi Raghav , request for help . I get no tests found and not able to identify the reason when I click on Enter even though I have done everything as shown by you and there are no typo errors as well in the code and also using the same command as below
    npx playwright test .\tests\my_first_test.spec.js

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

      Hi Venkat
      If you are running Playwright tests using the command npx playwright test, and you are seeing the message "No tests found" even though you have created a test file and the command is correctly pointing to the file, there could be a few possible reasons for this issue. Here are some troubleshooting steps that you can try:
      Make sure that your test file is located in the correct directory and has the correct file extension. By default, Playwright looks for files with the .spec.js extension in the tests directory. Double-check that your file is named correctly and located in the correct directory.
      Ensure that your test file contains at least one test case that is exported. A test case is a function that uses the Playwright API to interact with a web page and make assertions. For example:
      const { test, expect } = require('@playwright/test');
      test('My first test', async ({ page }) => {
      await page.goto('example.com');
      const title = await page.title();
      expect(title).toBe('Example Domain');
      });
      Make sure that your test file contains at least one exported test case that is defined using the test() function from the @playwright/test package.
      Check for any syntax errors or typos in your test file. Even a small typo or syntax error can prevent your tests from running. Use a code editor or an IDE with syntax highlighting to identify any syntax errors or typos in your code.
      Ensure that you have installed the necessary dependencies. Make sure that you have installed the @playwright/test package and any other dependencies that your test file may require. You can do this by running npm install in your project directory.
      Try running the test with the --verbose option. Running your test with the --verbose option will give you more detailed output, including any errors that may be preventing your tests from running. Run the following command to run your test with the --verbose option:
      npx playwright test --verbose .\tests\my_first_test.spec.js
      If none of these steps resolve the issue, try creating a new, minimal test file and running it with the npx playwright test command to see if the issue persists. This will help you determine whether the issue is with your code or with your environment.
      I hope these steps help you identify the issue and get your tests running!

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

      I also had the same issue, I am using windows PC, then I change the backward slash to forward slash, now it working for me. (npx playwright test ./tests/my_First_test.spec.js).

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

      Ok, yes on windows you will either need to use double back slash \\ or single forward slash /
      I will suggest to use single forward slash / as it will work on all OS

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

    hey raghaz, i was following your turorial. My playwright is latest when i tried to run my first test got an error ''can not found module' i just saw that i dont have expect module under common folder. is this reason how can i resolve it?

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

      Hi Zaira
      If you encounter an error stating "cannot find module" when running your first Playwright test, it typically indicates that a required module is missing or not installed in your project.
      In your specific case, it seems that the `expect` module is missing from the common folder. The `expect` module is often used for assertions and assertions are commonly placed in the common folder for reusability.
      To resolve this issue, you can follow these steps:
      1. Make sure you have the `expect` module installed in your project. You can install it using npm (Node Package Manager) by running the following command in your project's root folder:
      ```
      npm install expect
      ```
      2. Once the `expect` module is installed, verify that it appears in your `package.json` file as a dependency. You should see an entry similar to:
      ```
      "dependencies": {
      "expect": "^x.x.x"
      }
      ```
      3. If the `expect` module is successfully installed and listed in `package.json`, try running your test again. The error should be resolved, and the test should execute without any "cannot find module" errors.

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

    Easy to understand and score is 10/10

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

      Great score Sagarika

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

    Hi sir. When i used the import statement and tried to run the code it threw "SyntaxError: Cannot use import statement outside a module" error. Could you kindly help on this?

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

      Mukund
      Here are the common causes and solutions:
      1. Missing or Incorrect Module Syntax:
      - Ensure `.js` or `.mjs` extension: Your code file must have a `.js` or `.mjs` extension to be recognized as a module.
      - Add `type="module"` (if necessary): If using `.js`, explicitly declare it as a module in your HTML file:
      ```html
      ```
      2. Node.js Environment:
      - Use `node --experimental-modules`: If running directly with Node.js, enable experimental modules support:
      ```bash
      node --experimental-modules your-playwright-script.js
      ```
      - Consider `package.json` configuration: For long-term compatibility:
      ```json
      {
      "type": "module"
      }
      ```
      3. Browser Environment:
      - Bundle code for browsers: Browsers don't natively support `import` statements. Use a bundler like Webpack or Rollup to package your code and dependencies for browser execution.
      4. Incorrect Import Path:
      - Double-check paths: Verify that the paths in your `import` statements are correct and point to existing modules.
      - Resolve relative paths: Ensure relative paths are resolved correctly based on file locations.
      5. IDE Configuration:
      - Configure for module support: Some IDEs might require configuration to recognize and run modules correctly.
      Additional Tips:
      - Update Node.js: Use a recent Node.js version (>=14.6.0) for better module support.
      - Consider `require`: If compatibility is crucial, use `require` instead of `import`, but be mindful of potential differences.

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

    Hi Raghav. Thank you for sharing wonderful course.
    I am facing a problem while displaying report. Show-report is not showing latest report. Please guide

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

      Hi Pallavi
      Here are some things that you can check to troubleshoot the issue of the show-report command not showing the latest report in Playwright:
      * Check the path to the report. Make sure that the path to the report that you are trying to show is correct. You can use the playwright show-report --help command to see the list of available reports.
      * Check the permissions to the report. Make sure that you have the permissions to access the report. You can use the ls -l command to see the permissions to the report.
      * Check the status of the report. Make sure that the report has been generated successfully. You can use the playwright generate-report command to generate the report.
      If you have checked all of these things and you are still having problems, you can try posting a question on the Playwright forum or mailing list. There are a number of experienced Playwright users who can help you troubleshoot the issue.
      Here are some additional things to keep in mind:
      * The show-report command will only show the latest report that has been generated.
      * The show-report command will only show reports that are in the current directory.
      * The show-report command will only show reports that have been generated using the playwright generate-report command.
      I hope this helps

  • @PK-jx3hp
    @PK-jx3hp ปีที่แล้ว

    Hi, Can you please also explain how to login/connect to SPA which requires Azure Authentication. I did not find any solution anywhere.
    Thanks

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

      P K
      To login/connect to SPA which requires Azure Authentication using Playwright, you can follow these steps:
      1. Create a new Playwright context.
      2. Navigate to the SPA login page.
      3. Fill in the Azure authentication credentials.
      4. Click the "Login" button.
      5. Wait for the SPA to redirect to the home page.
      Here is an example of how to do this in Python:
      ```python
      import asyncio
      from playwright.async_api import async_playwright
      async def main():
      playwright = await async_playwright.launch()
      context = await playwright.chromium.launch(headless=False)
      page = await context.new_page()
      await page.goto("example.com/login")
      # Fill in the Azure authentication credentials.
      await page.fill("input[name='username']", "username")
      await page.fill("input[name='password']", "password")
      # Click the "Login" button.
      await page.click("button[type='submit']")
      # Wait for the SPA to redirect to the home page.
      await page.wait_for_url("example.com/home")
      await context.close()
      await playwright.stop()
      if __name__ == "__main__":
      asyncio.run(main())
      ```
      If you are using a different programming language, you can follow the same steps, but you will need to use the Playwright API for that language.
      Here are some additional tips for logging in to SPAs which require Azure Authentication using Playwright:
      * If the SPA uses a single sign-on (SSO) flow, you may need to use a different Playwright API to login. For example, if the SPA uses OAuth 2.0 for SSO, you can use the `page.authenticate()` API to login.
      * If the SPA uses a custom authentication flow, you may need to write your own Playwright script to login.
      * If you are having trouble logging in, you can try using the Playwright debugger to inspect the SPA's network traffic and HTML code.
      I hope this helps

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

    Hi Great video for beginners such as myself, thank you. However I cannot replicate your use of require and import. I can use require but get an error when trying to use import. This can be fixed by putting in "type" : "module" in JSON file but that then gives an error with require. Any suggestions please?

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

      Hi Mike, this can help flexiple.com/javascript/javascript-require-vs-import/
      I will read more on this

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

    Hi sir ...
    npx playwright test command is running
    But npx playwright test .\tests\demo.spec.js command is showing "no tests found" ...
    Specific file is not running????

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

      Hi Poornima
      If the command npx playwright test .\tests\demo.spec.js is showing "no tests found," it typically indicates that there are no test cases defined in the specified file or the file is not recognized as a valid test file.
      Here are a few things you can check to resolve the issue:
      Verify the test file path: Make sure the file path .tests\demo.spec.js is correct and matches the actual location of your test file. Double-check for any typos or incorrect directory structures.
      Check the test file content: Ensure that the test file (demo.spec.js) contains valid test cases written using the Playwright test API. Each test case should be defined using the test function provided by Playwright. For example:
      const { test, expect } = require('@playwright/test');
      test('Test case name', async ({ page }) => {
      // Test steps and assertions
      });
      Confirm the correct test runner: Ensure that you are using the Playwright test runner to execute the tests. The npx playwright test command is specifically designed to run Playwright tests. If you're using a different test runner, such as Mocha or Jest, the command and syntax might differ.
      Check the test file extension: Playwright test files typically use the .spec.js or .test.js file extension. Verify that the test file you're trying to run has the correct extension and is recognized by the test runner.
      Validate the Playwright installation: Make sure you have installed Playwright and its dependencies correctly. Run npx playwright install to ensure all necessary components are set up properly.
      By checking these points, you should be able to identify and resolve any issues preventing the specific test file from running successfully using the npx playwright test command.

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

      @@RaghavPal I'm not able to run sir

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

      will need more details. Also try getting online help

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

      @@RaghavPal ok sir .. thank you for your response

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

    I am following this tutorial, when running command node .\tests\my_first_test.spec.js is giving me error "module not found" . However I am getting perfect result if using command node my_first_test.spec.js. Could you please explain why

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

      1. Relative vs. Absolute Paths:
      - "node my_first_test.spec.js" works because it uses an absolute path, directly referencing the file from the current working directory.
      - "node .\tests\my_first_test.spec.js" fails because it uses a relative path, which requires Node.js to locate the file relative to the current working directory. If you're not in the correct directory, it won't find it.
      2. Resolving the Issue:
      - Change Directory: Before running the command, navigate to the `tests` directory using `cd tests`. Then execute the command as `node my_first_test.spec.js`.
      - Use Absolute Path: Alternatively, provide the full path to the file, like `node C:\path\to\project\tests\my_first_test.spec.js`.
      3. Additional Considerations:
      - Node Version Compatibility: Ensure you're using a Node.js version that supports Playwright (14 or above is recommended).
      - Project Structure: Verify that your Playwright configuration file (`playwright.config.js` or `playwright.config.ts`) is in the correct directory and has accurate test file patterns.
      - Module Installation: If using Playwright as a dependency, confirm it's installed correctly in your project's `node_modules` directory.
      Best Practices:
      - Consistency: Use consistent paths (either relative or absolute) throughout your project for clarity.
      - Configuration File: Leverage the `testDir` option in your Playwright configuration file to specify the test directory, simplifying command execution.

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

    Whenever Playwright version I update, should I manually download or update browsers?

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

      Sheetal
      No, you won't need to manually download or update browsers when you update Playwright itself.
      You can confirm the browser versions being used after updating Playwright using the following commands:
      ```bash
      npx playwright list-browsers
      ```
      Here's why:
      1. Automatic Browser Management:
      - Playwright takes care of downloading and managing compatible browser binaries automatically.
      - It streamlines the process, saving you time and effort.
      2. Aligned Versions:
      - Each Playwright version is specifically designed to work with compatible browser versions.
      - This ensures smooth test execution and avoids compatibility issues.
      3. Update Process:
      - When you update Playwright, it automatically checks for and downloads any required browser updates.
      - You don't need to manually intervene in this process.
      So to sum up:
      - Playwright handles browser updates automatically, so you can focus on testing rather than managing browser versions.
      - Upgrading Playwright ensures you're using compatible browser versions, maintaining test reliability.
      - You have the flexibility to control browser versions if specific needs arise.

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

    does this cover cucumber/specflows aswell?

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

      Not in this session

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

    Hi Raghav,
    Do you have videos on Playwright with TypeScript

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

      not on playwright, you can follow these tutorials and there will be slight change in syntax that you can get from documentation. In case you need to learn TypeScript can check tutorials here - automationstepbystep.com/

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

      @@RaghavPal Thanks Raghav for replying my query.

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

    Both in the previous lecture and this lecture, I am getting "Error: No tests found" when attempting to run a specific test with the 'npx playwright test .\tests\my_first_test.spec.js'
    It also didn't work when using the 'example.spec.js' that came with the playwright installation. Has this functionality changed? I have seen your answers to others who had similar errors, but I'm not sure how it wouldn't be a proper test file when it is exactly the same as the one you're seemingly using.
    EDIT: I should mention that all tests run as expected when I use 'npx playwright test' to run all tests - it's only when targeting a specific test in the way that you demonstrate that I'm getting 'Error: No tests found'.... So, again, it doesn't seem to be an issue with the test not being valid.

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

      Nevermind. I figured it out.
      I just have to type: npx playwright test my_first_test.spec.js
      Putting the ".\tests\" part is what was messing it up. Still not sure why it works for you, but at least I figured it out on my end.

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

      Glad it worked Erik

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

      @@erikpugh7028 - i am having same issue, can run with giving single file name but not path, could you tell me why

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

      @@erikpugh7028 I was having the same problem and this solved it. Thank you!

  • @SwatiSharma-m8s
    @SwatiSharma-m8s 10 หลายเดือนก่อน

    Hi in playwright\test lib and types are not display. how to add these

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

      Swati
      Here are the steps to ensure Playwright types and libraries are displayed correctly in your development environment:
      1. Installation:
      - Using npm:
      ```bash
      npm install --save-dev @playwright/test
      ```
      - Using yarn:
      ```bash
      yarn add --dev @playwright/test
      ```
      2. IDE Configuration:
      - Visual Studio Code:
      - Install the "TypeScript and JavaScript Language Features" extension (if not already installed).
      - Restart VS Code to ensure type recognition.
      - Other IDEs:
      - Consult their documentation for specific configuration instructions regarding TypeScript support.
      3. Import Statements:
      - Use correct import statements in your test files:
      ```javascript
      import { test, expect } from '@playwright/test';
      ```
      4. TypeScript Configuration (if applicable):
      - Create a `tsconfig.json` file at the root of your project with basic settings:
      ```json
      {
      "compilerOptions": {
      "target": "ES2017",
      "module": "commonjs",
      "baseUrl": ".",
      "types": ["@playwright/test"]
      }
      }
      ```
      Additional Troubleshooting:
      - Check TypeScript Version: Ensure you're using TypeScript version 4.4 or higher for full Playwright support.
      - Clear Cache and Restart: If issues persist, try clearing your IDE's cache and restarting it.
      - Manual Type Installation: If type recognition remains problematic, install types manually:
      ```bash
      npm install --save-dev @types/playwright
      ```

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

    Hello sir wat does worker actually mean ..is it a process ..

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

      Shylaja
      Yes, in Playwright, a worker is a separate process that runs test scripts in parallel. This parallelism helps improve the overall performance of test execution by distributing the workload across multiple processes. Each worker runs its own instance of the browser and executes test scripts independently.
      Here's a more detailed explanation of how workers function in Playwright:
      1. **Worker Initialization:** When you start a Playwright test run, Playwright creates a pool of worker processes. The number of workers is determined by various factors, including the number of available CPU cores, the complexity of your test scripts, and the specified configuration options.
      2. **Script Distribution:** As tests are discovered, Playwright assigns them to available workers. This distribution aims to balance the workload across workers and ensure efficient resource utilization.
      3. **Parallel Execution:** Each worker executes the assigned test scripts in parallel. This means that multiple tests can be running simultaneously across different workers, significantly reducing the overall execution time.
      4. **Communication and Synchronization:** Workers communicate with the Playwright test runner to report results, handle errors, and synchronize execution. This ensures that the test run proceeds in an organized and controlled manner.
      5. **Termination and Cleanup:** Once all tests have completed, Playwright gracefully terminates the workers and cleans up any associated resources. This helps maintain system stability and prevent resource leaks.
      The use of workers is a crucial aspect of Playwright's performance and scalability. By leveraging parallel execution, Playwright can significantly reduce test execution times, especially for large or complex test suites. This makes Playwright an ideal choice for automating web applications that require rapid feedback and continuous testing.
      In summary, workers in Playwright are separate processes that execute test scripts in parallel, enabling efficient and scalable test automation for web applications.

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

    i dont know why when i try to run npx playwright test .\tests\example.spec.js it shows no tests found always

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

      Hi Abdou
      There are a few reasons why you might be getting the "No tests found" error when you run `npx playwright test .\tests\example.spec.js`.
      * The file `example.spec.js` might not be a valid Playwright test file. Playwright test files must have a `.spec.js` or `.spec.ts` extension, and they must contain a `describe()` block with one or more `it()` blocks.
      * The file `example.spec.js` might not be in the `tests` directory. Playwright will only look for tests in the `tests` directory by default.
      * The file `example.spec.js` might not be executable. Playwright will only run tests that are executable.
      To troubleshoot the "No tests found" error, you can try the following:
      * Check the file extension of `example.spec.js`. Make sure that it is either `.spec.js` or `.spec.ts`.
      * Check the directory of `example.spec.js`. Make sure that it is in the `tests` directory.
      * Check the permissions of `example.spec.js`. Make sure that it is executable.
      If you have checked all of these things and you are still getting the "No tests found" error, then you can try the following:
      * Use the `-w` flag to specify the directory where Playwright should look for tests. For example, you would run the following command to look for tests in the `tests` directory:
      ```
      npx playwright test -w .\tests
      ```
      * Use the `-t` flag to specify a glob pattern for matching test files. For example, you would run the following command to match all test files that have a `.spec.js` or `.spec.ts` extension:
      ```
      npx playwright test -t *.spec.js *.spec.ts
      ```
      I hope this helps

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

      @@RaghavPalHi Raghav! Thank you for your great effort! I got the same issue. Could you please let me know how to do these: "they must contain a `describe()` block with one or more `it()` blocks." and "Check the permissions of `example.spec.js`. Make sure that it is executable."

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

    Hi Ragav, I know python very well, Is playwright have scope with python compared with javascript? Please clarify playwright python is suitable future or not

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

      Yes, you can use it with Python, it has future

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

      @@RaghavPal thanks for your valuable feedback and guidance

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

    It seems like we can only run tests if we are INSIDE the tests folder. If I am outside it won't run even if I specify the path correctly. Do you know why?

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

      Hi, It is generally recommended to run Playwright tests from within the tests folder or a subfolder, because Playwright looks for test files in the current working directory
      However, it is possible to specify the path to the test files when running Playwright, using the *--tests* flag. For example:
      /***
      playwright run --tests path/to/tests
      ***/
      Pls check and let me know if it works

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

      @@RaghavPal so I’m on the main folder and I am running playwright run -tests ./tests/my-test.spec.js and it doesn’t work it says command not found: a playwright

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

      Are you running from your project folder? Try command
      npx playwright test
      Check options here playwright.dev/docs/running-tests

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

    when i write command ( npx playwright test .\tests\first.spec.js)error appear(Error: No tests found) i do not know the problem exactally
    can you help me in that?

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

      Moataz
      The error message "Error: No tests found" means that Playwright cannot find any tests in the file `.\tests\first.spec.js`.
      There are a few possible reasons for this error:
      * The file `.\tests\first.spec.js` does not exist.
      * The file `.\tests\first.spec.js` is not a valid Playwright test file.
      * The Playwright test runner is not configured to look for tests in the file `.\tests\first.spec.js`.
      To troubleshoot the error, you can try the following:
      1. Make sure that the file `.\tests\first.spec.js` exists and is a valid Playwright test file.
      2. Make sure that the Playwright test runner is configured to look for tests in the directory `.\tests`.
      To configure the Playwright test runner to look for tests in the directory `.\tests`, you can use the following command:
      ```
      npx playwright test --test-dir .\tests
      ```
      If you are still getting the error after following these steps, then you can contact Playwright support for help.
      Here are some additional tips for troubleshooting Playwright test errors:
      * Make sure that you are using the latest version of Playwright.
      * Make sure that you are using the correct Playwright test runner.
      * Check the Playwright documentation for more information on troubleshooting test errors.
      I hope this helps

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

    Hi Raghav,
    Do you have tutorials in this series for type script based tests?

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

      Not yet on TypeScript Deepna

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

      ​@@RaghavPal Thank you, but are you planning to do one for TypeScript?

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

      I will do

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

    I am getting error :throw new Error([`Playwright Test did not expect ${title} to be called here. Any suggestions please

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

      Hi Nisha
      The error message you are getting is caused by the fact that you are calling a function that is not expected to be called in the current context. This can happen if you are using a function that is not part of the Playwright API, or if you are using a function in a way that is not expected.
      To resolve this error, you need to identify the function that is causing the error and understand why it is not expected to be called in the current context. Once you have identified the problem, you can fix it by changing the way that you are using the function.
      Here are some suggestions for resolving the error:
      * Make sure that you are using the correct function.
      * Make sure that you are using the function in the correct way.
      * If you are using a function that is not part of the Playwright API, make sure that you are importing it correctly.
      * If you are still having problems, you can report a bug to the Playwright team. They will be able to help you troubleshoot the problem.

  • @arvindgidde-patil120
    @arvindgidde-patil120 ปีที่แล้ว

    While running specific test file I am getting an error= No tests found. Please help me to resolve this error

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

      Arvind
      The error message "No tests found" means that the Playwright test runner could not find any tests in the file that you are trying to run.
      There are a few possible reasons why this might be happening:
      * The file might not contain any tests.
      * The file might not be a valid Playwright test file.
      * The file might be in a directory that is not being searched by the Playwright test runner.
      To troubleshoot this error, you can try the following:
      * Check the file to make sure that it contains at least one test.
      * Make sure that the file is a valid Playwright test file. You can do this by checking the file extension. The file extension for Playwright test files is `.spec.ts` or `.spec.js`.
      * Make sure that the file is in a directory that is being searched by the Playwright test runner. You can do this by setting the `testPath` property in the Playwright configuration file.
      Here is an example of how to set the `testPath` property in the Playwright configuration file:
      ```
      {
      "testPath": "./tests"
      }
      ```
      This will tell the Playwright test runner to search for tests in the `tests` directory.
      I hope this helps

  • @dineshbabuk.a.7127
    @dineshbabuk.a.7127 ปีที่แล้ว

    Hi Raghav , i followed ur steps but for me test and expect js are missing , how to get it

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

      Hi Dinesh,
      If you are using Playwright, you can install and use the jest testing framework along with the expect assertion library to write and run tests
      1. Install jest and expect as dev dependencies:
      npm install --save-dev jest @playwright/test expect
      2. Create a test file in your project's tests directory with the following content:
      const { test, expect } = require('@playwright/test');
      test('example test', async ({ page }) => {
      await page.goto('example.com');
      const pageTitle = await page.title();
      expect(pageTitle).toBe('Example Domain');
      });
      3. Update your package.json file to include a test script that runs jest:
      {
      "scripts": {
      "test": "jest"
      }
      }
      4. Run your tests using the following command:
      npm test

  • @Akshaykumar-yz3uy
    @Akshaykumar-yz3uy 8 หลายเดือนก่อน

    Hi Raghav, Thank you for this awesome couse. I am a begginer and I tried this but when I am running it in terminal it is showing no test found. I tried it through chat GPT and added jest in the package.json but still its not working

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

      Akshay
      It seems you're encountering a common issue where Playwright does not recognize the test files. This can happen for several reasons, such as incorrect configuration or file naming conventions. Here are a few steps you can take to troubleshoot the problem:
      1. Check your configuration file: Ensure that your `playwright.config.ts` or `playwright.config.js` is correctly set up and that the `testDir` property points to the directory where your test files are located¹.
      2. Verify file naming: Playwright by default looks for files with `.spec.ts` or `.test.ts` extensions. Make sure your test files follow this naming pattern.
      3. Update Playwright and Jest: Sometimes, compatibility issues can cause this problem. Update both Playwright and Jest to their latest versions using the following commands:
      ```bash
      npm install @playwright/test@latest
      npm install jest@latest
      ```
      4. Install the necessary dependencies: If you're using Jest with Playwright, you'll need to install `jest-playwright-preset`. You can do this with the following command:
      ```bash
      npm install -D jest jest-playwright-preset playwright
      ```
      5. Configure Jest to use Playwright: In your Jest configuration file, you should set the preset to `jest-playwright-preset` to integrate Playwright with Jest⁶.
      6. Check for syntax errors: Syntax errors in your test files or configuration files can also lead to tests not being found.
      7. Run Playwright tests directly: Try running the tests using the Playwright CLI to see if the issue is specific to Jest integration:
      ```bash
      npx playwright test
      ```
      8. Consult the documentation: Both Playwright and Jest have extensive documentation that can help you configure them correctly⁹.
      If you've tried all these steps and are still facing issues, it might be helpful to look at the error logs for more specific information about what might be going wrong.

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

    Hi guys,i've follow those step ,but why i get Error: No tests found while running in terminal?

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

      Check the location of the file in your command, use forward slashes

  • @kanchansharma3899
    @kanchansharma3899 11 หลายเดือนก่อน +1

    Raghav..here you are teaching Playwright with javasript..Do you any vedio's where you have teach playwright with typescript. Please suggest

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

      Kanchan
      Not specifically for now... but the initial few videos will help you get started irrespective of the programming language.. and then for TypeScript syntax, scripts, you can refer documenation

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

    Greetings! I followed your video "Writing Your First Test", I followed all the steps. After writing the creating the test block to run google mine is always running the Playwright page. From the command line when I run -npx playwright test .\my_first_test.spec.js it only returns to running only the the initial test that ran when you run npx playwright test. Why am I experiencing this does it have to do with version?

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

      Hi Robert
      There are a few reasons why your Playwright tests might only be running the initial test.
      * **You are not using the latest version of Playwright.** Playwright is constantly being updated with new features and bug fixes. If you are using an older version of Playwright, it is possible that your tests are not compatible with the latest version.
      * **You are not using the correct configuration file.** Playwright uses configuration files to control how your tests are run. If you are not using the correct configuration file, it is possible that your tests are not being run correctly.
      * **You are using the wrong command line argument.** The `npx playwright test` command has a number of command line arguments that can be used to control how your tests are run. If you are using the wrong command line argument, it is possible that your tests are not being run correctly.
      To resolve this issue, you can try the following:
      * **Update to the latest version of Playwright.** You can install the latest version of Playwright by running the following command:
      ```
      npm install -g playwright
      ```
      * **Use the correct configuration file.** The default configuration file for Playwright is `playwright.config.js`. If you are using a different configuration file, you need to specify the path to the configuration file when you run the `npx playwright test` command.
      * **Use the correct command line argument.** The `npx playwright test` command has a number of command line arguments that can be used to control how your tests are run. To run all of your tests, you can use the following command:
      ```
      npx playwright test
      ```
      If you are still having problems, you can try searching for help online or contacting the Playwright support team.
      Here are some additional tips for troubleshooting Playwright problems:
      * **Make sure that you are using the latest version of Playwright.** Playwright is constantly being updated with new features and bug fixes.
      * **Check your system settings.** Make sure that your system has the necessary hardware and software requirements for Playwright.
      * **Try running your tests in a different environment.** For example, try running them from a command line or from a different operating system.
      * **Contact the Playwright support team.** If you are still having problems, you can contact the Playwright support team for help
      I hope this helps

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

    i am getting following error : Test timeout of 30000ms exceeded.
    how to overcome this.

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

      run the command
      npx cypress verify
      if you still see time out error, run it once again,
      if it still shows same error, goto your project folder and open node_modules folder
      node_modules\cypress\lib\tasks\verify.js, search for VERIFY_TEST_RUNNER_TIMEOUT_MS and change it from 30000 (default) to 100000.
      pls check stackoverflow.com/questions/63667880/cypress-verification-timed-out-after-30000-milliseconds

  • @sd-kc9qy
    @sd-kc9qy ปีที่แล้ว

    Hello Raghav - I am using playwright and it executes code fine but in Test-Result folder is always empty. Do I have to configure anywhere to store results?

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

      Can check this medium.com/geekculture/how-to-generate-html-report-in-playwright-f9ec9b82427a

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

    currently I have selenium web drive but with chrome version update I everytime have to update the version manually. With Playwright I am using chromium, will i face same issue. Will playwright automatically update chromium version and run test without issue? please confirm

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

      Sheetal
      Here's how Playwright handles Chromium updates, ensuring smooth test execution:
      1. Automatic Updates:
      - Playwright downloads and manages compatible Chromium versions automatically when you install or update it.
      - This eliminates the manual effort of updating drivers like in Selenium.
      2. Compatibility:
      - Each Playwright version is tied to specific Chromium versions, ensuring compatibility and preventing unexpected issues.
      - You can check the supported versions in the Playwright documentation for your specific version.
      3. Updating Playwright:
      - To use a newer Chromium version, simply update Playwright itself:
      ```bash
      npm install @playwright/test@latest
      ```
      - This will download the latest compatible Chromium version.
      4. Managing Browser Binaries:
      - Review and manage browser binaries using the Playwright CLI:
      ```bash
      npx playwright install
      npx playwright list-browsers
      ```
      5. Configuration:
      - Optionally specify a desired Chromium version in your `playwright.config.js` file:
      ```javascript
      // playwright.config.js
      module.exports = {
      browsers: ['chromium:105'], // Use Chromium 105
      };
      ```
      Advantages over Selenium:
      - No manual driver management: Playwright handles updates for you.
      - Stays ahead of browser releases: Playwright often supports newer browser versions before Selenium.
      - Streamlined testing experience: Focus on tests, not browser compatibility hassles.
      Key Points:
      - Automatic updates within Playwright's version control.
      - Compatibility guaranteed between Playwright and Chromium versions.
      - Easy update process through Playwright itself.
      - Flexible configuration for specific browser version control.
      Stay updated with Playwright, and your tests will seamlessly adapt to Chromium updates without manual intervention!

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

    Raghav..here you are teaching Playwright with javasript..Do you have any video's where you have teach playwright with typescript. Please suggest.

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

      Jaswant
      As of now I have not create Playwright with Typescript

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

    Sir, No tests found error is shown whenever I enter path and try running the test = npx playwright test .\tests\firsttest.spec.js

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

      Hi Aditya
      The error message "No tests found" means that the Playwright test runner could not find any tests in the specified directory. There are a few possible reasons for this:
      * The test file is not named correctly. Playwright expects test files to have a name that ends in `.spec.js` or `.spec.ts`.
      * The test file is not in the specified directory. Playwright will only look for tests in the specified directory and its subdirectories.
      * The test file is not using the Playwright API. Playwright tests must be written using the Playwright API.
      To troubleshoot this error, you can try the following:
      * Check the name of the test file to make sure it ends in `.spec.js` or `.spec.ts`.
      * Make sure the test file is in the specified directory or one of its subdirectories.
      * Check the code in the test file to make sure it is using the Playwright API.
      If you have checked all of these things and you are still getting the error message, then you may need to contact Playwright support for help.
      In your case, the error message says that the test file is not found. This suggests that the test file is not in the specified directory or that it is not named correctly. You can try renaming the test file to end in `.spec.js` or `.spec.ts`, or you can move the test file to the specified directory. If that doesn't work, then you can check the code in the test file to make sure it is using the Playwright API.
      I hope this helps

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

    Also can we have video on installing playwright with typescript? Also How can I download the version of node js version 8.5 which is the version you used for the tutorial?

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

      Hi Robert
      Let me help you with that.
      Here are the steps on how to install Playwright with TypeScript:
      1. Install Node.js. You can download the latest version of Node.js from the official website.
      2. Install TypeScript. You can install TypeScript by running the following command:
      ```
      npm install -g typescript
      ```
      3. Install Playwright. You can install Playwright by running the following command:
      ```
      npm install -g playwright
      ```
      4. Create a new TypeScript project. You can create a new TypeScript project by running the following command:
      ```
      mkdir my-project
      cd my-project
      tsc --init
      ```
      5. Create a new file called `index.ts`. In this file, you can write your Playwright tests.
      6. Run your tests. You can run your tests by running the following command:
      ```
      npx playwright test
      ```
      Here are the steps on how to download Node.js version 8.5:
      1. Go to the Node.js download page.
      2. Click on the "Download" button for Node.js version 8.5.
      3. Save the file to your computer.
      4. Run the installer.

  • @sd-kc9qy
    @sd-kc9qy ปีที่แล้ว

    Hello Raghav. I just followed the exact steps in tutorial 4 but was not able to launch a google page. It gives a report but nothing in there. I ran example test and it seems showing passed. What can cause a problem?

    • @sd-kc9qy
      @sd-kc9qy ปีที่แล้ว

      I fixed it. Ignore my message.

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

      ok

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

    Hi Raghav, can I request a video on Playwright with Cucumber and also using different versions of browsers? Thanks for the great content!

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

      I will plan

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

    Dear Raghav, could you help me check this issue. I follow your step but when I execute "My first test" it responds to me in the terminal: "Running 0 tests using 0 workers"

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

      Hi Peter, check in your config file the folder where tests should be located and the naming format for test files
      By default it is .*(test|spec)\.(js|ts|mjs)

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

      @@RaghavPal Thank Raghav I see the issue like you mention. My config file is "my_first_test_spec.js"

  • @AnshulGupta-i9x
    @AnshulGupta-i9x 16 วันที่ผ่านมา

    Sir ! Issue is result is not printing : My new project code :
    const {test, except}=require('@playwright/test')
    const{greet,Areet}=require('./demo/hello')
    console.log(greet());
    hello.js : exports.HelloA1=function greet(name) {
    return `HelloA1, ${name}!`;
    }
    exports.HelloA2=function Areet(nameone) {
    return `HelloA2, ${nameone}!`;
    }
    When i try to run command then : node .\tests
    ewproject.spec.js
    nothing happened

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

      Anshul
      The issue is with how you are importing and using the functions from `hello.js`. You are exporting them as `HelloA1` and `HelloA2`, but in your `newproject.spec.js`, you're calling `greet()` and `Areet()` directly, which are undefined.
      ### Fix Your Code
      1. **Update the Imports in `newproject.spec.js`:**
      ```javascript
      const {test, expect} = require('@playwright/test');
      const {HelloA1, HelloA2} = require('./demo/hello');
      console.log(HelloA1("Playwright")); // Call the correct exported function
      console.log(HelloA2("Tester")); // Call the correct exported function
      ```
      2. **Run the File:**
      Use this command:
      ```bash
      node .\tests
      ewproject.spec.js
      ```
      3. **Expected Output:**
      ```
      HelloA1, Playwright!
      HelloA2, Tester!
      ```
      -

    • @AnshulGupta-i9x
      @AnshulGupta-i9x 14 วันที่ผ่านมา

      @@RaghavPal Thanks sir , After all it works
      Also can test we api from playwright when developer shared a collection

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

      Sure Anshul

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

    Can you upload videos for writing tests with Typescript?

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

      I will check on this

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

    Hi Raghav,
    I stored my test in the tests directory but when I try to run it always complains of not finding the tests. Any suggestion for it please?
    Test directory path: C:\auto\tests
    npx playwright test .\tests\mylogin.spec.js
    Running 0 tests using 0 workers
    =================
    no tests found.

    When I am running the example.spec.js from the same folder it runs fine.

    Running 3 tests using 2 workers
    3 passed (9s)

    Thanks,
    Syed

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

      Hi Syed, check the command, in the command try to give full location of the test file

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

      @@RaghavPal Same issue is coming to my end. I have created a new file name my_first.spec.js under the tests folder and I ab trying to run the below code
      const {test, expect} = require ('@playwright/test');
      test('My first test ' , async ({page})=> {
      await page.goto('www.google.com/')
      await expect(page).toHaveTitle("Google");
      });
      and I am running this command --- npx playwright test .\tests\my_first.spec.js
      This output is coming
      Running 0 tests using 0 workers
      =================
      no tests found.
      =================
      Please help to resolve this issue
      Thank you

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

      In the configuration file, check the option testDir and see what is mentioned here

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

      @@RaghavPal This is mentioned in the config file testDir: './tests',
      But one thing that is my config file extension is ts and my other file extension is js. is it the reason behind this issue?

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

      I'm having this exact same issue, even when I have copied everything word for word in the video it says zero tests.

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

    For anyone facing the below error , save the test before running it :)
    "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  4 หลายเดือนก่อน

      Thanks for adding Sumithra

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

    @RaghavPal thank you very much for these content. Could you pls help me? When I ran npx playwright test ./tests/myFirstTest.spec.js I got 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. But I checked all the names and paths. I also tried the forward slashes: npx playwright test ./tests/myfirstTest.spec.js
    I am using playwright version 1.47.0

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

      The error message suggests that the arguments you're providing are not being recognized as regular expressions matching your test files.
      Let's break it down. When you run npx playwright test ./tests/myFirstTest.spec.js, Playwright is expecting a regular expression that matches your test file. In your case, it's not finding any tests.
      Here are a few things you can try to resolve this issue:
      Check your test file naming and path
      Make sure your test file is named correctly and the path is correct. In your case, you've tried both ./tests/myFirstTest.spec.js and ./tests/myfirstTest.spec.js. Double-check that the file name and path match exactly
      Use a glob pattern
      Instead of specifying the exact file name, you can use a glob pattern to match all test files in a directory. For example, you can try running npx playwright test ./tests/*.spec.js. This will match all files with the .spec.js extension in the ./tests directory
      Check your test file content
      Ensure that your test file contains a valid test definition using the test function from @playwright/test. Here's an example of what a simple test file might look like:
      import { test, expect } from '@playwright/test';
      test('basic test', async ({ page }) => {
      await page.goto('playwright.dev/');
      const name = await page.innerText('.navbar__title');
      expect(name).toBe('Playwright');
      });
      -

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

    Hi sir how can we handle login with otp it would be great help id you can create video for the same

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

      Hi Kusumdevi, I will check and plan for this

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

    Hello Raghav, I followed the exact same steps but it is showing some error when i am running the code to print hello and helloworld

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

      Hi Aarti, will need to see the details of code and error message