@types/k6 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- k6/README.md +2 -2
- k6/browser/index.d.ts +1529 -242
- k6/package.json +7 -2
k6/browser/index.d.ts
CHANGED
|
@@ -414,6 +414,139 @@ export interface ElementStateFilter {
|
|
|
414
414
|
state?: ElementState;
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
+
/**
|
|
418
|
+
* The `devices` named export defines emulation settings for many end-user
|
|
419
|
+
* devices that can be used to simulate browser behavior on a mobile device.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
* ```js
|
|
423
|
+
* import { browser, devices } from 'k6/browser';
|
|
424
|
+
* ... // redacted
|
|
425
|
+
* const iphoneX = devices['iPhone X'];
|
|
426
|
+
* const context = await browser.newContext(iphoneX);
|
|
427
|
+
* ... // redacted
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
export const devices: Record<
|
|
431
|
+
| "Blackberry PlayBook"
|
|
432
|
+
| "Blackberry PlayBook landscape"
|
|
433
|
+
| "BlackBerry Z30"
|
|
434
|
+
| "BlackBerry Z30 landscape"
|
|
435
|
+
| "Galaxy Note 3"
|
|
436
|
+
| "Galaxy Note 3 landscape"
|
|
437
|
+
| "Galaxy Note II"
|
|
438
|
+
| "Galaxy Note II landscape"
|
|
439
|
+
| "Galaxy S III"
|
|
440
|
+
| "Galaxy S III landscape"
|
|
441
|
+
| "Galaxy S5"
|
|
442
|
+
| "Galaxy S5 landscape"
|
|
443
|
+
| "iPad"
|
|
444
|
+
| "iPad landscape"
|
|
445
|
+
| "iPad Mini"
|
|
446
|
+
| "iPad Mini landscape"
|
|
447
|
+
| "iPad Pro"
|
|
448
|
+
| "iPad Pro landscape"
|
|
449
|
+
| "iPhone 4"
|
|
450
|
+
| "iPhone 4 landscape"
|
|
451
|
+
| "iPhone 5"
|
|
452
|
+
| "iPhone 5 landscape"
|
|
453
|
+
| "iPhone 6"
|
|
454
|
+
| "iPhone 6 landscape"
|
|
455
|
+
| "iPhone 6 Plus"
|
|
456
|
+
| "iPhone 6 Plus landscape"
|
|
457
|
+
| "iPhone 7"
|
|
458
|
+
| "iPhone 7 landscape"
|
|
459
|
+
| "iPhone 7 Plus"
|
|
460
|
+
| "iPhone 7 Plus landscape"
|
|
461
|
+
| "iPhone 8"
|
|
462
|
+
| "iPhone 8 landscape"
|
|
463
|
+
| "iPhone 8 Plus"
|
|
464
|
+
| "iPhone 8 Plus landscape"
|
|
465
|
+
| "iPhone SE"
|
|
466
|
+
| "iPhone SE landscape"
|
|
467
|
+
| "iPhone X"
|
|
468
|
+
| "iPhone X landscape"
|
|
469
|
+
| "iPhone XR"
|
|
470
|
+
| "iPhone XR landscape"
|
|
471
|
+
| "JioPhone 2"
|
|
472
|
+
| "JioPhone 2 landscape"
|
|
473
|
+
| "Kindle Fire HDX"
|
|
474
|
+
| "Kindle Fire HDX landscape"
|
|
475
|
+
| "LG Optimus L70"
|
|
476
|
+
| "LG Optimus L70 landscape"
|
|
477
|
+
| "Microsoft Lumia 550"
|
|
478
|
+
| "Microsoft Lumia 950"
|
|
479
|
+
| "Microsoft Lumia 950 landscape"
|
|
480
|
+
| "Nexus 10"
|
|
481
|
+
| "Nexus 10 landscape"
|
|
482
|
+
| "Nexus 4"
|
|
483
|
+
| "Nexus 4 landscape"
|
|
484
|
+
| "Nexus 5"
|
|
485
|
+
| "Nexus 5 landscape"
|
|
486
|
+
| "Nexus 5X"
|
|
487
|
+
| "Nexus 5X landscape"
|
|
488
|
+
| "Nexus 6"
|
|
489
|
+
| "Nexus 6 landscape"
|
|
490
|
+
| "Nexus 6P"
|
|
491
|
+
| "Nexus 6P landscape"
|
|
492
|
+
| "Nexus 7"
|
|
493
|
+
| "Nexus 7 landscape"
|
|
494
|
+
| "Nokia Lumia 520"
|
|
495
|
+
| "Nokia Lumia 520 landscape"
|
|
496
|
+
| "Nokia N9"
|
|
497
|
+
| "Nokia N9 landscape"
|
|
498
|
+
| "Pixel 2"
|
|
499
|
+
| "Pixel 2 landscape"
|
|
500
|
+
| "Pixel 2 XL"
|
|
501
|
+
| "Pixel 2 XL landscape",
|
|
502
|
+
Device
|
|
503
|
+
>;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Device represents an end-user device (computer, tablet, phone etc.).
|
|
507
|
+
*/
|
|
508
|
+
export interface Device {
|
|
509
|
+
/**
|
|
510
|
+
* Name of the device.
|
|
511
|
+
*/
|
|
512
|
+
name: string;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* User agent of the device.
|
|
516
|
+
*/
|
|
517
|
+
userAgent: string;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Viewport size of the device.
|
|
521
|
+
*/
|
|
522
|
+
viewport: {
|
|
523
|
+
/**
|
|
524
|
+
* page width in pixels.
|
|
525
|
+
*/
|
|
526
|
+
width: number;
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* page height in pixels.
|
|
530
|
+
*/
|
|
531
|
+
height: number;
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Device viewport scale factor.
|
|
536
|
+
*/
|
|
537
|
+
deviceScaleFactor: number;
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Indicates whether the device is a mobile device.
|
|
541
|
+
*/
|
|
542
|
+
isMobile: boolean;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Indicates whether the device support touch events.
|
|
546
|
+
*/
|
|
547
|
+
hasTouch: boolean;
|
|
548
|
+
}
|
|
549
|
+
|
|
417
550
|
/**
|
|
418
551
|
* BrowserPermissions defines all the possible permissions that can be granted
|
|
419
552
|
* to the browser application.
|
|
@@ -1719,10 +1852,18 @@ export interface Frame {
|
|
|
1719
1852
|
|
|
1720
1853
|
/**
|
|
1721
1854
|
* Сreates and returns a new locator for this frame.
|
|
1855
|
+
*
|
|
1856
|
+
* @example
|
|
1857
|
+
* ```js
|
|
1858
|
+
* const frame = page.frames()[1];
|
|
1859
|
+
* const submitButton = frame.locator('button', { hasText: 'Pizza, Please!' });
|
|
1860
|
+
* ```
|
|
1861
|
+
*
|
|
1722
1862
|
* @param selector The selector to use.
|
|
1863
|
+
* @param options Options to use for filtering.
|
|
1723
1864
|
* @returns The new locator.
|
|
1724
1865
|
*/
|
|
1725
|
-
locator(selector: string): Locator;
|
|
1866
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
1726
1867
|
|
|
1727
1868
|
/**
|
|
1728
1869
|
* Get the `innerHTML` attribute of the first element found that matches the selector.
|
|
@@ -1961,101 +2102,813 @@ export interface Frame {
|
|
|
1961
2102
|
* @param timeout The timeout to wait for.
|
|
1962
2103
|
*/
|
|
1963
2104
|
waitForTimeout(timeout: number): Promise<void>;
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
/**
|
|
1967
|
-
* JSHandle represents an in-page JavaScript object.
|
|
1968
|
-
*/
|
|
1969
|
-
export interface JSHandle<T = any> {
|
|
1970
|
-
/**
|
|
1971
|
-
* Returns either `null` or the object handle itself, if the object handle is
|
|
1972
|
-
* an instance of `ElementHandle`.
|
|
1973
|
-
* @returns The ElementHandle if available.
|
|
1974
|
-
*/
|
|
1975
|
-
asElement(): Promise<ElementHandle | null>;
|
|
1976
2105
|
|
|
1977
2106
|
/**
|
|
1978
|
-
*
|
|
2107
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
2108
|
+
*
|
|
2109
|
+
* @example
|
|
2110
|
+
* ```js
|
|
2111
|
+
* const locator = frame.getByRole('button', { name: 'Pizza, Please!' });
|
|
2112
|
+
*
|
|
2113
|
+
* await locator.click();
|
|
2114
|
+
* ```
|
|
2115
|
+
*
|
|
2116
|
+
* @param role The role of the element.
|
|
2117
|
+
* @param options Options to use.
|
|
2118
|
+
* @returns The locator to the element with the corresponding role.
|
|
1979
2119
|
*/
|
|
1980
|
-
|
|
2120
|
+
getByRole(
|
|
2121
|
+
role:
|
|
2122
|
+
| "alert"
|
|
2123
|
+
| "alertdialog"
|
|
2124
|
+
| "application"
|
|
2125
|
+
| "article"
|
|
2126
|
+
| "banner"
|
|
2127
|
+
| "blockquote"
|
|
2128
|
+
| "button"
|
|
2129
|
+
| "caption"
|
|
2130
|
+
| "cell"
|
|
2131
|
+
| "checkbox"
|
|
2132
|
+
| "code"
|
|
2133
|
+
| "columnheader"
|
|
2134
|
+
| "combobox"
|
|
2135
|
+
| "complementary"
|
|
2136
|
+
| "contentinfo"
|
|
2137
|
+
| "definition"
|
|
2138
|
+
| "dialog"
|
|
2139
|
+
| "directory"
|
|
2140
|
+
| "document"
|
|
2141
|
+
| "emphasis"
|
|
2142
|
+
| "feed"
|
|
2143
|
+
| "figure"
|
|
2144
|
+
| "form"
|
|
2145
|
+
| "generic"
|
|
2146
|
+
| "grid"
|
|
2147
|
+
| "gridcell"
|
|
2148
|
+
| "group"
|
|
2149
|
+
| "heading"
|
|
2150
|
+
| "img"
|
|
2151
|
+
| "insertion"
|
|
2152
|
+
| "link"
|
|
2153
|
+
| "list"
|
|
2154
|
+
| "listbox"
|
|
2155
|
+
| "listitem"
|
|
2156
|
+
| "log"
|
|
2157
|
+
| "main"
|
|
2158
|
+
| "marquee"
|
|
2159
|
+
| "math"
|
|
2160
|
+
| "menu"
|
|
2161
|
+
| "menubar"
|
|
2162
|
+
| "menuitem"
|
|
2163
|
+
| "menuitemcheckbox"
|
|
2164
|
+
| "menuitemradio"
|
|
2165
|
+
| "meter"
|
|
2166
|
+
| "navigation"
|
|
2167
|
+
| "none"
|
|
2168
|
+
| "note"
|
|
2169
|
+
| "option"
|
|
2170
|
+
| "presentation"
|
|
2171
|
+
| "progressbar"
|
|
2172
|
+
| "radio"
|
|
2173
|
+
| "radiogroup"
|
|
2174
|
+
| "region"
|
|
2175
|
+
| "row"
|
|
2176
|
+
| "rowgroup"
|
|
2177
|
+
| "rowheader"
|
|
2178
|
+
| "scrollbar"
|
|
2179
|
+
| "search"
|
|
2180
|
+
| "searchbox"
|
|
2181
|
+
| "separator"
|
|
2182
|
+
| "slider"
|
|
2183
|
+
| "spinbutton"
|
|
2184
|
+
| "status"
|
|
2185
|
+
| "strong"
|
|
2186
|
+
| "subscript"
|
|
2187
|
+
| "superscript"
|
|
2188
|
+
| "switch"
|
|
2189
|
+
| "tab"
|
|
2190
|
+
| "table"
|
|
2191
|
+
| "tablist"
|
|
2192
|
+
| "tabpanel"
|
|
2193
|
+
| "term"
|
|
2194
|
+
| "textbox"
|
|
2195
|
+
| "time"
|
|
2196
|
+
| "timer"
|
|
2197
|
+
| "toolbar"
|
|
2198
|
+
| "tooltip"
|
|
2199
|
+
| "tree"
|
|
2200
|
+
| "treegrid"
|
|
2201
|
+
| "treeitem",
|
|
2202
|
+
options?: {
|
|
2203
|
+
/**
|
|
2204
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
2205
|
+
*
|
|
2206
|
+
* @defaultValue false
|
|
2207
|
+
*/
|
|
2208
|
+
exact?: boolean;
|
|
1981
2209
|
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
*/
|
|
1989
|
-
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
2210
|
+
/**
|
|
2211
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
2212
|
+
*
|
|
2213
|
+
* @defaultValue false
|
|
2214
|
+
*/
|
|
2215
|
+
includeHidden?: boolean;
|
|
1990
2216
|
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
* @param pageFunction The function to be evaluated.
|
|
1996
|
-
* @param args The arguments to pass to the page function.
|
|
1997
|
-
* @returns A JSHandle of the return value of `pageFunction`.
|
|
1998
|
-
*/
|
|
1999
|
-
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
2217
|
+
/**
|
|
2218
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
2219
|
+
*/
|
|
2220
|
+
level?: number;
|
|
2000
2221
|
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
*/
|
|
2006
|
-
getProperties(): Promise<Map<string, JSHandle>>;
|
|
2222
|
+
/**
|
|
2223
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
2224
|
+
*/
|
|
2225
|
+
name?: string | RegExp;
|
|
2007
2226
|
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
jsonValue(): Promise<any>;
|
|
2013
|
-
}
|
|
2227
|
+
/**
|
|
2228
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
2229
|
+
*/
|
|
2230
|
+
checked?: boolean;
|
|
2014
2231
|
|
|
2015
|
-
/**
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
/**
|
|
2020
|
-
* Sends a key down message to a session target.
|
|
2021
|
-
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
2022
|
-
* @param key Name of key to press, such as `ArrowLeft`.
|
|
2023
|
-
*/
|
|
2024
|
-
down(key: string): Promise<void>;
|
|
2232
|
+
/**
|
|
2233
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
2234
|
+
*/
|
|
2235
|
+
disabled?: boolean;
|
|
2025
2236
|
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
*/
|
|
2031
|
-
insertText(text: string): Promise<void>;
|
|
2237
|
+
/**
|
|
2238
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
2239
|
+
*/
|
|
2240
|
+
expanded?: boolean;
|
|
2032
2241
|
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
* @param options Specifies the typing options.
|
|
2038
|
-
*/
|
|
2039
|
-
press(key: string, options?: { delay?: number }): Promise<void>;
|
|
2242
|
+
/**
|
|
2243
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
2244
|
+
*/
|
|
2245
|
+
pressed?: boolean;
|
|
2040
2246
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
* @param options Specifies the typing options.
|
|
2048
|
-
*/
|
|
2049
|
-
type(text: string, options?: { delay?: number }): Promise<void>;
|
|
2247
|
+
/**
|
|
2248
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
2249
|
+
*/
|
|
2250
|
+
selected?: boolean;
|
|
2251
|
+
},
|
|
2252
|
+
): Locator;
|
|
2050
2253
|
|
|
2051
2254
|
/**
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2255
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
2256
|
+
*
|
|
2257
|
+
* @example
|
|
2258
|
+
* ```js
|
|
2259
|
+
* const locator = frame.getByAltText('pizza');
|
|
2260
|
+
*
|
|
2261
|
+
* await locator.click();
|
|
2262
|
+
* ```
|
|
2263
|
+
*
|
|
2264
|
+
* @param altText The alt text of the element.
|
|
2265
|
+
* @param options Options to use.
|
|
2266
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
2267
|
+
*/
|
|
2268
|
+
getByAltText(
|
|
2269
|
+
altText: string | RegExp,
|
|
2270
|
+
options?: {
|
|
2271
|
+
/**
|
|
2272
|
+
* Whether the locator should be exact.
|
|
2273
|
+
*
|
|
2274
|
+
* @defaultValue false
|
|
2275
|
+
*/
|
|
2276
|
+
exact?: boolean;
|
|
2277
|
+
},
|
|
2278
|
+
): Locator;
|
|
2279
|
+
|
|
2280
|
+
/**
|
|
2281
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2282
|
+
*
|
|
2283
|
+
* @example
|
|
2284
|
+
* ```js
|
|
2285
|
+
* const locator = frame.getByLabel('Password');
|
|
2286
|
+
*
|
|
2287
|
+
* await locator.fill('my-password');
|
|
2288
|
+
* ```
|
|
2289
|
+
*
|
|
2290
|
+
* @param label The label text of the element.
|
|
2291
|
+
* @param options Options to use.
|
|
2292
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2293
|
+
*/
|
|
2294
|
+
getByLabel(
|
|
2295
|
+
label: string | RegExp,
|
|
2296
|
+
options?: {
|
|
2297
|
+
/**
|
|
2298
|
+
* Whether the locator should be exact.
|
|
2299
|
+
*
|
|
2300
|
+
* @defaultValue false
|
|
2301
|
+
*/
|
|
2302
|
+
exact?: boolean;
|
|
2303
|
+
},
|
|
2304
|
+
): Locator;
|
|
2305
|
+
|
|
2306
|
+
/**
|
|
2307
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
2308
|
+
*
|
|
2309
|
+
* Consider the following DOM structure:
|
|
2310
|
+
*
|
|
2311
|
+
* ```html
|
|
2312
|
+
* <div>Hello <span>world</span></div>
|
|
2313
|
+
* <div>Hello</div>
|
|
2314
|
+
* ```
|
|
2315
|
+
*
|
|
2316
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
2317
|
+
*
|
|
2318
|
+
* @example
|
|
2319
|
+
* ```js
|
|
2320
|
+
* // Matches <span>
|
|
2321
|
+
* frame.getByText('world');
|
|
2322
|
+
*
|
|
2323
|
+
* // Matches first <div>
|
|
2324
|
+
* frame.getByText('Hello world');
|
|
2325
|
+
*
|
|
2326
|
+
* // Matches second <div>
|
|
2327
|
+
* frame.getByText('Hello', { exact: true });
|
|
2328
|
+
*
|
|
2329
|
+
* // Matches both <div>s
|
|
2330
|
+
* frame.getByText(/Hello/);
|
|
2331
|
+
*
|
|
2332
|
+
* // Matches second <div>
|
|
2333
|
+
* frame.getByText(/^hello$/i);
|
|
2334
|
+
* ```
|
|
2335
|
+
*
|
|
2336
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
2337
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
2338
|
+
* and ignores leading and trailing whitespace.
|
|
2339
|
+
*
|
|
2340
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
2341
|
+
* `value` instead of the text content. For example, locating by text
|
|
2342
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
2343
|
+
*
|
|
2344
|
+
* @param text Text to locate the element by.
|
|
2345
|
+
* @param options Options to use.
|
|
2346
|
+
* @returns The locator to the element with the corresponding text content.
|
|
2347
|
+
*/
|
|
2348
|
+
getByText(
|
|
2349
|
+
text: string | RegExp,
|
|
2350
|
+
options?: {
|
|
2351
|
+
/**
|
|
2352
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
2353
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
2354
|
+
* Note that exact match still trims whitespace.
|
|
2355
|
+
*
|
|
2356
|
+
* @defaultValue false
|
|
2357
|
+
*/
|
|
2358
|
+
exact?: boolean;
|
|
2359
|
+
},
|
|
2360
|
+
): Locator;
|
|
2361
|
+
|
|
2362
|
+
/**
|
|
2363
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
2364
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
2365
|
+
*
|
|
2366
|
+
* @example
|
|
2367
|
+
* HTML:
|
|
2368
|
+
* ```html
|
|
2369
|
+
* <button data-testid="submit-button">Submit</button>
|
|
2370
|
+
* ```
|
|
2371
|
+
*
|
|
2372
|
+
* JavaScript:
|
|
2373
|
+
* ```js
|
|
2374
|
+
* const locator = frame.getByTestId('submit-button');
|
|
2375
|
+
*
|
|
2376
|
+
* await locator.click();
|
|
2377
|
+
* ```
|
|
2378
|
+
*
|
|
2379
|
+
* @param testId The test ID of the element.
|
|
2380
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2381
|
+
*/
|
|
2382
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2383
|
+
|
|
2384
|
+
/**
|
|
2385
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
2386
|
+
*
|
|
2387
|
+
* @example
|
|
2388
|
+
* ```js
|
|
2389
|
+
* const locator = frame.getByPlaceholder('name@example.com');
|
|
2390
|
+
*
|
|
2391
|
+
* await locator.fill('my.name@example.com');
|
|
2392
|
+
* ```
|
|
2393
|
+
*
|
|
2394
|
+
* @param placeholder The placeholder text of the element.
|
|
2395
|
+
* @param options Options to use.
|
|
2396
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2397
|
+
*/
|
|
2398
|
+
getByPlaceholder(
|
|
2399
|
+
placeholder: string | RegExp,
|
|
2400
|
+
options?: {
|
|
2401
|
+
/**
|
|
2402
|
+
* Whether the locator should be exact.
|
|
2403
|
+
*
|
|
2404
|
+
* @defaultValue false
|
|
2405
|
+
*/
|
|
2406
|
+
exact?: boolean;
|
|
2407
|
+
},
|
|
2408
|
+
): Locator;
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
2412
|
+
*
|
|
2413
|
+
* @example
|
|
2414
|
+
* ```js
|
|
2415
|
+
* const locator = frame.getByTitle('Information box');
|
|
2416
|
+
*
|
|
2417
|
+
* await locator.click();
|
|
2418
|
+
* ```
|
|
2419
|
+
*
|
|
2420
|
+
* @param title The title text of the element.
|
|
2421
|
+
* @param options Options to use.
|
|
2422
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2423
|
+
*/
|
|
2424
|
+
getByTitle(
|
|
2425
|
+
title: string | RegExp,
|
|
2426
|
+
options?: {
|
|
2427
|
+
/**
|
|
2428
|
+
* Whether the locator should be exact.
|
|
2429
|
+
*
|
|
2430
|
+
* @defaultValue false
|
|
2431
|
+
*/
|
|
2432
|
+
exact?: boolean;
|
|
2433
|
+
},
|
|
2434
|
+
): Locator;
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* FrameLocator makes it easier to locate elements within an `iframe` on the
|
|
2439
|
+
* page. `FrameLocator` are created by calling `page.locator(selector).contentFrame()`.
|
|
2440
|
+
* It works in the same way as `Locator` instances.
|
|
2441
|
+
*/
|
|
2442
|
+
export interface FrameLocator {
|
|
2443
|
+
/**
|
|
2444
|
+
* The method finds all elements matching the selector and creates a new
|
|
2445
|
+
* locator that matches all of them. This method can be used to further
|
|
2446
|
+
* refine the locator by chaining additional selectors.
|
|
2447
|
+
*
|
|
2448
|
+
* @example
|
|
2449
|
+
* ```js
|
|
2450
|
+
* const frame = page.frameLocator('iframe');
|
|
2451
|
+
* const rows = frame.locator('table tr');
|
|
2452
|
+
* const cell = rows.locator('.selected');
|
|
2453
|
+
*
|
|
2454
|
+
* // Use with options to filter by text
|
|
2455
|
+
* const submitButton = frame.locator('button', { hasText: 'Submit' });
|
|
2456
|
+
* ```
|
|
2457
|
+
*
|
|
2458
|
+
* @param selector A selector to use when resolving DOM element.
|
|
2459
|
+
* @param options Options to use for filtering.
|
|
2460
|
+
* @returns The new locator.
|
|
2461
|
+
*/
|
|
2462
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
2463
|
+
|
|
2464
|
+
/**
|
|
2465
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
2466
|
+
*
|
|
2467
|
+
* @example
|
|
2468
|
+
* ```js
|
|
2469
|
+
* const locator = frameLocator.getByRole('button', { name: 'Pizza, Please!' });
|
|
2470
|
+
*
|
|
2471
|
+
* await locator.click();
|
|
2472
|
+
* ```
|
|
2473
|
+
*
|
|
2474
|
+
* @param role The role of the element.
|
|
2475
|
+
* @param options Options to use.
|
|
2476
|
+
* @returns The locator to the element with the corresponding role.
|
|
2477
|
+
*/
|
|
2478
|
+
getByRole(
|
|
2479
|
+
role:
|
|
2480
|
+
| "alert"
|
|
2481
|
+
| "alertdialog"
|
|
2482
|
+
| "application"
|
|
2483
|
+
| "article"
|
|
2484
|
+
| "banner"
|
|
2485
|
+
| "blockquote"
|
|
2486
|
+
| "button"
|
|
2487
|
+
| "caption"
|
|
2488
|
+
| "cell"
|
|
2489
|
+
| "checkbox"
|
|
2490
|
+
| "code"
|
|
2491
|
+
| "columnheader"
|
|
2492
|
+
| "combobox"
|
|
2493
|
+
| "complementary"
|
|
2494
|
+
| "contentinfo"
|
|
2495
|
+
| "definition"
|
|
2496
|
+
| "dialog"
|
|
2497
|
+
| "directory"
|
|
2498
|
+
| "document"
|
|
2499
|
+
| "emphasis"
|
|
2500
|
+
| "feed"
|
|
2501
|
+
| "figure"
|
|
2502
|
+
| "form"
|
|
2503
|
+
| "generic"
|
|
2504
|
+
| "grid"
|
|
2505
|
+
| "gridcell"
|
|
2506
|
+
| "group"
|
|
2507
|
+
| "heading"
|
|
2508
|
+
| "img"
|
|
2509
|
+
| "insertion"
|
|
2510
|
+
| "link"
|
|
2511
|
+
| "list"
|
|
2512
|
+
| "listbox"
|
|
2513
|
+
| "listitem"
|
|
2514
|
+
| "log"
|
|
2515
|
+
| "main"
|
|
2516
|
+
| "marquee"
|
|
2517
|
+
| "math"
|
|
2518
|
+
| "menu"
|
|
2519
|
+
| "menubar"
|
|
2520
|
+
| "menuitem"
|
|
2521
|
+
| "menuitemcheckbox"
|
|
2522
|
+
| "menuitemradio"
|
|
2523
|
+
| "meter"
|
|
2524
|
+
| "navigation"
|
|
2525
|
+
| "none"
|
|
2526
|
+
| "note"
|
|
2527
|
+
| "option"
|
|
2528
|
+
| "presentation"
|
|
2529
|
+
| "progressbar"
|
|
2530
|
+
| "radio"
|
|
2531
|
+
| "radiogroup"
|
|
2532
|
+
| "region"
|
|
2533
|
+
| "row"
|
|
2534
|
+
| "rowgroup"
|
|
2535
|
+
| "rowheader"
|
|
2536
|
+
| "scrollbar"
|
|
2537
|
+
| "search"
|
|
2538
|
+
| "searchbox"
|
|
2539
|
+
| "separator"
|
|
2540
|
+
| "slider"
|
|
2541
|
+
| "spinbutton"
|
|
2542
|
+
| "status"
|
|
2543
|
+
| "strong"
|
|
2544
|
+
| "subscript"
|
|
2545
|
+
| "superscript"
|
|
2546
|
+
| "switch"
|
|
2547
|
+
| "tab"
|
|
2548
|
+
| "table"
|
|
2549
|
+
| "tablist"
|
|
2550
|
+
| "tabpanel"
|
|
2551
|
+
| "term"
|
|
2552
|
+
| "textbox"
|
|
2553
|
+
| "time"
|
|
2554
|
+
| "timer"
|
|
2555
|
+
| "toolbar"
|
|
2556
|
+
| "tooltip"
|
|
2557
|
+
| "tree"
|
|
2558
|
+
| "treegrid"
|
|
2559
|
+
| "treeitem",
|
|
2560
|
+
options?: {
|
|
2561
|
+
/**
|
|
2562
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
2563
|
+
*
|
|
2564
|
+
* @defaultValue false
|
|
2565
|
+
*/
|
|
2566
|
+
exact?: boolean;
|
|
2567
|
+
|
|
2568
|
+
/**
|
|
2569
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
2570
|
+
*
|
|
2571
|
+
* @defaultValue false
|
|
2572
|
+
*/
|
|
2573
|
+
includeHidden?: boolean;
|
|
2574
|
+
|
|
2575
|
+
/**
|
|
2576
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
2577
|
+
*/
|
|
2578
|
+
level?: number;
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
2582
|
+
*/
|
|
2583
|
+
name?: string | RegExp;
|
|
2584
|
+
|
|
2585
|
+
/**
|
|
2586
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
2587
|
+
*/
|
|
2588
|
+
checked?: boolean;
|
|
2589
|
+
|
|
2590
|
+
/**
|
|
2591
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
2592
|
+
*/
|
|
2593
|
+
disabled?: boolean;
|
|
2594
|
+
|
|
2595
|
+
/**
|
|
2596
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
2597
|
+
*/
|
|
2598
|
+
expanded?: boolean;
|
|
2599
|
+
|
|
2600
|
+
/**
|
|
2601
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
2602
|
+
*/
|
|
2603
|
+
pressed?: boolean;
|
|
2604
|
+
|
|
2605
|
+
/**
|
|
2606
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
2607
|
+
*/
|
|
2608
|
+
selected?: boolean;
|
|
2609
|
+
},
|
|
2610
|
+
): Locator;
|
|
2611
|
+
|
|
2612
|
+
/**
|
|
2613
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
2614
|
+
*
|
|
2615
|
+
* @example
|
|
2616
|
+
* ```js
|
|
2617
|
+
* const locator = frameLocator.getByAltText('pizza');
|
|
2618
|
+
*
|
|
2619
|
+
* await locator.click();
|
|
2620
|
+
* ```
|
|
2621
|
+
*
|
|
2622
|
+
* @param altText The alt text of the element.
|
|
2623
|
+
* @param options Options to use.
|
|
2624
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
2625
|
+
*/
|
|
2626
|
+
getByAltText(
|
|
2627
|
+
altText: string | RegExp,
|
|
2628
|
+
options?: {
|
|
2629
|
+
/**
|
|
2630
|
+
* Whether the locator should be exact.
|
|
2631
|
+
*
|
|
2632
|
+
* @defaultValue false
|
|
2633
|
+
*/
|
|
2634
|
+
exact?: boolean;
|
|
2635
|
+
},
|
|
2636
|
+
): Locator;
|
|
2637
|
+
|
|
2638
|
+
/**
|
|
2639
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2640
|
+
*
|
|
2641
|
+
* @example
|
|
2642
|
+
* ```js
|
|
2643
|
+
* const locator = frameLocator.getByLabel('Password');
|
|
2644
|
+
*
|
|
2645
|
+
* await locator.fill('my-password');
|
|
2646
|
+
* ```
|
|
2647
|
+
*
|
|
2648
|
+
* @param label The label text of the element.
|
|
2649
|
+
* @param options Options to use.
|
|
2650
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2651
|
+
*/
|
|
2652
|
+
getByLabel(
|
|
2653
|
+
label: string | RegExp,
|
|
2654
|
+
options?: {
|
|
2655
|
+
/**
|
|
2656
|
+
* Whether the locator should be exact.
|
|
2657
|
+
*
|
|
2658
|
+
* @defaultValue false
|
|
2659
|
+
*/
|
|
2660
|
+
exact?: boolean;
|
|
2661
|
+
},
|
|
2662
|
+
): Locator;
|
|
2663
|
+
|
|
2664
|
+
/**
|
|
2665
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
2666
|
+
*
|
|
2667
|
+
* Consider the following DOM structure:
|
|
2668
|
+
*
|
|
2669
|
+
* ```html
|
|
2670
|
+
* <div>Hello <span>world</span></div>
|
|
2671
|
+
* <div>Hello</div>
|
|
2672
|
+
* ```
|
|
2673
|
+
*
|
|
2674
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
2675
|
+
*
|
|
2676
|
+
* @example
|
|
2677
|
+
* ```js
|
|
2678
|
+
* // Matches <span>
|
|
2679
|
+
* frameLocator.getByText('world');
|
|
2680
|
+
*
|
|
2681
|
+
* // Matches first <div>
|
|
2682
|
+
* frameLocator.getByText('Hello world');
|
|
2683
|
+
*
|
|
2684
|
+
* // Matches second <div>
|
|
2685
|
+
* frameLocator.getByText('Hello', { exact: true });
|
|
2686
|
+
*
|
|
2687
|
+
* // Matches both <div>s
|
|
2688
|
+
* frameLocator.getByText(/Hello/);
|
|
2689
|
+
*
|
|
2690
|
+
* // Matches second <div>
|
|
2691
|
+
* frameLocator.getByText(/^hello$/i);
|
|
2692
|
+
* ```
|
|
2693
|
+
*
|
|
2694
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
2695
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
2696
|
+
* and ignores leading and trailing whitespace.
|
|
2697
|
+
*
|
|
2698
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
2699
|
+
* `value` instead of the text content. For example, locating by text
|
|
2700
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
2701
|
+
*
|
|
2702
|
+
* @param text Text to locate the element by.
|
|
2703
|
+
* @param options Options to use.
|
|
2704
|
+
* @returns The locator to the element with the corresponding text content.
|
|
2705
|
+
*/
|
|
2706
|
+
getByText(
|
|
2707
|
+
text: string | RegExp,
|
|
2708
|
+
options?: {
|
|
2709
|
+
/**
|
|
2710
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
2711
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
2712
|
+
* Note that exact match still trims whitespace.
|
|
2713
|
+
*
|
|
2714
|
+
* @defaultValue false
|
|
2715
|
+
*/
|
|
2716
|
+
exact?: boolean;
|
|
2717
|
+
},
|
|
2718
|
+
): Locator;
|
|
2719
|
+
|
|
2720
|
+
/**
|
|
2721
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
2722
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
2723
|
+
*
|
|
2724
|
+
* @example
|
|
2725
|
+
* HTML:
|
|
2726
|
+
* ```html
|
|
2727
|
+
* <button data-testid="submit-button">Submit</button>
|
|
2728
|
+
* ```
|
|
2729
|
+
*
|
|
2730
|
+
* JavaScript:
|
|
2731
|
+
* ```js
|
|
2732
|
+
* const locator = frameLocator.getByTestId('submit-button');
|
|
2733
|
+
*
|
|
2734
|
+
* await locator.click();
|
|
2735
|
+
* ```
|
|
2736
|
+
*
|
|
2737
|
+
* @param testId The test ID of the element.
|
|
2738
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2739
|
+
*/
|
|
2740
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2741
|
+
|
|
2742
|
+
/**
|
|
2743
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
2744
|
+
*
|
|
2745
|
+
* @example
|
|
2746
|
+
* ```js
|
|
2747
|
+
* const locator = frameLocator.getByPlaceholder('name@example.com');
|
|
2748
|
+
*
|
|
2749
|
+
* await locator.fill('my.name@example.com');
|
|
2750
|
+
* ```
|
|
2751
|
+
*
|
|
2752
|
+
* @param placeholder The placeholder text of the element.
|
|
2753
|
+
* @param options Options to use.
|
|
2754
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2755
|
+
*/
|
|
2756
|
+
getByPlaceholder(
|
|
2757
|
+
placeholder: string | RegExp,
|
|
2758
|
+
options?: {
|
|
2759
|
+
/**
|
|
2760
|
+
* Whether the locator should be exact.
|
|
2761
|
+
*
|
|
2762
|
+
* @defaultValue false
|
|
2763
|
+
*/
|
|
2764
|
+
exact?: boolean;
|
|
2765
|
+
},
|
|
2766
|
+
): Locator;
|
|
2767
|
+
|
|
2768
|
+
/**
|
|
2769
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
2770
|
+
*
|
|
2771
|
+
* @example
|
|
2772
|
+
* ```js
|
|
2773
|
+
* const locator = frameLocator.getByTitle('Information box');
|
|
2774
|
+
*
|
|
2775
|
+
* await locator.click();
|
|
2776
|
+
* ```
|
|
2777
|
+
*
|
|
2778
|
+
* @param title The title text of the element.
|
|
2779
|
+
* @param options Options to use.
|
|
2780
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2781
|
+
*/
|
|
2782
|
+
getByTitle(
|
|
2783
|
+
title: string | RegExp,
|
|
2784
|
+
options?: {
|
|
2785
|
+
/**
|
|
2786
|
+
* Whether the locator should be exact.
|
|
2787
|
+
*
|
|
2788
|
+
* @defaultValue false
|
|
2789
|
+
*/
|
|
2790
|
+
exact?: boolean;
|
|
2791
|
+
},
|
|
2792
|
+
): Locator;
|
|
2793
|
+
}
|
|
2794
|
+
|
|
2795
|
+
/**
|
|
2796
|
+
* JSHandle represents an in-page JavaScript object.
|
|
2797
|
+
*/
|
|
2798
|
+
export interface JSHandle<T = any> {
|
|
2799
|
+
/**
|
|
2800
|
+
* Returns either `null` or the object handle itself, if the object handle is
|
|
2801
|
+
* an instance of `ElementHandle`.
|
|
2802
|
+
* @returns The ElementHandle if available.
|
|
2803
|
+
*/
|
|
2804
|
+
asElement(): Promise<ElementHandle | null>;
|
|
2805
|
+
|
|
2806
|
+
/**
|
|
2807
|
+
* Stops referencing the element handle.
|
|
2808
|
+
*/
|
|
2809
|
+
dispose(): Promise<void>;
|
|
2810
|
+
|
|
2811
|
+
/**
|
|
2812
|
+
* Evaluates the page function and returns its return value.
|
|
2813
|
+
* This method passes this handle as the first argument to the page function.
|
|
2814
|
+
* @param pageFunction The function to be evaluated.
|
|
2815
|
+
* @param args The arguments to pass to the page function.
|
|
2816
|
+
* @returns The return value of `pageFunction`.
|
|
2817
|
+
*/
|
|
2818
|
+
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
2819
|
+
|
|
2820
|
+
/**
|
|
2821
|
+
* Evaluates the page function and returns a `JSHandle`.
|
|
2822
|
+
* This method passes this handle as the first argument to the page function.
|
|
2823
|
+
* Unlike `evaluate`, `evaluateHandle` returns the value as a `JSHandle`
|
|
2824
|
+
* @param pageFunction The function to be evaluated.
|
|
2825
|
+
* @param args The arguments to pass to the page function.
|
|
2826
|
+
* @returns A JSHandle of the return value of `pageFunction`.
|
|
2827
|
+
*/
|
|
2828
|
+
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
2829
|
+
|
|
2830
|
+
/**
|
|
2831
|
+
* Fetches a map with own property names of of the `JSHandle` with their values as
|
|
2832
|
+
* `JSHandle` instances.
|
|
2833
|
+
* @returns A map with property names as keys and `JSHandle` instances for the property values.
|
|
2834
|
+
*/
|
|
2835
|
+
getProperties(): Promise<Map<string, JSHandle>>;
|
|
2836
|
+
|
|
2837
|
+
/**
|
|
2838
|
+
* Fetches a JSON representation of the object.
|
|
2839
|
+
* @returns A JSON representation of the object.
|
|
2840
|
+
*/
|
|
2841
|
+
jsonValue(): Promise<any>;
|
|
2842
|
+
}
|
|
2843
|
+
|
|
2844
|
+
/**
|
|
2845
|
+
* Keyboard provides an API for managing a virtual keyboard.
|
|
2846
|
+
*/
|
|
2847
|
+
export interface Keyboard {
|
|
2848
|
+
/**
|
|
2849
|
+
* Sends a key down message to a session target.
|
|
2850
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
2851
|
+
* @param key Name of key to press, such as `ArrowLeft`.
|
|
2852
|
+
*/
|
|
2853
|
+
down(key: string): Promise<void>;
|
|
2854
|
+
|
|
2855
|
+
/**
|
|
2856
|
+
* Dispatches an `input` event with the given `text`.
|
|
2857
|
+
* This method does not emit `keyDown`, `keyUp` or `keyPress` events.
|
|
2858
|
+
* @param text Event text.
|
|
2859
|
+
*/
|
|
2860
|
+
insertText(text: string): Promise<void>;
|
|
2861
|
+
|
|
2862
|
+
/**
|
|
2863
|
+
* Sends a key press message to a session target.
|
|
2864
|
+
* A press message consists of successive key down and up messages.
|
|
2865
|
+
* @param key Sequence of keys to press.
|
|
2866
|
+
* @param options Specifies the typing options.
|
|
2867
|
+
*/
|
|
2868
|
+
press(key: string, options?: { delay?: number }): Promise<void>;
|
|
2869
|
+
|
|
2870
|
+
/**
|
|
2871
|
+
* Type sends a `press` message to a session target for each character in text.
|
|
2872
|
+
* It sends an insertText message if a character is not among
|
|
2873
|
+
* valid characters in the keyboard's layout.
|
|
2874
|
+
* Modifier keys `Shift`, `Control`, `Alt`, `Meta` are _not_ respected.
|
|
2875
|
+
* @param text A text to type into a focused element.
|
|
2876
|
+
* @param options Specifies the typing options.
|
|
2877
|
+
*/
|
|
2878
|
+
type(text: string, options?: { delay?: number }): Promise<void>;
|
|
2879
|
+
|
|
2880
|
+
/**
|
|
2881
|
+
* Sends a key up message to a session target.
|
|
2882
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
2054
2883
|
* @param key Name of key to release, such as `ArrowLeft`.
|
|
2055
2884
|
*/
|
|
2056
2885
|
up(key: string): Promise<void>;
|
|
2057
2886
|
}
|
|
2058
2887
|
|
|
2888
|
+
export interface LocatorOptions {
|
|
2889
|
+
/**
|
|
2890
|
+
* Matches only elements that contain the specified text. String or regular expression.
|
|
2891
|
+
*/
|
|
2892
|
+
hasText?: string | RegExp;
|
|
2893
|
+
|
|
2894
|
+
/**
|
|
2895
|
+
* Matches only elements that do not contain the specified text. String or regular expression.
|
|
2896
|
+
*/
|
|
2897
|
+
hasNotText?: string | RegExp;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
export interface LocatorFilterOptions {
|
|
2901
|
+
/**
|
|
2902
|
+
* Matches only elements that contain the specified text. String or regular expression.
|
|
2903
|
+
*/
|
|
2904
|
+
hasText?: string | RegExp;
|
|
2905
|
+
|
|
2906
|
+
/**
|
|
2907
|
+
* Matches only elements that do not contain the specified text. String or regular expression.
|
|
2908
|
+
*/
|
|
2909
|
+
hasNotText?: string | RegExp;
|
|
2910
|
+
}
|
|
2911
|
+
|
|
2059
2912
|
/**
|
|
2060
2913
|
* The Locator API makes it easier to work with dynamically changing elements.
|
|
2061
2914
|
* Some of the benefits of using it over existing ways to locate an element
|
|
@@ -2080,262 +2933,657 @@ export interface Locator {
|
|
|
2080
2933
|
*
|
|
2081
2934
|
* @returns Array of locators
|
|
2082
2935
|
*/
|
|
2083
|
-
all(): Promise<Locator[]>;
|
|
2936
|
+
all(): Promise<Locator[]>;
|
|
2937
|
+
|
|
2938
|
+
/**
|
|
2939
|
+
* Returns the bounding box of the element that this locator points to.
|
|
2940
|
+
*
|
|
2941
|
+
* **Usage**
|
|
2942
|
+
*
|
|
2943
|
+
* ```js
|
|
2944
|
+
* const locator = page.locator('#my-element');
|
|
2945
|
+
* const boundingBox = await locator.boundingBox();
|
|
2946
|
+
* ```
|
|
2947
|
+
*
|
|
2948
|
+
* @param options Options to use.
|
|
2949
|
+
* @returns The bounding box of the element, or null if the element is not visible.
|
|
2950
|
+
*/
|
|
2951
|
+
boundingBox(options?: TimeoutOptions): Promise<Rect | null>;
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* Clears text boxes and input fields of any existing values.
|
|
2955
|
+
*
|
|
2956
|
+
* **Usage**
|
|
2957
|
+
*
|
|
2958
|
+
* ```js
|
|
2959
|
+
* // Clears the input field matching the selector.
|
|
2960
|
+
* page.locator('input[name="login"]').clear();
|
|
2961
|
+
* ```
|
|
2962
|
+
*
|
|
2963
|
+
* @param options Options to use.
|
|
2964
|
+
*/
|
|
2965
|
+
clear(options?: ElementHandleOptions): Promise<void>;
|
|
2966
|
+
|
|
2967
|
+
/**
|
|
2968
|
+
* Mouse click on the chosen element.
|
|
2969
|
+
* @param options Options to use.
|
|
2970
|
+
* @returns Promise which resolves when the element is successfully clicked.
|
|
2971
|
+
*/
|
|
2972
|
+
click(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
2973
|
+
|
|
2974
|
+
/**
|
|
2975
|
+
* Returns a `FrameLocator` that can be used to locate elements within an
|
|
2976
|
+
* `iframe`.
|
|
2977
|
+
* @returns A `FrameLocator`.
|
|
2978
|
+
*/
|
|
2979
|
+
contentFrame(): FrameLocator;
|
|
2980
|
+
|
|
2981
|
+
/**
|
|
2982
|
+
* Returns the number of elements matching the selector.
|
|
2983
|
+
*
|
|
2984
|
+
* **Usage**
|
|
2985
|
+
*
|
|
2986
|
+
* ```js
|
|
2987
|
+
* const count = await page.locator('input').count();
|
|
2988
|
+
* ```
|
|
2989
|
+
*
|
|
2990
|
+
* @returns Promise which resolves with the number of elements matching the selector.
|
|
2991
|
+
*/
|
|
2992
|
+
count(): Promise<number>;
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* Mouse double click on the chosen element.
|
|
2996
|
+
* @param options Options to use.
|
|
2997
|
+
*/
|
|
2998
|
+
dblclick(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
2999
|
+
|
|
3000
|
+
/**
|
|
3001
|
+
* Use this method to select an `input type="checkbox"`.
|
|
3002
|
+
* @param options Options to use.
|
|
3003
|
+
*/
|
|
3004
|
+
check(options?: ElementClickOptions): Promise<void>;
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* Use this method to unselect an `input type="checkbox"`.
|
|
3008
|
+
* @param options Options to use.
|
|
3009
|
+
*/
|
|
3010
|
+
uncheck(options?: ElementClickOptions): Promise<void>;
|
|
3011
|
+
|
|
3012
|
+
/**
|
|
3013
|
+
* Checks to see if the `input type="checkbox"` is selected or not.
|
|
3014
|
+
* @param options Options to use.
|
|
3015
|
+
* @returns `true` if the element is checked, `false` otherwise.
|
|
3016
|
+
*/
|
|
3017
|
+
isChecked(options?: TimeoutOptions): Promise<boolean>;
|
|
3018
|
+
|
|
3019
|
+
/**
|
|
3020
|
+
* Checks if the element is editable.
|
|
3021
|
+
* @param options Options to use.
|
|
3022
|
+
* @returns `true` if the element is editable, `false` otherwise.
|
|
3023
|
+
*/
|
|
3024
|
+
isEditable(options?: TimeoutOptions): Promise<boolean>;
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* Checks if the element is `enabled`.
|
|
3028
|
+
* @param options Options to use.
|
|
3029
|
+
* @returns `true` if the element is enabled, `false` otherwise.
|
|
3030
|
+
*/
|
|
3031
|
+
isEnabled(options?: TimeoutOptions): Promise<boolean>;
|
|
3032
|
+
|
|
3033
|
+
/**
|
|
3034
|
+
* Checks if the element is `disabled`.
|
|
3035
|
+
* @param options Options to use.
|
|
3036
|
+
* @returns `true` if the element is disabled, `false` otherwise.
|
|
3037
|
+
*/
|
|
3038
|
+
isDisabled(options?: TimeoutOptions): Promise<boolean>;
|
|
3039
|
+
|
|
3040
|
+
/**
|
|
3041
|
+
* Checks if the element is `visible`.
|
|
3042
|
+
* @returns `true` if the element is visible, `false` otherwise.
|
|
3043
|
+
*/
|
|
3044
|
+
isVisible(): Promise<boolean>;
|
|
3045
|
+
|
|
3046
|
+
/**
|
|
3047
|
+
* Checks if the element is `hidden`.
|
|
3048
|
+
* @returns `true` if the element is hidden, `false` otherwise.
|
|
3049
|
+
*/
|
|
3050
|
+
isHidden(): Promise<boolean>;
|
|
3051
|
+
|
|
3052
|
+
/**
|
|
3053
|
+
* Fill an `input`, `textarea` or `contenteditable` element with the provided value.
|
|
3054
|
+
* @param value Value to fill for the `input` or `textarea` element.
|
|
3055
|
+
* @param options Options to use.
|
|
3056
|
+
*/
|
|
3057
|
+
fill(value: string, options?: ElementHandleOptions): Promise<void>;
|
|
3058
|
+
|
|
3059
|
+
/**
|
|
3060
|
+
* Returns locator to the first matching element.
|
|
3061
|
+
*
|
|
3062
|
+
* **Usage**
|
|
3063
|
+
*
|
|
3064
|
+
* ```js
|
|
3065
|
+
* const firstRow = await page.locator('tr').first();
|
|
3066
|
+
* ```
|
|
3067
|
+
*
|
|
3068
|
+
* @returns Locator.
|
|
3069
|
+
*/
|
|
3070
|
+
first(): Locator;
|
|
3071
|
+
|
|
3072
|
+
/**
|
|
3073
|
+
* Focuses the element using locator's selector.
|
|
3074
|
+
* @param options Options to use.
|
|
3075
|
+
*/
|
|
3076
|
+
focus(options?: TimeoutOptions): Promise<void>;
|
|
3077
|
+
|
|
3078
|
+
/**
|
|
3079
|
+
* Returns the element attribute value for the given attribute name.
|
|
3080
|
+
* @param name Attribute name to retrieve value for.
|
|
3081
|
+
* @param options Options to use.
|
|
3082
|
+
* @returns Attribute value.
|
|
3083
|
+
*/
|
|
3084
|
+
getAttribute(name: string, options?: TimeoutOptions): Promise<string | null>;
|
|
3085
|
+
|
|
3086
|
+
/**
|
|
3087
|
+
* Returns the `element.innerHTML`.
|
|
3088
|
+
* @param options Options to use.
|
|
3089
|
+
* @returns Element's innerHTML.
|
|
3090
|
+
*/
|
|
3091
|
+
innerHTML(options?: TimeoutOptions): Promise<string>;
|
|
3092
|
+
|
|
3093
|
+
/**
|
|
3094
|
+
* Returns the `element.innerText`.
|
|
3095
|
+
* @param options Options to use.
|
|
3096
|
+
* @returns Element's innerText.
|
|
3097
|
+
*/
|
|
3098
|
+
innerText(options?: TimeoutOptions): Promise<string>;
|
|
3099
|
+
|
|
3100
|
+
/**
|
|
3101
|
+
* Returns the `element.textContent`.
|
|
3102
|
+
* @param options Options to use.
|
|
3103
|
+
* @returns Element's textContent.
|
|
3104
|
+
*/
|
|
3105
|
+
textContent(options?: TimeoutOptions): Promise<string | null>;
|
|
3106
|
+
|
|
3107
|
+
/**
|
|
3108
|
+
* Returns `input.value` for the selected `input`, `textarea` or `select` element.
|
|
3109
|
+
* @param options Options to use.
|
|
3110
|
+
* @returns The input value of the element.
|
|
3111
|
+
*/
|
|
3112
|
+
inputValue(options?: TimeoutOptions): Promise<string>;
|
|
3113
|
+
|
|
3114
|
+
/**
|
|
3115
|
+
* Returns locator to the last matching element.
|
|
3116
|
+
*
|
|
3117
|
+
* **Usage**
|
|
3118
|
+
*
|
|
3119
|
+
* ```js
|
|
3120
|
+
* const lastRow = await page.locator('tr').last();
|
|
3121
|
+
* ```
|
|
3122
|
+
*
|
|
3123
|
+
* @returns Locator.
|
|
3124
|
+
*/
|
|
3125
|
+
last(): Locator;
|
|
3126
|
+
|
|
3127
|
+
/**
|
|
3128
|
+
* The method finds all elements matching the selector and creates a new
|
|
3129
|
+
* locator that matches all of them. This method can be used to further
|
|
3130
|
+
* refine the locator by chaining additional selectors.
|
|
3131
|
+
*
|
|
3132
|
+
* @example
|
|
3133
|
+
* ```js
|
|
3134
|
+
* const rows = page.locator('table tr');
|
|
3135
|
+
* const cell = rows.locator('.selected');
|
|
3136
|
+
*
|
|
3137
|
+
* // Use with options to filter
|
|
3138
|
+
* const orangeButton = fruitsSection.locator('button', { hasText: 'Add to Cart' });
|
|
3139
|
+
* ```
|
|
3140
|
+
*
|
|
3141
|
+
* @param selector A selector to use when resolving DOM element.
|
|
3142
|
+
* @param options Options to use for filtering.
|
|
3143
|
+
* @returns The new locator.
|
|
3144
|
+
*/
|
|
3145
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
2084
3146
|
|
|
2085
3147
|
/**
|
|
2086
|
-
*
|
|
3148
|
+
* Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
|
2087
3149
|
*
|
|
2088
3150
|
* **Usage**
|
|
2089
3151
|
*
|
|
2090
3152
|
* ```js
|
|
2091
|
-
*
|
|
2092
|
-
* page.locator('input[name="login"]').clear();
|
|
3153
|
+
* const secondRow = await page.locator('tr').nth(1);
|
|
2093
3154
|
* ```
|
|
2094
3155
|
*
|
|
2095
|
-
* @param
|
|
2096
|
-
|
|
2097
|
-
clear(options?: ElementHandleOptions): Promise<void>;
|
|
2098
|
-
|
|
2099
|
-
/**
|
|
2100
|
-
* Mouse click on the chosen element.
|
|
2101
|
-
* @param options Options to use.
|
|
2102
|
-
* @returns Promise which resolves when the element is successfully clicked.
|
|
3156
|
+
* @param index
|
|
3157
|
+
* @returns Locator
|
|
2103
3158
|
*/
|
|
2104
|
-
|
|
3159
|
+
nth(index: number): Locator;
|
|
2105
3160
|
|
|
2106
3161
|
/**
|
|
2107
|
-
*
|
|
2108
|
-
*
|
|
2109
|
-
* **Usage**
|
|
3162
|
+
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
3163
|
+
* otherwise only the first option matching one of the passed options is selected.
|
|
2110
3164
|
*
|
|
3165
|
+
* @example
|
|
2111
3166
|
* ```js
|
|
2112
|
-
*
|
|
3167
|
+
* // Single selection matching the value or label
|
|
3168
|
+
* locator.selectOption('blue');
|
|
3169
|
+
*
|
|
3170
|
+
* // single selection matching the label
|
|
3171
|
+
* locator.selectOption({ label: 'Blue' });
|
|
3172
|
+
*
|
|
3173
|
+
* // multiple selection
|
|
3174
|
+
* locator.selectOption(['red', 'green', 'blue']);
|
|
2113
3175
|
* ```
|
|
2114
3176
|
*
|
|
2115
|
-
* @
|
|
2116
|
-
*/
|
|
2117
|
-
count(): Promise<number>;
|
|
2118
|
-
|
|
2119
|
-
/**
|
|
2120
|
-
* Mouse double click on the chosen element.
|
|
3177
|
+
* @param values Values of options to select.
|
|
2121
3178
|
* @param options Options to use.
|
|
3179
|
+
* @returns List of selected options.
|
|
2122
3180
|
*/
|
|
2123
|
-
|
|
3181
|
+
selectOption(
|
|
3182
|
+
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
3183
|
+
options?: ElementHandleOptions,
|
|
3184
|
+
): Promise<string[]>;
|
|
2124
3185
|
|
|
2125
3186
|
/**
|
|
2126
|
-
*
|
|
2127
|
-
* @param
|
|
3187
|
+
* Checks or unchecks the input checkbox element.
|
|
3188
|
+
* @param checked Whether to check or uncheck the element.
|
|
3189
|
+
* @param options Options to customize the check action.
|
|
3190
|
+
* @returns A promise that resolves when the element is checked or unchecked.
|
|
2128
3191
|
*/
|
|
2129
|
-
|
|
3192
|
+
setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
|
|
2130
3193
|
|
|
2131
3194
|
/**
|
|
2132
|
-
*
|
|
2133
|
-
*
|
|
3195
|
+
* Press a single key on the keyboard or a combination of keys.
|
|
3196
|
+
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
3197
|
+
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
|
|
3198
|
+
* @param options Keyboard press options.
|
|
2134
3199
|
*/
|
|
2135
|
-
|
|
3200
|
+
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2136
3201
|
|
|
2137
3202
|
/**
|
|
2138
|
-
*
|
|
2139
|
-
* @param
|
|
2140
|
-
* @
|
|
3203
|
+
* Type a text into the input field.
|
|
3204
|
+
* @param text Text to type into the input field.
|
|
3205
|
+
* @param options Typing options.
|
|
2141
3206
|
*/
|
|
2142
|
-
|
|
3207
|
+
type(text: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2143
3208
|
|
|
2144
3209
|
/**
|
|
2145
|
-
*
|
|
3210
|
+
* Hover over the element.
|
|
2146
3211
|
* @param options Options to use.
|
|
2147
|
-
* @returns `true` if the element is editable, `false` otherwise.
|
|
2148
3212
|
*/
|
|
2149
|
-
|
|
3213
|
+
hover(options?: MouseMoveOptions): Promise<void>;
|
|
2150
3214
|
|
|
2151
3215
|
/**
|
|
2152
|
-
*
|
|
3216
|
+
* Tap on the chosen element.
|
|
2153
3217
|
* @param options Options to use.
|
|
2154
|
-
* @returns `true` if the element is enabled, `false` otherwise.
|
|
2155
3218
|
*/
|
|
2156
|
-
|
|
3219
|
+
tap(options?: MouseMoveOptions): Promise<void>;
|
|
2157
3220
|
|
|
2158
3221
|
/**
|
|
2159
|
-
*
|
|
3222
|
+
* Dispatches HTML DOM event types e.g. `click`.
|
|
3223
|
+
* @param type DOM event type.
|
|
3224
|
+
* @param eventInit Event-specific properties.
|
|
2160
3225
|
* @param options Options to use.
|
|
2161
|
-
* @returns `true` if the element is disabled, `false` otherwise.
|
|
2162
|
-
*/
|
|
2163
|
-
isDisabled(options?: TimeoutOptions): Promise<boolean>;
|
|
2164
|
-
|
|
2165
|
-
/**
|
|
2166
|
-
* Checks if the element is `visible`.
|
|
2167
|
-
* @returns `true` if the element is visible, `false` otherwise.
|
|
2168
|
-
*/
|
|
2169
|
-
isVisible(): Promise<boolean>;
|
|
2170
|
-
|
|
2171
|
-
/**
|
|
2172
|
-
* Checks if the element is `hidden`.
|
|
2173
|
-
* @returns `true` if the element is hidden, `false` otherwise.
|
|
2174
3226
|
*/
|
|
2175
|
-
|
|
3227
|
+
dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions): Promise<void>;
|
|
2176
3228
|
|
|
2177
3229
|
/**
|
|
2178
|
-
*
|
|
2179
|
-
* @param
|
|
2180
|
-
* @param options Options to use.
|
|
3230
|
+
* Wait for the element to be in a particular state e.g. `visible`.
|
|
3231
|
+
* @param options Wait options.
|
|
2181
3232
|
*/
|
|
2182
|
-
|
|
3233
|
+
waitFor(options?: { state?: ElementState } & TimeoutOptions): Promise<void>;
|
|
2183
3234
|
|
|
2184
3235
|
/**
|
|
2185
|
-
* Returns
|
|
2186
|
-
*
|
|
2187
|
-
* **Usage**
|
|
3236
|
+
* Returns a new Locator that matches only elements with the given options.
|
|
2188
3237
|
*
|
|
3238
|
+
* @example
|
|
2189
3239
|
* ```js
|
|
2190
|
-
*
|
|
3240
|
+
* // Filter list items that contain "Product 2" text
|
|
3241
|
+
* const product2Item = page
|
|
3242
|
+
* .locator('li')
|
|
3243
|
+
* .filter({ hasText: 'Product 2' })
|
|
3244
|
+
* .first();
|
|
3245
|
+
*
|
|
3246
|
+
* // Filter list items that do NOT contain "Product 2" using regex
|
|
3247
|
+
* const product1Item = page
|
|
3248
|
+
* .locator('li')
|
|
3249
|
+
* .filter({ hasNotText: /Product 2/ })
|
|
3250
|
+
* .first();
|
|
2191
3251
|
* ```
|
|
2192
3252
|
*
|
|
2193
|
-
* @
|
|
3253
|
+
* @param options Filter options.
|
|
3254
|
+
* @returns A new filtered Locator that can be chained with other methods.
|
|
2194
3255
|
*/
|
|
2195
|
-
|
|
3256
|
+
filter(options: LocatorFilterOptions): Locator;
|
|
2196
3257
|
|
|
2197
3258
|
/**
|
|
2198
|
-
*
|
|
3259
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
3260
|
+
*
|
|
3261
|
+
* @example
|
|
3262
|
+
* ```js
|
|
3263
|
+
* const locator = locator.getByRole('button', { name: 'Pizza, Please!' });
|
|
3264
|
+
*
|
|
3265
|
+
* await locator.click();
|
|
3266
|
+
* ```
|
|
3267
|
+
*
|
|
3268
|
+
* @param role The role of the element.
|
|
2199
3269
|
* @param options Options to use.
|
|
3270
|
+
* @returns The locator to the element with the corresponding role.
|
|
2200
3271
|
*/
|
|
2201
|
-
|
|
3272
|
+
getByRole(
|
|
3273
|
+
role:
|
|
3274
|
+
| "alert"
|
|
3275
|
+
| "alertdialog"
|
|
3276
|
+
| "application"
|
|
3277
|
+
| "article"
|
|
3278
|
+
| "banner"
|
|
3279
|
+
| "blockquote"
|
|
3280
|
+
| "button"
|
|
3281
|
+
| "caption"
|
|
3282
|
+
| "cell"
|
|
3283
|
+
| "checkbox"
|
|
3284
|
+
| "code"
|
|
3285
|
+
| "columnheader"
|
|
3286
|
+
| "combobox"
|
|
3287
|
+
| "complementary"
|
|
3288
|
+
| "contentinfo"
|
|
3289
|
+
| "definition"
|
|
3290
|
+
| "dialog"
|
|
3291
|
+
| "directory"
|
|
3292
|
+
| "document"
|
|
3293
|
+
| "emphasis"
|
|
3294
|
+
| "feed"
|
|
3295
|
+
| "figure"
|
|
3296
|
+
| "form"
|
|
3297
|
+
| "generic"
|
|
3298
|
+
| "grid"
|
|
3299
|
+
| "gridcell"
|
|
3300
|
+
| "group"
|
|
3301
|
+
| "heading"
|
|
3302
|
+
| "img"
|
|
3303
|
+
| "insertion"
|
|
3304
|
+
| "link"
|
|
3305
|
+
| "list"
|
|
3306
|
+
| "listbox"
|
|
3307
|
+
| "listitem"
|
|
3308
|
+
| "log"
|
|
3309
|
+
| "main"
|
|
3310
|
+
| "marquee"
|
|
3311
|
+
| "math"
|
|
3312
|
+
| "menu"
|
|
3313
|
+
| "menubar"
|
|
3314
|
+
| "menuitem"
|
|
3315
|
+
| "menuitemcheckbox"
|
|
3316
|
+
| "menuitemradio"
|
|
3317
|
+
| "meter"
|
|
3318
|
+
| "navigation"
|
|
3319
|
+
| "none"
|
|
3320
|
+
| "note"
|
|
3321
|
+
| "option"
|
|
3322
|
+
| "presentation"
|
|
3323
|
+
| "progressbar"
|
|
3324
|
+
| "radio"
|
|
3325
|
+
| "radiogroup"
|
|
3326
|
+
| "region"
|
|
3327
|
+
| "row"
|
|
3328
|
+
| "rowgroup"
|
|
3329
|
+
| "rowheader"
|
|
3330
|
+
| "scrollbar"
|
|
3331
|
+
| "search"
|
|
3332
|
+
| "searchbox"
|
|
3333
|
+
| "separator"
|
|
3334
|
+
| "slider"
|
|
3335
|
+
| "spinbutton"
|
|
3336
|
+
| "status"
|
|
3337
|
+
| "strong"
|
|
3338
|
+
| "subscript"
|
|
3339
|
+
| "superscript"
|
|
3340
|
+
| "switch"
|
|
3341
|
+
| "tab"
|
|
3342
|
+
| "table"
|
|
3343
|
+
| "tablist"
|
|
3344
|
+
| "tabpanel"
|
|
3345
|
+
| "term"
|
|
3346
|
+
| "textbox"
|
|
3347
|
+
| "time"
|
|
3348
|
+
| "timer"
|
|
3349
|
+
| "toolbar"
|
|
3350
|
+
| "tooltip"
|
|
3351
|
+
| "tree"
|
|
3352
|
+
| "treegrid"
|
|
3353
|
+
| "treeitem",
|
|
3354
|
+
options?: {
|
|
3355
|
+
/**
|
|
3356
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
3357
|
+
*
|
|
3358
|
+
* @defaultValue false
|
|
3359
|
+
*/
|
|
3360
|
+
exact?: boolean;
|
|
2202
3361
|
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
getAttribute(name: string, options?: TimeoutOptions): Promise<string | null>;
|
|
3362
|
+
/**
|
|
3363
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
3364
|
+
*
|
|
3365
|
+
* @defaultValue false
|
|
3366
|
+
*/
|
|
3367
|
+
includeHidden?: boolean;
|
|
2210
3368
|
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
3369
|
+
/**
|
|
3370
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
3371
|
+
*/
|
|
3372
|
+
level?: number;
|
|
3373
|
+
|
|
3374
|
+
/**
|
|
3375
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
3376
|
+
*/
|
|
3377
|
+
name?: string | RegExp;
|
|
3378
|
+
|
|
3379
|
+
/**
|
|
3380
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
3381
|
+
*/
|
|
3382
|
+
checked?: boolean;
|
|
3383
|
+
|
|
3384
|
+
/**
|
|
3385
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
3386
|
+
*/
|
|
3387
|
+
disabled?: boolean;
|
|
3388
|
+
|
|
3389
|
+
/**
|
|
3390
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
3391
|
+
*/
|
|
3392
|
+
expanded?: boolean;
|
|
2217
3393
|
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
*/
|
|
2223
|
-
innerText(options?: TimeoutOptions): Promise<string>;
|
|
3394
|
+
/**
|
|
3395
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
3396
|
+
*/
|
|
3397
|
+
pressed?: boolean;
|
|
2224
3398
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
3399
|
+
/**
|
|
3400
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
3401
|
+
*/
|
|
3402
|
+
selected?: boolean;
|
|
3403
|
+
},
|
|
3404
|
+
): Locator;
|
|
2231
3405
|
|
|
2232
3406
|
/**
|
|
2233
|
-
* Returns
|
|
3407
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
3408
|
+
*
|
|
3409
|
+
* @example
|
|
3410
|
+
* ```js
|
|
3411
|
+
* const locator = locator.getByAltText('pizza');
|
|
3412
|
+
*
|
|
3413
|
+
* await locator.click();
|
|
3414
|
+
* ```
|
|
3415
|
+
*
|
|
3416
|
+
* @param altText The alt text of the element.
|
|
2234
3417
|
* @param options Options to use.
|
|
2235
|
-
* @returns The
|
|
3418
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
2236
3419
|
*/
|
|
2237
|
-
|
|
3420
|
+
getByAltText(
|
|
3421
|
+
altText: string | RegExp,
|
|
3422
|
+
options?: {
|
|
3423
|
+
/**
|
|
3424
|
+
* Whether the locator should be exact.
|
|
3425
|
+
*
|
|
3426
|
+
* @defaultValue false
|
|
3427
|
+
*/
|
|
3428
|
+
exact?: boolean;
|
|
3429
|
+
},
|
|
3430
|
+
): Locator;
|
|
2238
3431
|
|
|
2239
3432
|
/**
|
|
2240
|
-
* Returns
|
|
2241
|
-
*
|
|
2242
|
-
* **Usage**
|
|
3433
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2243
3434
|
*
|
|
3435
|
+
* @example
|
|
2244
3436
|
* ```js
|
|
2245
|
-
* const
|
|
3437
|
+
* const locator = locator.getByLabel('Password');
|
|
3438
|
+
*
|
|
3439
|
+
* await locator.fill('my-password');
|
|
2246
3440
|
* ```
|
|
2247
3441
|
*
|
|
2248
|
-
* @
|
|
3442
|
+
* @param label The label text of the element.
|
|
3443
|
+
* @param options Options to use.
|
|
3444
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2249
3445
|
*/
|
|
2250
|
-
|
|
3446
|
+
getByLabel(
|
|
3447
|
+
label: string | RegExp,
|
|
3448
|
+
options?: {
|
|
3449
|
+
/**
|
|
3450
|
+
* Whether the locator should be exact.
|
|
3451
|
+
*
|
|
3452
|
+
* @defaultValue false
|
|
3453
|
+
*/
|
|
3454
|
+
exact?: boolean;
|
|
3455
|
+
},
|
|
3456
|
+
): Locator;
|
|
2251
3457
|
|
|
2252
3458
|
/**
|
|
2253
|
-
*
|
|
3459
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
2254
3460
|
*
|
|
2255
|
-
*
|
|
3461
|
+
* Consider the following DOM structure:
|
|
2256
3462
|
*
|
|
2257
|
-
* ```
|
|
2258
|
-
*
|
|
3463
|
+
* ```html
|
|
3464
|
+
* <div>Hello <span>world</span></div>
|
|
3465
|
+
* <div>Hello</div>
|
|
2259
3466
|
* ```
|
|
2260
3467
|
*
|
|
2261
|
-
*
|
|
2262
|
-
* @returns Locator
|
|
2263
|
-
*/
|
|
2264
|
-
nth(index: number): Locator;
|
|
2265
|
-
|
|
2266
|
-
/**
|
|
2267
|
-
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
2268
|
-
* otherwise only the first option matching one of the passed options is selected.
|
|
3468
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
2269
3469
|
*
|
|
2270
3470
|
* @example
|
|
2271
3471
|
* ```js
|
|
2272
|
-
* //
|
|
2273
|
-
* locator.
|
|
3472
|
+
* // Matches <span>
|
|
3473
|
+
* locator.getByText('world');
|
|
2274
3474
|
*
|
|
2275
|
-
* //
|
|
2276
|
-
* locator.
|
|
3475
|
+
* // Matches first <div>
|
|
3476
|
+
* locator.getByText('Hello world');
|
|
2277
3477
|
*
|
|
2278
|
-
* //
|
|
2279
|
-
* locator.
|
|
3478
|
+
* // Matches second <div>
|
|
3479
|
+
* locator.getByText('Hello', { exact: true });
|
|
3480
|
+
*
|
|
3481
|
+
* // Matches both <div>s
|
|
3482
|
+
* locator.getByText(/Hello/);
|
|
3483
|
+
*
|
|
3484
|
+
* // Matches second <div>
|
|
3485
|
+
* locator.getByText(/^hello$/i);
|
|
2280
3486
|
* ```
|
|
2281
3487
|
*
|
|
2282
|
-
*
|
|
3488
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
3489
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
3490
|
+
* and ignores leading and trailing whitespace.
|
|
3491
|
+
*
|
|
3492
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
3493
|
+
* `value` instead of the text content. For example, locating by text
|
|
3494
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
3495
|
+
*
|
|
3496
|
+
* @param text Text to locate the element by.
|
|
2283
3497
|
* @param options Options to use.
|
|
2284
|
-
* @returns
|
|
2285
|
-
*/
|
|
2286
|
-
selectOption(
|
|
2287
|
-
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
2288
|
-
options?: ElementHandleOptions,
|
|
2289
|
-
): Promise<string[]>;
|
|
2290
|
-
|
|
2291
|
-
/**
|
|
2292
|
-
* Checks or unchecks the input checkbox element.
|
|
2293
|
-
* @param checked Whether to check or uncheck the element.
|
|
2294
|
-
* @param options Options to customize the check action.
|
|
2295
|
-
* @returns A promise that resolves when the element is checked or unchecked.
|
|
2296
|
-
*/
|
|
2297
|
-
setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
|
|
2298
|
-
|
|
2299
|
-
/**
|
|
2300
|
-
* Press a single key on the keyboard or a combination of keys.
|
|
2301
|
-
* A superset of the key values can be found [here](https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values).
|
|
2302
|
-
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
|
|
2303
|
-
* @param options Keyboard press options.
|
|
2304
|
-
*/
|
|
2305
|
-
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2306
|
-
|
|
2307
|
-
/**
|
|
2308
|
-
* Type a text into the input field.
|
|
2309
|
-
* @param text Text to type into the input field.
|
|
2310
|
-
* @param options Typing options.
|
|
3498
|
+
* @returns The locator to the element with the corresponding text content.
|
|
2311
3499
|
*/
|
|
2312
|
-
|
|
3500
|
+
getByText(
|
|
3501
|
+
text: string | RegExp,
|
|
3502
|
+
options?: {
|
|
3503
|
+
/**
|
|
3504
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
3505
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
3506
|
+
* Note that exact match still trims whitespace.
|
|
3507
|
+
*
|
|
3508
|
+
* @defaultValue false
|
|
3509
|
+
*/
|
|
3510
|
+
exact?: boolean;
|
|
3511
|
+
},
|
|
3512
|
+
): Locator;
|
|
2313
3513
|
|
|
2314
3514
|
/**
|
|
2315
|
-
*
|
|
2316
|
-
*
|
|
3515
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
3516
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
3517
|
+
*
|
|
3518
|
+
* @example
|
|
3519
|
+
* HTML:
|
|
3520
|
+
* ```html
|
|
3521
|
+
* <button data-testid="submit-button">Submit</button>
|
|
3522
|
+
* ```
|
|
3523
|
+
*
|
|
3524
|
+
* JavaScript:
|
|
3525
|
+
* ```js
|
|
3526
|
+
* const locator = locator.getByTestId('submit-button');
|
|
3527
|
+
*
|
|
3528
|
+
* await locator.click();
|
|
3529
|
+
* ```
|
|
3530
|
+
*
|
|
3531
|
+
* @param testId The test ID of the element.
|
|
3532
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2317
3533
|
*/
|
|
2318
|
-
|
|
3534
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2319
3535
|
|
|
2320
3536
|
/**
|
|
2321
|
-
*
|
|
3537
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
3538
|
+
*
|
|
3539
|
+
* @example
|
|
3540
|
+
* ```js
|
|
3541
|
+
* const locator = locator.getByPlaceholder('name@example.com');
|
|
3542
|
+
*
|
|
3543
|
+
* await locator.fill('my.name@example.com');
|
|
3544
|
+
* ```
|
|
3545
|
+
*
|
|
3546
|
+
* @param placeholder The placeholder text of the element.
|
|
2322
3547
|
* @param options Options to use.
|
|
3548
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2323
3549
|
*/
|
|
2324
|
-
|
|
3550
|
+
getByPlaceholder(
|
|
3551
|
+
placeholder: string | RegExp,
|
|
3552
|
+
options?: {
|
|
3553
|
+
/**
|
|
3554
|
+
* Whether the locator should be exact.
|
|
3555
|
+
*
|
|
3556
|
+
* @defaultValue false
|
|
3557
|
+
*/
|
|
3558
|
+
exact?: boolean;
|
|
3559
|
+
},
|
|
3560
|
+
): Locator;
|
|
2325
3561
|
|
|
2326
3562
|
/**
|
|
2327
|
-
*
|
|
2328
|
-
*
|
|
2329
|
-
* @
|
|
3563
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
3564
|
+
*
|
|
3565
|
+
* @example
|
|
3566
|
+
* ```js
|
|
3567
|
+
* const locator = locator.getByTitle('Information box');
|
|
3568
|
+
*
|
|
3569
|
+
* await locator.click();
|
|
3570
|
+
* ```
|
|
3571
|
+
*
|
|
3572
|
+
* @param title The title text of the element.
|
|
2330
3573
|
* @param options Options to use.
|
|
3574
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2331
3575
|
*/
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
3576
|
+
getByTitle(
|
|
3577
|
+
title: string | RegExp,
|
|
3578
|
+
options?: {
|
|
3579
|
+
/**
|
|
3580
|
+
* Whether the locator should be exact.
|
|
3581
|
+
*
|
|
3582
|
+
* @defaultValue false
|
|
3583
|
+
*/
|
|
3584
|
+
exact?: boolean;
|
|
3585
|
+
},
|
|
3586
|
+
): Locator;
|
|
2339
3587
|
}
|
|
2340
3588
|
|
|
2341
3589
|
/**
|
|
@@ -3487,9 +4735,18 @@ export interface Page {
|
|
|
3487
4735
|
* when the action takes place, which means locators can span over navigations
|
|
3488
4736
|
* where the underlying dom changes.
|
|
3489
4737
|
*
|
|
4738
|
+
* @example
|
|
4739
|
+
* ```js
|
|
4740
|
+
* const textbox = page.locator('#text1');
|
|
4741
|
+
*
|
|
4742
|
+
* // Create a locator with text filtering options
|
|
4743
|
+
* const submitButton = page.locator('button', { hasText: 'Pizza, Please!' });
|
|
4744
|
+
* ```
|
|
4745
|
+
*
|
|
3490
4746
|
* @param selector A selector to use when resolving DOM element.
|
|
4747
|
+
* @param options Options to use for filtering.
|
|
3491
4748
|
*/
|
|
3492
|
-
locator(selector: string): Locator;
|
|
4749
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
3493
4750
|
|
|
3494
4751
|
/**
|
|
3495
4752
|
* The page's main frame. Page is made up of frames in a hierarchical. At the
|
|
@@ -4334,6 +5591,36 @@ export interface Page {
|
|
|
4334
5591
|
},
|
|
4335
5592
|
): Promise<void>;
|
|
4336
5593
|
|
|
5594
|
+
/**
|
|
5595
|
+
* Waits for the page to match against the URL for a Response object
|
|
5596
|
+
*
|
|
5597
|
+
* @example
|
|
5598
|
+
* ```js
|
|
5599
|
+
* const responsePromise = page.waitForResponse('https://example.com/resource');
|
|
5600
|
+
* await page.goto('https://example.com/resource');
|
|
5601
|
+
* const response = await responsePromise;
|
|
5602
|
+
* ```
|
|
5603
|
+
*
|
|
5604
|
+
* @param response Request URL string or regex to match against Response object.
|
|
5605
|
+
* @param options Options to use.
|
|
5606
|
+
*/
|
|
5607
|
+
waitForResponse(
|
|
5608
|
+
response: string | RegExp,
|
|
5609
|
+
options?: {
|
|
5610
|
+
/**
|
|
5611
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds.
|
|
5612
|
+
* The default value can be changed via the
|
|
5613
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
5614
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
5615
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
5616
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
5617
|
+
*
|
|
5618
|
+
* Setting the value to `0` will disable the timeout.
|
|
5619
|
+
*/
|
|
5620
|
+
timeout?: number;
|
|
5621
|
+
},
|
|
5622
|
+
): Promise<Response | null>;
|
|
5623
|
+
|
|
4337
5624
|
/**
|
|
4338
5625
|
* **NOTE** Use web assertions that assert visibility or a locator-based
|
|
4339
5626
|
* locator.waitFor([options]) instead.
|