I would like to know if there is any way to use newman with playwright. My idea is to be able to use the Newman library to call some collection that I have in Postman and from there capture some values of its response. I know that playwright has its own module to make API calls, but the company where I am currently wants to use the requests that already exist in postman.
Could anyone help me with this integration, how could it be done, any ideas? I would greatly appreciate your help.
This thread is trying to answer question "Is there a way to use Newman with Playwright to call a collection from Postman and capture some values from its response?"
The flow that I want to carry out is the following:
Start the automated test execution with Playwright
@elbudaoes3 I think that should be possible with playwright + newman without much coercing.
Here's how I would imagine that going. This is a little contrived and you will have to, of course, adapt it to your use case:
import newman from "newman"
import { test, expect } from "@playwright/test"
test("some test", async ({ page }) => {
const loginData = await new Promise((resolve, reject) => {
newman.run(runOpts).on("done", (error, results) => {
if (error) reject(error)
else resolve(results)
})
})
await expect(loginData).toHaveProperty("email")
await page.goto("/sign-in")
await page.locator("#email").fill(loginData.email)
await page.locator("#password").fill(loginData.password)
// the rest of your tests and other newman runs, etc.
})
It's a little funky with the Promise
syntax, but that's just so that we can await
the newman results at the outer test scope and not have to write the rest of the test nested inside a callback function (or other funkier solutions).
DISCLAIMER: I am not an expert with the newman library, so this example is untested and derived from their docs, but the principle is sound.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].