{"record":{"id":"143fddef66caa5b8","repo":"angular/components","slug":"cannot-find-page-size-selector-in-paginator-make","errorCode":null,"errorMessage":"Cannot find page size selector in paginator. Make sure that the `pageSizeOptions` have been configured.","messagePattern":"Cannot find page size selector in paginator\\. Make sure that the `pageSizeOptions` have been configured\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/material/paginator/testing/paginator-harness.ts","lineNumber":108,"sourceCode":"        'Could not find last page button inside paginator. ' +\n          'Make sure that `showFirstLastButtons` is enabled.',\n      );\n    }\n\n    return button.click();\n  }\n\n  /**\n   * Sets the page size of the paginator.\n   * @param size Page size that should be select.\n   */\n  async setPageSize(size: number): Promise<void> {\n    const select = await this._select();\n\n    // The select is only available if the `pageSizeOptions` are\n    // set to an array with more than one item.\n    if (!select) {\n      throw Error(\n        'Cannot find page size selector in paginator. ' +\n          'Make sure that the `pageSizeOptions` have been configured.',\n      );\n    }\n\n    return select.clickOptions({text: `${size}`});\n  }\n\n  /** Gets the page size of the paginator. */\n  async getPageSize(): Promise<number> {\n    const select = await this._select();\n    const value = select ? select.getValueText() : (await this._pageSizeFallback()).text();\n    return coerceNumberProperty(await value);\n  }\n\n  /** Gets the text of the range label of the paginator. */\n  async getRangeLabel(): Promise<string> {\n    return (await this._rangeLabel()).text();","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/paginator/testing/paginator-harness.ts#L90-L126","documentation":"MatPaginatorHarness `setPageSize()` throws because the page-size `<mat-select>` is only rendered when `pageSizeOptions` contains more than one option. Without a selector there is nothing to click.","triggerScenarios":"`await paginatorHarness.setPageSize(20)` when the paginator has no `pageSizeOptions` input, a single-element array, or `pageSize: fixed` style usage.","commonSituations":"Paginator configured with a fixed page size for the test; `pageSizeOptions` forgotten in the test fixture; array defined with only one option.","solutions":["Provide `[pageSizeOptions]=\"[5, 10, 20]\"` (2+ options) on the paginator","Include 20 (or the target size) in `pageSizeOptions` so the option exists in the select","Set `pageSize` directly via component input if changing options is not intended"],"exampleFix":"// before\n<mat-paginator [pageSizeOptions]=\"[10]\"></mat-paginator>\n// after\n<mat-paginator [pageSizeOptions]=\"[10, 20]\"></mat-paginator>","handlingStrategy":"validation","validationCode":"const select = await paginatorHarness.getPageSizeSelect?.();\nif (!select) {\n  throw new Error('pageSizeOptions must have 2+ entries to use setPageSize');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await paginatorHarness.setPageSize(20);\n} catch (e) {\n  if (String(e?.message).includes('page size selector')) {\n    fail('Add [pageSizeOptions]=\"[5,10,20]\" to the paginator');\n  }\n  throw e;\n}","preventionTips":["Always configure pageSizeOptions with multiple sizes in test fixtures","Include the target size in pageSizeOptions","Set pageSize directly when selector is not needed"],"tags":["angular","material","paginator","testing","harness"],"backgroundTag":"missing-config-input","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}