|
| 1 | +--- |
| 2 | +title: 'isHidden(selector[, options])' |
| 3 | +excerpt: 'Browser module: frame.isHidden(selector[, options]) method' |
| 4 | +--- |
| 5 | + |
| 6 | +# isHidden(selector[, options]) |
| 7 | + |
| 8 | +{{% admonition type="warning" %}} |
| 9 | + |
| 10 | +Use locator-based [`locator.isHidden([options])`](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-experimental/browser/locator/ishidden/) instead. |
| 11 | + |
| 12 | +{{% /admonition %}} |
| 13 | + |
| 14 | +Checks if the element is `hidden`. |
| 15 | + |
| 16 | +<TableWithNestedRows> |
| 17 | + |
| 18 | +| Parameter | Type | Default | Description | |
| 19 | +| -------------- | ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 20 | +| selector | string | `''` | A selector to search for an element. If there are multiple elements satisfying the selector, the first will be used. | |
| 21 | +| options | object | `null` | | |
| 22 | +| options.strict | boolean | `false` | When `true`, the call requires selector to resolve to a single element. If given selector resolves to more than one element, the call throws an exception. | |
| 23 | + |
| 24 | +</TableWithNestedRows> |
| 25 | + |
| 26 | +### Returns |
| 27 | + |
| 28 | +| Type | Description | |
| 29 | +| ---- | ------------------------------------------------ | |
| 30 | +| bool | `true` if the element is `hidden`, else `false`. | |
| 31 | + |
| 32 | +### Example |
| 33 | + |
| 34 | +{{< code >}} |
| 35 | + |
| 36 | +```javascript |
| 37 | +import { browser } from 'k6/experimental/browser'; |
| 38 | + |
| 39 | +export const options = { |
| 40 | + scenarios: { |
| 41 | + browser: { |
| 42 | + executor: 'shared-iterations', |
| 43 | + options: { |
| 44 | + browser: { |
| 45 | + type: 'chromium', |
| 46 | + }, |
| 47 | + }, |
| 48 | + }, |
| 49 | + }, |
| 50 | +}; |
| 51 | + |
| 52 | +export default async function () { |
| 53 | + const page = browser.newPage(); |
| 54 | + |
| 55 | + await page.goto('https://test.k6.io/browser.php'); |
| 56 | + if (page.isHidden('#input-text-hidden')) { |
| 57 | + console.log('element is hidden'); |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +{{< /code >}} |
0 commit comments