microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
67.01k stars 3.68k forks source link

[Feature]: I pass the json and it automatically generates request & response #32479

Open kashiMathura opened 2 months ago

kashiMathura commented 2 months ago

🚀 Feature Request

If I open postman and import the json file (which contains API def) then I automatically see the requests generated. Could you please provide such feature in playwright? This feature is also supported by readyAPI.

Example

No response

Motivation

More people will use it, It will be helpful for the users

MichaelBehnam commented 2 months ago

https://github.com/microsoft/playwright/issues/30082

pavelfeldman commented 2 months ago

Could you be more specific and provide examples of expected behavior with code snippets.

sudeepshukla930 commented 2 months ago

This feature would be incredibly valuable! In a recent proof of concept for my company, I exported Postman collections( request , validation ) and used them to generate test cases, which greatly streamlined our workflow. A slightly similar concept could be implemented in Playwright to enhance testing capabilities. Although I m a beginner, I am eager to contribute if this feature is developed and would be excited to collaborate on it.

dgozman commented 2 months ago

@sudeepshukla930 That's great to hear! However, could you please help us understand the substance of the proposed feature by sharing a concrete example of inputs, outputs, new APIs, etc?

sudeepshukla930 commented 2 months ago

Thank you for your comment.After reviewing @kashiMathura feature request. It seems that the concept, I have been working on might be quite similar to what Kashi is looking for. To clarify the substance of the work what I had done , let me provide a concrete example of the inputs, outputs :

Example: Inputs:

Postman Collection Export: We use Postman to create a collection of API requests, including payloads, headers, and scripts.

Exported JSON: This collection is exported in JSON format, which contains details about API requests, endpoints, methods, and validation scripts.

Processing:

Playwright Test Script: As part of a Proof of Concept (POC) , I developed a basic implementation using Playwright. This script reads the exported JSON, parses it to extract API request details and validation scripts.

Outputs:

Generated Test Scripts: The Playwright script generates test scripts for each API request based on the parsed JSON. These scripts can be executed directly to perform the requests and validations as specified in the Postman collection.

Additional Note:

This implementation is a basic example created as part of POC . We can utilise this and create something that can be very impactful for the playwright community

dgozman commented 2 months ago

@sudeepshukla930 Thank you for the details! This sounds like a great project that does not need to be a part of Playwright itself. If you or someone else from the community that has great knowledge of Postman and its json format publishes an npm package, it could become the endorsed solution for Playwright-Postman integration. We are looking forward to it as well!

sudeepshukla930 commented 2 months ago

Hi @dgozman , thanks for this , I m also looking a way to contribute into this .I had tried a basic example not a fully fledged one , but we can try together or anyone in the community who can join....It will definitely make playwright more used widely and can add as a great feature in npm registery