Open joshuajaco opened 1 month ago
As a workaround I currently use:
await expect(() => {
const url = new URL(page.url());
expect(url.searchParams.get("foo")).toEqual("bar");
}).toPass();
You can also use:
await page.goto('https://github.com/search?q=playwright&type=repositories');
let params = {};
new URL(page.url()).searchParams.forEach(function (val, key) {
params[key] = val;
});
expect(params).toMatchObject({q: 'playwright', type: 'repositories'});
In this way, you can search for multiple params. I'm also working in the code to make a PR but I'm not sure where to put this piece of code. I was digging mainly in matchers.ts (I only declared the new method here), as well as expect.ts and injectedScript.ts but I couldn't figure out how to implement this feature at all, any help would be appreciated 😄
🚀 Feature Request
There should be an API to test search params of the page, something like:
Example
No response
Motivation
toHaveURL
is not sufficient for testing search params for multiple reasons: