Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
feat(fetch): accept numeric and bool params (#9345)
Yury Semikhatsky6c18f1a6f0ed
diff --git a/docs/src/api/params.md b/docs/src/api/params.mdindex f47f5e745b..25bd9e085a 100644--- a/docs/src/api/params.md+++ b/docs/src/api/params.md@@ -303,7 +303,7 @@ Emulates consistent window screen size available inside web page via `window.scrTarget URL.## fetch-option-params-- `params` <[Object]<[string], [string]>>+- `params` <[Object]<[string], [string]|[float]|[boolean]>>Query parameters to be send with the URL.diff --git a/tests/browsercontext-fetch.spec.ts b/tests/browsercontext-fetch.spec.tsindex 7971a0499b..31c5f955f8 100644--- a/tests/browsercontext-fetch.spec.ts+++ b/tests/browsercontext-fetch.spec.ts@@ -903,3 +903,29 @@ it('context request should export same storage state as context', async ({ conteconst pageState = await page.request.storageState();expect(pageState).toEqual(contextState);});++it('should accept bool and numeric params', async ({ context, page, server }) => {+ let request;+ const url = new URL(server.EMPTY_PAGE);+ url.searchParams.set('str', 's');+ url.searchParams.set('num', '10');+ url.searchParams.set('bool', 'true');+ url.searchParams.set('bool2', 'false');+ server.setRoute(url.pathname + url.search, (req, res) => {+ request = req;+ server.serveFile(req, res);+ });+ await page.request.get(server.EMPTY_PAGE, {+ params: {+ 'str': 's',+ 'num': 10,+ 'bool': true,+ 'bool2': false,+ }+ });+ const params = new URLSearchParams(request.url.substr(request.url.indexOf('?')));+ expect(params.get('str')).toEqual('s');+ expect(params.get('num')).toEqual('10');+ expect(params.get('bool')).toEqual('true');+ expect(params.get('bool2')).toEqual('false');+});diff --git a/types/types.d.ts b/types/types.d.tsindex 2c632b058e..768e31656b 100644--- a/types/types.d.ts+++ b/types/types.d.ts@@ -11747,7 +11747,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -11835,7 +11835,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -11869,7 +11869,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -11903,7 +11903,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -11974,7 +11974,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -12045,7 +12045,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.@@ -12116,7 +12116,7 @@ export interface ApiRequestContext {/*** Query parameters to be send with the URL.*/- params?: { [key: string]: string; };+ params?: { [key: string]: string|number|boolean; };/*** Request timeout in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout.