Playwright Beginner Tutorial 12 | Annotation & Tags

Поделиться
HTML-код
  • Опубликовано: 14 дек 2024

Комментарии • 60

  • @Royal_Gondane
    @Royal_Gondane 2 года назад +2

    One thing to call out, although I've seen many PlayWright playlists, but here I found small small basic things which will actually help me in my project.

  • @ajrobson
    @ajrobson 2 года назад +1

    Thanks for these videos, I've been using Playwright for a few months but haven't done a tutorial I just googled what I needed. I've learnt a lot of new things over these 12 videos that I will be putting into practice now!

  • @TheMMakif
    @TheMMakif Год назад +1

    I do appreciate your efforts. Thank you for awesome series

  • @thelet3878
    @thelet3878 2 года назад +1

    amazing ! will you continue this tutorial ? also, can you teach us about the right structure for a playwright project ?

  • @sankararaodarapureddi1407
    @sankararaodarapureddi1407 2 года назад

    Very Greatfull and Excellent Videos, Many Thanks Raghav

  • @rianwardana1478
    @rianwardana1478 2 года назад

    Thankyou so much raghav, keep it up !😁

  • @MrRajkarna
    @MrRajkarna Год назад +1

    Please provide POM framework for playwright

  • @sandeepdubey7664
    @sandeepdubey7664 2 года назад

    Great demo's for beginners..Thanks

  • @ilhamiaktan7560
    @ilhamiaktan7560 Год назад +1

    My project is a .Net C# project. I want to run my @smoke tag in the spec flow playwright project. Which command do I need to run in the terminal?

    • @RaghavPal
      @RaghavPal  Год назад +1

      Ilhami
      To run the @smoke tag in the SpecFlow Playwright project in a .NET C# project, you can use the following command in the terminal:
      ```
      npx playwright test --specs *.feature --tags @smoke
      ```
      This will run all the features in the current directory that have the `@smoke` tag.
      Here are some additional things to keep in mind:
      * The `npx` command is used to run Node.js packages.
      * The `playwright` command is used to run Playwright tests.
      * The `--specs` flag is used to specify the features to run.
      * The `--tags` flag is used to specify the tags of the features to run.
      I hope this helps

    • @ilhamiaktan7560
      @ilhamiaktan7560 Год назад

      @@RaghavPal Thank you I will try.

    • @ilhamiaktan7560
      @ilhamiaktan7560 Год назад

      But my code is .Net C# not JS

    • @RaghavPal
      @RaghavPal  Год назад

      can try this
      npx playwright test --tags="@smoke"

    • @ilhamiaktan7560
      @ilhamiaktan7560 Год назад

      npx : The term 'npx' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
      verify that the path is correct and try again.
      has to be the start dotnet test I tried this but didn't work as well
      dotnet test --tags="@smoke"@@RaghavPal

  • @gauravgulati5490
    @gauravgulati5490 5 месяцев назад +1

    Hi Sir, How about if you give a tag say @smoke and @sanity to some test and mix some of them there and say another @admin tag, is there a way to run together the ones tagged @smoke and @admin ?

    • @RaghavPal
      @RaghavPal  5 месяцев назад +1

      Gaurav
      In Playwright, you can achieve this by using test runners and test filters. Here's how you can run tests with specific tags:
      1. Test Tags:
      - First, make sure you've tagged your tests appropriately. For example, you've tagged some tests with `@smoke`, some with `@sanity`, and others with `@admin`
      2. Test Runners:
      - Playwright supports different test runners like Jest, Mocha, and Jasmine.
      - You can use the test runner's built-in functionality to filter tests based on tags.
      - For example, if you're using Jest, you can use the `--testNamePattern` flag to filter tests by tag:
      ```bash
      jest --testNamePattern=@smoke|@admin
      ```
      - This command will run tests with either the `@smoke` or `@admin` tag
      3. Custom Logic:
      - If you need more complex filtering, you can write custom logic in your test runner configuration.
      - For instance, create a custom script that reads the tags and runs specific tests based on your criteria.
      Remember to adjust the commands and configuration according to your specific setup
      -

    • @gauravgulati5490
      @gauravgulati5490 5 месяцев назад

      @@RaghavPal Sweet! Thank you so much for the reply sir! Really appreciate it

  • @Kaiser0109
    @Kaiser0109 2 года назад

    I love u Bro youre the best, so much effort and work for free great!

  • @SathyanarayananVittal
    @SathyanarayananVittal 10 месяцев назад

    Lovely series. Thanks

    • @RaghavPal
      @RaghavPal  10 месяцев назад

      Glad you enjoyed it Sathya

  • @sarvesht2201
    @sarvesht2201 2 года назад

    Hi Raghav,
    Can you please create a playlist for Ansible and AWS automation using Ansible

  • @akshatmehta212
    @akshatmehta212 2 года назад

    How can we will right javascript logic--comparison product price with playwright?

    • @RaghavPal
      @RaghavPal  2 года назад

      Hi Akshat, will need to check on this

  • @ahmethalal6926
    @ahmethalal6926 Год назад +1

    Hi I encouter problems by Using the "=>" symbol for function call in Javascript
    Is there any reason why some times the code includes "=>" and it is correct and sometimes it translates to "=>" where ">" is a different character, which, it breaks the code?
    iT SAYS "INVALID CHARACTER"

    • @RaghavPal
      @RaghavPal  Год назад

      Hi Ahmet, in case you have copied it from the description, you will have to change the < and > signs, as youtube description does not allow the normal < > symbols and I have to change them

  • @cnjbravo
    @cnjbravo 8 месяцев назад

    Hi Raghav.
    One question, imagine that I have several test folders like this:
    Playwright_Automation (this is the main folder created when installing playwright)
    - test1
    --- test1.spec.js
    - test2
    --- test2.spec.js
    - test3
    --- test3.spec.js
    Do I have to install playwright (npx playwright install) for each test folder? I'm asking this because in my team they have something like I mention and it was failing a test (let's say "test3) and the only way to make it work was runing this "npx playwright install" for that particular folder.
    Thanks :)

    • @RaghavPal
      @RaghavPal  8 месяцев назад

      Jorge
      When working with multiple test folders in a Playwright project, you don't need to install Playwright separately for each folder. The installation process is typically done at the project level, and it applies to all test folders within that project.
      Here's how it works:
      1. Project-Level Installation:
      - When you initially set up your Playwright project (e.g., in the `Playwright_Automation` folder), you run the installation command:
      ```
      npx playwright install
      ```
      - This command installs Playwright globally for your entire project.
      - It downloads the necessary browser binaries and sets up the project configuration files.
      2. Test Folders:
      - Each test folder (e.g., `test1`, `test2`, `test3`) can contain its own test files (e.g., `test1.spec.js`, `test2.spec.js`, `test3.spec.js`).
      - These test files can reference Playwright and use its APIs without any additional installation steps.
      - The global installation ensures that all test folders have access to the same Playwright installation.
      3. Running Tests:
      - When you run your tests (e.g., using `npx playwright test`), Playwright will use the installed version from the project level.
      - It will automatically discover and execute tests from all relevant test folders.
      4. Configuration:
      - If you need to customize Playwright settings (e.g., specify which browsers to use, modify configuration), you can do so in the `playwright.config.ts` file.
      - This configuration file is at the project level and affects all test folders.
      5. Updating Playwright:
      - To update Playwright to the latest version, run:
      ```
      npm install -D @playwright/test@latest
      ```
      - This command updates Playwright globally for the entire project.
      In summary, you only need to install Playwright once at the project level, and it will be available to all test folders. If your team encountered issues with a specific test folder (e.g., "test3"), it's essential to ensure that the project-level installation is correctly set up

  • @NikitaFondekar-rz3mb
    @NikitaFondekar-rz3mb 8 месяцев назад

    when I used - - grep invert 'smoke' then rest of the tests are not getting executed getting error as "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."
    Please help

    • @RaghavPal
      @RaghavPal  8 месяцев назад

      Nikita
      The error message indicates Playwright isn't finding any tests because the `grep invert 'smoke'` argument might not be interpreted correctly. Here's how to fix it:
      Solution:
      Playwright uses single dashes (`-`) for options and double dashes (`--`) for flags with values. There's a typo in your command.
      The correct way to use `grep` with `invert` to exclude smoke tests is:
      ```bash
      playwright test --grep invert:smoke # This is the corrected command
      ```
      Explanation:
      - `playwright test`: This starts the Playwright test runner.
      - `--grep invert:smoke`: This is the corrected flag with the value.
      - `--grep`: This is the flag for filtering tests based on patterns.
      - `invert:`: This keyword specifies inversion, meaning it will run tests that don't match the following pattern.
      - `smoke`: This is the pattern to exclude. Playwright will run any test file or test name that doesn't contain the word "smoke".
      Additional Notes:
      - Make sure there are no extra spaces around the colons (`:`) in the flag.
      - If your test file or test names have special characters like `$` or `*`, you might need to escape them with backslashes (`\`) to avoid misinterpretations.
      By using the corrected command, Playwright should now run all tests except those containing "smoke" in their names or file paths.

  • @Royal_Gondane
    @Royal_Gondane 2 года назад +1

    Hi Raghav, could you please add a framework in upcoming videos??? In my company, we're planning to migrate to PlayWright from Protractor... Also we have plenty of API automation modules, can you please add the API part in that framework?

  • @dileephpentapati8535
    @dileephpentapati8535 9 месяцев назад

    Thank you Raghav.
    These sessions are very useful.
    I have one question:
    Shall we generate the same reports in Playwright with java without Nunit, JUnit etc....?

    • @RaghavPal
      @RaghavPal  9 месяцев назад

      Dileeph
      Playwright itself does not provide built-in reporting capabilities like NUnit or JUnit. However, you can still generate custom reports for your Playwright tests using other tools and libraries. Here are some options:
      1. Custom Reporters with Playwright Test:
      - Playwright Test allows you to specify custom reporters programmatically in your configuration file.
      - You can create your own reporter or use existing ones to generate reports in various formats (e.g., JSON, XML, HTML).
      - Examples of custom reporters include Allure, Mochawesome, and custom JUnit-style reporters.
      2. Allure Reporter for Playwright:
      - Allure is a popular reporting framework that provides rich and interactive reports.
      - You can integrate Allure with Playwright by using the `allure-playwright` package.
      - Follow the instructions in the [Allure Report Docs for Playwright](allurereport.org/docs/playwright/) to set up Allure reporting for your Playwright tests⁴.
      3. JUnit-Style XML Reports:
      - Although Playwright itself doesn't generate JUnit-style reports, you can use other tools to convert Playwright test results into JUnit XML format.
      - For example, you can use the `junit-viewer` npm package to convert Playwright test results to JUnit-style HTML reports⁵.
      4. HTML Reports with Allure and Playwright:
      - If you prefer HTML reports, consider using Allure with Playwright.
      - Allure generates detailed HTML reports with step-by-step information, screenshots, and attachments.
      - Follow the steps in the [Medium tutorial on generating HTML reports in Playwright](medium.com/geekculture/how-to-generate-html-report-in-playwright-f9ec9b82427a) to set up Allure reporting³.
      5. Custom Solutions:
      - You can create your own custom reporting solution by capturing relevant data during test execution (e.g., test names, status, screenshots) and generating reports in your preferred format (HTML, XML, etc.).
      - Use Playwright's event listeners (`test.beforeEach`, `test.afterEach`, etc.) to collect data during test runs.

  • @harishkce1989
    @harishkce1989 Год назад

    Hello Raghave
    how/why does the browser close automatically after the steps inside the test() method is executed ?
    is this the nature of the test() method ?
    (inside one example.js)i was trying to use beforeall() to launch the browser - > have multiple test method() -> finally close the browser using afterall()
    is this even possible ?

    • @RaghavPal
      @RaghavPal  Год назад

      Hi Harish
      Yes, the nature of the test() method in Playwright is to automatically close the browser after the test steps have been executed. This is done to ensure that each test runs in an isolated environment, and to prevent any interference between tests.
      Regarding your question about using beforeAll(), multiple test() methods, and afterAll(), it is certainly possible to launch the browser before the tests, run multiple tests, and then close the browser after all the tests have completed. Here is an example:
      const { chromium } = require('playwright');
      let browser;
      let context;
      let page;
      beforeAll(async () => {
      browser = await chromium.launch();
      context = await browser.newContext();
      page = await context.newPage();
      });
      afterAll(async () => {
      await browser.close();
      });
      describe('My Test Suite', () => {
      test('Test 1', async () => {
      await page.goto('www.example.com');
      // add your test steps here
      });
      test('Test 2', async () => {
      await page.goto('www.example.com');
      // add your test steps here
      });
      // add more test cases here
      });
      In this example, we are launching the browser and creating a new context and page in the beforeAll() method. We then define multiple test() methods, each of which will use the same browser context and page. Finally, we close the browser in the afterAll() method.
      Note that it's important to keep the tests independent of each other and avoid any shared state between tests. Otherwise, the behavior of the tests may become unpredictable.

  • @letramytran7524
    @letramytran7524 Год назад

    Hi Raghav, thank you so much for your tutorial, I learnt a lot from your videos, much appreciate your work

    • @RaghavPal
      @RaghavPal  Год назад

      The reason why you are getting the "No tests found" error when you run the command `npx playwright test .\tests\login.spec.js` is because the Playwright test runner is looking for test files in the current directory. When you specify the path to the test file, the Playwright test runner is not able to find the file because it is not in the current directory.
      To fix this, you need to make sure that the test file is in the current directory. You can do this by moving the test file to the current directory or by using the `cd` command to change to the directory where the test file is located.
      For example, if the test file is located in the `tests` directory, you can run the following command to change to the `tests` directory:
      ```
      cd tests
      ```
      Once you are in the `tests` directory, you can run the command `npx playwright test login.spec.js` and the Playwright test runner will be able to find the test file.
      Here are some additional things to keep in mind when running Playwright tests:
      * The Playwright test runner uses the file extension to determine the type of file. For example, a file with the extension `.spec.js` is considered to be a JavaScript test file.
      * The Playwright test runner will only run files that match the specified test match criteria. The default test match criteria is `. *(test|spec)\. (js|ts|mjs)`. This means that the Playwright test runner will only run files that have the `test` or `spec` suffix and that are written in JavaScript, TypeScript, or MJS.
      I hope this helps

  • @sameerasenarath-yn6if
    @sameerasenarath-yn6if Год назад

    Hi appreciate your effort, it's beneficial.
    i would like to know how to pass command line (npx) parameter to the palyaright.config.js file

    • @RaghavPal
      @RaghavPal  Год назад +1

      Hi Sameera,
      You can pass command-line arguments to your Playwright configuration file by using the process.argv array, which contains the command-line arguments used to launch the current process.
      In your playwright.config.js file, you can access the command-line arguments by reading the process.argv array. For example, if you want to pass a --browser argument to your configuration file, you can do the following:
      In your terminal or command prompt, run the npx command with the --browser argument, like this:
      npx playwright test --browser=chromium
      In your playwright.config.js file, you can access the --browser argument using the following code:
      const browserType = process.argv.find(arg => arg.startsWith('--browser='))
      const browserName = browserType ? browserType.split('=')[1] : 'chromium';
      module.exports = {
      browsers: [browserName],
      // other configuration options
      };
      In the code above, we use the process.argv array to find the --browser argument and extract the browser name from it. If the --browser argument is not provided, we default to chromium.
      Note that you can pass any command-line argument you want to your configuration file using this approach. Simply modify the code above to find and use the argument you need.

  • @sarayum7934
    @sarayum7934 11 месяцев назад

    how to run 3 tests in sequence?

    • @RaghavPal
      @RaghavPal  11 месяцев назад

      Sarayu
      Here are several ways to run 3 tests in sequence using Playwright:
      1. Within a Single File:
      - Using `test.describe.configure({ mode: 'serial' })`:
      ```javascript
      import { test, expect } from '@playwright/test';
      test.describe.configure({ mode: 'serial' }); // Run tests serially
      test('Test 1', async ({ page }) => {
      // Test actions here
      });
      test('Test 2', async ({ page }) => {
      // Test actions here
      });
      test('Test 3', async ({ page }) => {
      // Test actions here
      });
      ```
      - Using a Shared Page Instance:
      ```javascript
      let page: Page;
      test.beforeAll(async ({ browser }) => {
      page = await browser.newPage();
      });
      test('Test 1', async () => {
      // Test actions using page
      });
      test('Test 2', async () => {
      // Test actions using page
      });
      test('Test 3', async () => {
      // Test actions using page
      });
      ```
      2. Across Multiple Files:
      - Using a Test List File:
      1. Create a `test-list.txt` file with the test file names in the desired order:
      ```
      test1.spec.js
      test2.spec.js
      test3.spec.js
      ```
      2. Run the tests using the `--test-list` option:
      ```bash
      npx playwright test --test-list=test-list.txt
      ```
      3. Disabling Parallel Execution:
      - Using the `--workers=1` option:
      ```bash
      npx playwright test --workers=1
      ```
      - Setting `testProject.fullyParallel` or `testConfig.fullyParallel` to `false`:
      ```javascript
      // In playwright.config.js
      module.exports = {
      testProject: {
      fullyParallel: false,
      },
      };
      ```
      Choosing the Best Method:
      - Within a Single File: Simple for closely related tests.
      - Across Multiple Files: Better for organizing tests logically.
      - Disabling Parallel Execution: Controls execution across all files.
      Consider factors like test organization, dependencies, and execution speed when choosing the most suitable approach for your testing needs

  • @vanshikagupta5025
    @vanshikagupta5025 2 года назад

    Hi Raghav, your videos help me a lot in my job. Currently I'm having a question in Jmeter as I'm new to it.
    My url looks like ip:port/OTAService_MCI/webresources/OTAWebService/SONEListener?imei=$IMEI&imsi=$IMSI&msisdn=$MSISDN and I need to pass multiple values in IMEI, IMSI and MSISDN.
    What needs to be done in this case? Can you please help?

    • @RaghavPal
      @RaghavPal  2 года назад

      Hi Vanshika, in the video I have explained the parts of HTTP request, if you need more help. pls check this
      www.blazemeter.com/blog/jmeter-http-request
      octoperf.com/blog/2021/11/25/jmeter-http-requests/#request-values

  • @arpankapoor5638
    @arpankapoor5638 2 года назад

    Please continue with further advance topics

  • @supriyamohanty2125
    @supriyamohanty2125 Год назад

    Hi Raghav, plz do a video on API Request

  • @14-Peaks
    @14-Peaks Месяц назад