@types/k6 1.1.1 → 1.3.0
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 +2028 -236
- k6/net/grpc/index.d.ts +29 -0
- k6/package.json +8 -3
k6/browser/index.d.ts
CHANGED
|
@@ -1377,6 +1377,19 @@ export interface ElementHandle extends JSHandle {
|
|
|
1377
1377
|
|
|
1378
1378
|
/**
|
|
1379
1379
|
* Select one or more options of a `<select>` element which match the values.
|
|
1380
|
+
*
|
|
1381
|
+
* @example
|
|
1382
|
+
* ```js
|
|
1383
|
+
* // Single selection matching the value or label
|
|
1384
|
+
* handle.selectOption('blue');
|
|
1385
|
+
*
|
|
1386
|
+
* // single selection matching the label
|
|
1387
|
+
* handle.selectOption({ label: 'Blue' });
|
|
1388
|
+
*
|
|
1389
|
+
* // multiple selection
|
|
1390
|
+
* handle.selectOption(['red', 'green', 'blue']);
|
|
1391
|
+
* ```
|
|
1392
|
+
*
|
|
1380
1393
|
* @param values Values of options to select.
|
|
1381
1394
|
* @param options Element handle options.
|
|
1382
1395
|
* @returns List of selected options.
|
|
@@ -1567,6 +1580,19 @@ export interface Frame {
|
|
|
1567
1580
|
/**
|
|
1568
1581
|
* Select the given options and return the array of option values of the first element
|
|
1569
1582
|
* found that matches the selector.
|
|
1583
|
+
*
|
|
1584
|
+
* @example
|
|
1585
|
+
* ```js
|
|
1586
|
+
* // Single selection matching the value or label
|
|
1587
|
+
* frame.selectOption('blue');
|
|
1588
|
+
*
|
|
1589
|
+
* // single selection matching the label
|
|
1590
|
+
* frame.selectOption({ label: 'Blue' });
|
|
1591
|
+
*
|
|
1592
|
+
* // multiple selection
|
|
1593
|
+
* frame.selectOption(['red', 'green', 'blue']);
|
|
1594
|
+
* ```
|
|
1595
|
+
*
|
|
1570
1596
|
* @param selector The selector to use.
|
|
1571
1597
|
* @param values The values to select.
|
|
1572
1598
|
* @returns The array of option values of the first element found.
|
|
@@ -1693,10 +1719,18 @@ export interface Frame {
|
|
|
1693
1719
|
|
|
1694
1720
|
/**
|
|
1695
1721
|
* Сreates and returns a new locator for this frame.
|
|
1722
|
+
*
|
|
1723
|
+
* @example
|
|
1724
|
+
* ```js
|
|
1725
|
+
* const frame = page.frames()[1];
|
|
1726
|
+
* const submitButton = frame.locator('button', { hasText: 'Pizza, Please!' });
|
|
1727
|
+
* ```
|
|
1728
|
+
*
|
|
1696
1729
|
* @param selector The selector to use.
|
|
1730
|
+
* @param options Options to use for filtering.
|
|
1697
1731
|
* @returns The new locator.
|
|
1698
1732
|
*/
|
|
1699
|
-
locator(selector: string): Locator;
|
|
1733
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
1700
1734
|
|
|
1701
1735
|
/**
|
|
1702
1736
|
* Get the `innerHTML` attribute of the first element found that matches the selector.
|
|
@@ -1841,7 +1875,83 @@ export interface Frame {
|
|
|
1841
1875
|
* @param options The options to use.
|
|
1842
1876
|
* @returns A promise that resolves to the response of the navigation when it happens.
|
|
1843
1877
|
*/
|
|
1844
|
-
waitForNavigation(options?:
|
|
1878
|
+
waitForNavigation(options?: {
|
|
1879
|
+
/**
|
|
1880
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds. The
|
|
1881
|
+
* default value can be changed via the
|
|
1882
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
1883
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
1884
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
1885
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
1886
|
+
*
|
|
1887
|
+
* Setting the value to `0` will disable the timeout.
|
|
1888
|
+
*/
|
|
1889
|
+
timeout?: number;
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* An exact string or regex pattern to match while waiting for the
|
|
1893
|
+
* navigation. Note that if the parameter is a string, the method will
|
|
1894
|
+
* wait for navigation to URL that is exactly equal to the string.
|
|
1895
|
+
*/
|
|
1896
|
+
url?: string | RegExp;
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
1900
|
+
* either:
|
|
1901
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
1902
|
+
* `DOMContentLoaded` event is fired.
|
|
1903
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
1904
|
+
* fired.
|
|
1905
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
1906
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
1907
|
+
* this method for testing especially with chatty websites where the event
|
|
1908
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
1909
|
+
*/
|
|
1910
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
1911
|
+
}): Promise<Response | null>;
|
|
1912
|
+
|
|
1913
|
+
/**
|
|
1914
|
+
* Waits for the page to navigate to the specified URL.
|
|
1915
|
+
*
|
|
1916
|
+
* @example
|
|
1917
|
+
* ```js
|
|
1918
|
+
* await page.locator('a[href="/login"]').click();
|
|
1919
|
+
* await page.waitForURL(/.*\/login$/);
|
|
1920
|
+
* ```
|
|
1921
|
+
*
|
|
1922
|
+
* @param url An exact match or regular expression to match the URL.
|
|
1923
|
+
* @param options Options to use.
|
|
1924
|
+
*/
|
|
1925
|
+
waitForURL(
|
|
1926
|
+
url: string | RegExp,
|
|
1927
|
+
options?: {
|
|
1928
|
+
/**
|
|
1929
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds.
|
|
1930
|
+
* The default value can be changed via the
|
|
1931
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
1932
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
1933
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
1934
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
1935
|
+
*
|
|
1936
|
+
* Setting the value to `0` will disable the timeout.
|
|
1937
|
+
*/
|
|
1938
|
+
timeout?: number;
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
1942
|
+
* either:
|
|
1943
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
1944
|
+
* `DOMContentLoaded` event is fired.
|
|
1945
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
1946
|
+
* fired.
|
|
1947
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
1948
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
1949
|
+
* this method for testing especially with chatty websites where the event
|
|
1950
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
1951
|
+
*/
|
|
1952
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
1953
|
+
},
|
|
1954
|
+
): Promise<void>;
|
|
1845
1955
|
|
|
1846
1956
|
/**
|
|
1847
1957
|
* Wait for the given selector to match the waiting criteria.
|
|
@@ -1859,145 +1969,894 @@ export interface Frame {
|
|
|
1859
1969
|
* @param timeout The timeout to wait for.
|
|
1860
1970
|
*/
|
|
1861
1971
|
waitForTimeout(timeout: number): Promise<void>;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
/**
|
|
1865
|
-
* JSHandle represents an in-page JavaScript object.
|
|
1866
|
-
*/
|
|
1867
|
-
export interface JSHandle<T = any> {
|
|
1868
|
-
/**
|
|
1869
|
-
* Returns either `null` or the object handle itself, if the object handle is
|
|
1870
|
-
* an instance of `ElementHandle`.
|
|
1871
|
-
* @returns The ElementHandle if available.
|
|
1872
|
-
*/
|
|
1873
|
-
asElement(): Promise<ElementHandle | null>;
|
|
1874
1972
|
|
|
1875
1973
|
/**
|
|
1876
|
-
*
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
*
|
|
1882
|
-
*
|
|
1883
|
-
*
|
|
1884
|
-
*
|
|
1885
|
-
* @
|
|
1886
|
-
|
|
1887
|
-
|
|
1974
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
1975
|
+
*
|
|
1976
|
+
* @example
|
|
1977
|
+
* ```js
|
|
1978
|
+
* const locator = frame.getByRole('button', { name: 'Pizza, Please!' });
|
|
1979
|
+
*
|
|
1980
|
+
* await locator.click();
|
|
1981
|
+
* ```
|
|
1982
|
+
*
|
|
1983
|
+
* @param role The role of the element.
|
|
1984
|
+
* @param options Options to use.
|
|
1985
|
+
* @returns The locator to the element with the corresponding role.
|
|
1986
|
+
*/
|
|
1987
|
+
getByRole(
|
|
1988
|
+
role:
|
|
1989
|
+
| "alert"
|
|
1990
|
+
| "alertdialog"
|
|
1991
|
+
| "application"
|
|
1992
|
+
| "article"
|
|
1993
|
+
| "banner"
|
|
1994
|
+
| "blockquote"
|
|
1995
|
+
| "button"
|
|
1996
|
+
| "caption"
|
|
1997
|
+
| "cell"
|
|
1998
|
+
| "checkbox"
|
|
1999
|
+
| "code"
|
|
2000
|
+
| "columnheader"
|
|
2001
|
+
| "combobox"
|
|
2002
|
+
| "complementary"
|
|
2003
|
+
| "contentinfo"
|
|
2004
|
+
| "definition"
|
|
2005
|
+
| "dialog"
|
|
2006
|
+
| "directory"
|
|
2007
|
+
| "document"
|
|
2008
|
+
| "emphasis"
|
|
2009
|
+
| "feed"
|
|
2010
|
+
| "figure"
|
|
2011
|
+
| "form"
|
|
2012
|
+
| "generic"
|
|
2013
|
+
| "grid"
|
|
2014
|
+
| "gridcell"
|
|
2015
|
+
| "group"
|
|
2016
|
+
| "heading"
|
|
2017
|
+
| "img"
|
|
2018
|
+
| "insertion"
|
|
2019
|
+
| "link"
|
|
2020
|
+
| "list"
|
|
2021
|
+
| "listbox"
|
|
2022
|
+
| "listitem"
|
|
2023
|
+
| "log"
|
|
2024
|
+
| "main"
|
|
2025
|
+
| "marquee"
|
|
2026
|
+
| "math"
|
|
2027
|
+
| "menu"
|
|
2028
|
+
| "menubar"
|
|
2029
|
+
| "menuitem"
|
|
2030
|
+
| "menuitemcheckbox"
|
|
2031
|
+
| "menuitemradio"
|
|
2032
|
+
| "meter"
|
|
2033
|
+
| "navigation"
|
|
2034
|
+
| "none"
|
|
2035
|
+
| "note"
|
|
2036
|
+
| "option"
|
|
2037
|
+
| "presentation"
|
|
2038
|
+
| "progressbar"
|
|
2039
|
+
| "radio"
|
|
2040
|
+
| "radiogroup"
|
|
2041
|
+
| "region"
|
|
2042
|
+
| "row"
|
|
2043
|
+
| "rowgroup"
|
|
2044
|
+
| "rowheader"
|
|
2045
|
+
| "scrollbar"
|
|
2046
|
+
| "search"
|
|
2047
|
+
| "searchbox"
|
|
2048
|
+
| "separator"
|
|
2049
|
+
| "slider"
|
|
2050
|
+
| "spinbutton"
|
|
2051
|
+
| "status"
|
|
2052
|
+
| "strong"
|
|
2053
|
+
| "subscript"
|
|
2054
|
+
| "superscript"
|
|
2055
|
+
| "switch"
|
|
2056
|
+
| "tab"
|
|
2057
|
+
| "table"
|
|
2058
|
+
| "tablist"
|
|
2059
|
+
| "tabpanel"
|
|
2060
|
+
| "term"
|
|
2061
|
+
| "textbox"
|
|
2062
|
+
| "time"
|
|
2063
|
+
| "timer"
|
|
2064
|
+
| "toolbar"
|
|
2065
|
+
| "tooltip"
|
|
2066
|
+
| "tree"
|
|
2067
|
+
| "treegrid"
|
|
2068
|
+
| "treeitem",
|
|
2069
|
+
options?: {
|
|
2070
|
+
/**
|
|
2071
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
2072
|
+
*
|
|
2073
|
+
* @defaultValue false
|
|
2074
|
+
*/
|
|
2075
|
+
exact?: boolean;
|
|
1888
2076
|
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
* @returns A JSHandle of the return value of `pageFunction`.
|
|
1896
|
-
*/
|
|
1897
|
-
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
2077
|
+
/**
|
|
2078
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
2079
|
+
*
|
|
2080
|
+
* @defaultValue false
|
|
2081
|
+
*/
|
|
2082
|
+
includeHidden?: boolean;
|
|
1898
2083
|
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
*/
|
|
1904
|
-
getProperties(): Promise<Map<string, JSHandle>>;
|
|
2084
|
+
/**
|
|
2085
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
2086
|
+
*/
|
|
2087
|
+
level?: number;
|
|
1905
2088
|
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
jsonValue(): Promise<any>;
|
|
1911
|
-
}
|
|
2089
|
+
/**
|
|
2090
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
2091
|
+
*/
|
|
2092
|
+
name?: string | RegExp;
|
|
1912
2093
|
|
|
1913
|
-
/**
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
/**
|
|
1918
|
-
* Sends a key down message to a session target.
|
|
1919
|
-
* 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).
|
|
1920
|
-
* @param key Name of key to press, such as `ArrowLeft`.
|
|
1921
|
-
*/
|
|
1922
|
-
down(key: string): Promise<void>;
|
|
2094
|
+
/**
|
|
2095
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
2096
|
+
*/
|
|
2097
|
+
checked?: boolean;
|
|
1923
2098
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
*/
|
|
1929
|
-
insertText(text: string): Promise<void>;
|
|
2099
|
+
/**
|
|
2100
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
2101
|
+
*/
|
|
2102
|
+
disabled?: boolean;
|
|
1930
2103
|
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
* @param options Specifies the typing options.
|
|
1936
|
-
*/
|
|
1937
|
-
press(key: string, options?: { delay?: number }): Promise<void>;
|
|
2104
|
+
/**
|
|
2105
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
2106
|
+
*/
|
|
2107
|
+
expanded?: boolean;
|
|
1938
2108
|
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
* Modifier keys `Shift`, `Control`, `Alt`, `Meta` are _not_ respected.
|
|
1944
|
-
* @param text A text to type into a focused element.
|
|
1945
|
-
* @param options Specifies the typing options.
|
|
1946
|
-
*/
|
|
1947
|
-
type(text: string, options?: { delay?: number }): Promise<void>;
|
|
2109
|
+
/**
|
|
2110
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
2111
|
+
*/
|
|
2112
|
+
pressed?: boolean;
|
|
1948
2113
|
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
}
|
|
2114
|
+
/**
|
|
2115
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
2116
|
+
*/
|
|
2117
|
+
selected?: boolean;
|
|
2118
|
+
},
|
|
2119
|
+
): Locator;
|
|
1956
2120
|
|
|
1957
|
-
/**
|
|
1958
|
-
* The Locator API makes it easier to work with dynamically changing elements.
|
|
1959
|
-
* Some of the benefits of using it over existing ways to locate an element
|
|
1960
|
-
* (e.g. Page.$()) include:
|
|
1961
|
-
*
|
|
1962
|
-
* - Helps with writing robust tests by finding an element even if the
|
|
1963
|
-
* underlying frame navigates.
|
|
1964
|
-
* - Makes it easier to work with dynamic web pages and SPAs built with Svelte,
|
|
1965
|
-
* React, Vue, etc.
|
|
1966
|
-
*/
|
|
1967
|
-
export interface Locator {
|
|
1968
2121
|
/**
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
1971
|
-
* **Usage**
|
|
2122
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
1972
2123
|
*
|
|
2124
|
+
* @example
|
|
1973
2125
|
* ```js
|
|
1974
|
-
*
|
|
1975
|
-
*
|
|
2126
|
+
* const locator = frame.getByAltText('pizza');
|
|
2127
|
+
*
|
|
2128
|
+
* await locator.click();
|
|
1976
2129
|
* ```
|
|
1977
2130
|
*
|
|
2131
|
+
* @param altText The alt text of the element.
|
|
1978
2132
|
* @param options Options to use.
|
|
2133
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
1979
2134
|
*/
|
|
1980
|
-
|
|
2135
|
+
getByAltText(
|
|
2136
|
+
altText: string | RegExp,
|
|
2137
|
+
options?: {
|
|
2138
|
+
/**
|
|
2139
|
+
* Whether the locator should be exact.
|
|
2140
|
+
*
|
|
2141
|
+
* @defaultValue false
|
|
2142
|
+
*/
|
|
2143
|
+
exact?: boolean;
|
|
2144
|
+
},
|
|
2145
|
+
): Locator;
|
|
1981
2146
|
|
|
1982
2147
|
/**
|
|
1983
|
-
*
|
|
2148
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2149
|
+
*
|
|
2150
|
+
* @example
|
|
2151
|
+
* ```js
|
|
2152
|
+
* const locator = frame.getByLabel('Password');
|
|
2153
|
+
*
|
|
2154
|
+
* await locator.fill('my-password');
|
|
2155
|
+
* ```
|
|
2156
|
+
*
|
|
2157
|
+
* @param label The label text of the element.
|
|
1984
2158
|
* @param options Options to use.
|
|
1985
|
-
* @returns
|
|
2159
|
+
* @returns The locator to the element with the corresponding label text.
|
|
1986
2160
|
*/
|
|
1987
|
-
|
|
2161
|
+
getByLabel(
|
|
2162
|
+
label: string | RegExp,
|
|
2163
|
+
options?: {
|
|
2164
|
+
/**
|
|
2165
|
+
* Whether the locator should be exact.
|
|
2166
|
+
*
|
|
2167
|
+
* @defaultValue false
|
|
2168
|
+
*/
|
|
2169
|
+
exact?: boolean;
|
|
2170
|
+
},
|
|
2171
|
+
): Locator;
|
|
1988
2172
|
|
|
1989
2173
|
/**
|
|
1990
|
-
*
|
|
2174
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
1991
2175
|
*
|
|
1992
|
-
*
|
|
2176
|
+
* Consider the following DOM structure:
|
|
2177
|
+
*
|
|
2178
|
+
* ```html
|
|
2179
|
+
* <div>Hello <span>world</span></div>
|
|
2180
|
+
* <div>Hello</div>
|
|
2181
|
+
* ```
|
|
2182
|
+
*
|
|
2183
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
1993
2184
|
*
|
|
2185
|
+
* @example
|
|
1994
2186
|
* ```js
|
|
1995
|
-
*
|
|
2187
|
+
* // Matches <span>
|
|
2188
|
+
* frame.getByText('world');
|
|
2189
|
+
*
|
|
2190
|
+
* // Matches first <div>
|
|
2191
|
+
* frame.getByText('Hello world');
|
|
2192
|
+
*
|
|
2193
|
+
* // Matches second <div>
|
|
2194
|
+
* frame.getByText('Hello', { exact: true });
|
|
2195
|
+
*
|
|
2196
|
+
* // Matches both <div>s
|
|
2197
|
+
* frame.getByText(/Hello/);
|
|
2198
|
+
*
|
|
2199
|
+
* // Matches second <div>
|
|
2200
|
+
* frame.getByText(/^hello$/i);
|
|
1996
2201
|
* ```
|
|
1997
2202
|
*
|
|
1998
|
-
*
|
|
2203
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
2204
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
2205
|
+
* and ignores leading and trailing whitespace.
|
|
2206
|
+
*
|
|
2207
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
2208
|
+
* `value` instead of the text content. For example, locating by text
|
|
2209
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
2210
|
+
*
|
|
2211
|
+
* @param text Text to locate the element by.
|
|
2212
|
+
* @param options Options to use.
|
|
2213
|
+
* @returns The locator to the element with the corresponding text content.
|
|
1999
2214
|
*/
|
|
2000
|
-
|
|
2215
|
+
getByText(
|
|
2216
|
+
text: string | RegExp,
|
|
2217
|
+
options?: {
|
|
2218
|
+
/**
|
|
2219
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
2220
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
2221
|
+
* Note that exact match still trims whitespace.
|
|
2222
|
+
*
|
|
2223
|
+
* @defaultValue false
|
|
2224
|
+
*/
|
|
2225
|
+
exact?: boolean;
|
|
2226
|
+
},
|
|
2227
|
+
): Locator;
|
|
2228
|
+
|
|
2229
|
+
/**
|
|
2230
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
2231
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
2232
|
+
*
|
|
2233
|
+
* @example
|
|
2234
|
+
* HTML:
|
|
2235
|
+
* ```html
|
|
2236
|
+
* <button data-testid="submit-button">Submit</button>
|
|
2237
|
+
* ```
|
|
2238
|
+
*
|
|
2239
|
+
* JavaScript:
|
|
2240
|
+
* ```js
|
|
2241
|
+
* const locator = frame.getByTestId('submit-button');
|
|
2242
|
+
*
|
|
2243
|
+
* await locator.click();
|
|
2244
|
+
* ```
|
|
2245
|
+
*
|
|
2246
|
+
* @param testId The test ID of the element.
|
|
2247
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2248
|
+
*/
|
|
2249
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2250
|
+
|
|
2251
|
+
/**
|
|
2252
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
2253
|
+
*
|
|
2254
|
+
* @example
|
|
2255
|
+
* ```js
|
|
2256
|
+
* const locator = frame.getByPlaceholder('name@example.com');
|
|
2257
|
+
*
|
|
2258
|
+
* await locator.fill('my.name@example.com');
|
|
2259
|
+
* ```
|
|
2260
|
+
*
|
|
2261
|
+
* @param placeholder The placeholder text of the element.
|
|
2262
|
+
* @param options Options to use.
|
|
2263
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2264
|
+
*/
|
|
2265
|
+
getByPlaceholder(
|
|
2266
|
+
placeholder: string | RegExp,
|
|
2267
|
+
options?: {
|
|
2268
|
+
/**
|
|
2269
|
+
* Whether the locator should be exact.
|
|
2270
|
+
*
|
|
2271
|
+
* @defaultValue false
|
|
2272
|
+
*/
|
|
2273
|
+
exact?: boolean;
|
|
2274
|
+
},
|
|
2275
|
+
): Locator;
|
|
2276
|
+
|
|
2277
|
+
/**
|
|
2278
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
2279
|
+
*
|
|
2280
|
+
* @example
|
|
2281
|
+
* ```js
|
|
2282
|
+
* const locator = frame.getByTitle('Information box');
|
|
2283
|
+
*
|
|
2284
|
+
* await locator.click();
|
|
2285
|
+
* ```
|
|
2286
|
+
*
|
|
2287
|
+
* @param title The title text of the element.
|
|
2288
|
+
* @param options Options to use.
|
|
2289
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2290
|
+
*/
|
|
2291
|
+
getByTitle(
|
|
2292
|
+
title: string | RegExp,
|
|
2293
|
+
options?: {
|
|
2294
|
+
/**
|
|
2295
|
+
* Whether the locator should be exact.
|
|
2296
|
+
*
|
|
2297
|
+
* @defaultValue false
|
|
2298
|
+
*/
|
|
2299
|
+
exact?: boolean;
|
|
2300
|
+
},
|
|
2301
|
+
): Locator;
|
|
2302
|
+
}
|
|
2303
|
+
|
|
2304
|
+
/**
|
|
2305
|
+
* FrameLocator makes it easier to locate elements within an `iframe` on the
|
|
2306
|
+
* page. `FrameLocator` are created by calling `page.locator(selector).contentFrame()`.
|
|
2307
|
+
* It works in the same way as `Locator` instances.
|
|
2308
|
+
*/
|
|
2309
|
+
export interface FrameLocator {
|
|
2310
|
+
/**
|
|
2311
|
+
* The method finds all elements matching the selector and creates a new
|
|
2312
|
+
* locator that matches all of them. This method can be used to further
|
|
2313
|
+
* refine the locator by chaining additional selectors.
|
|
2314
|
+
*
|
|
2315
|
+
* @example
|
|
2316
|
+
* ```js
|
|
2317
|
+
* const frame = page.frameLocator('iframe');
|
|
2318
|
+
* const rows = frame.locator('table tr');
|
|
2319
|
+
* const cell = rows.locator('.selected');
|
|
2320
|
+
*
|
|
2321
|
+
* // Use with options to filter by text
|
|
2322
|
+
* const submitButton = frame.locator('button', { hasText: 'Submit' });
|
|
2323
|
+
* ```
|
|
2324
|
+
*
|
|
2325
|
+
* @param selector A selector to use when resolving DOM element.
|
|
2326
|
+
* @param options Options to use for filtering.
|
|
2327
|
+
* @returns The new locator.
|
|
2328
|
+
*/
|
|
2329
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
2330
|
+
|
|
2331
|
+
/**
|
|
2332
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
2333
|
+
*
|
|
2334
|
+
* @example
|
|
2335
|
+
* ```js
|
|
2336
|
+
* const locator = frameLocator.getByRole('button', { name: 'Pizza, Please!' });
|
|
2337
|
+
*
|
|
2338
|
+
* await locator.click();
|
|
2339
|
+
* ```
|
|
2340
|
+
*
|
|
2341
|
+
* @param role The role of the element.
|
|
2342
|
+
* @param options Options to use.
|
|
2343
|
+
* @returns The locator to the element with the corresponding role.
|
|
2344
|
+
*/
|
|
2345
|
+
getByRole(
|
|
2346
|
+
role:
|
|
2347
|
+
| "alert"
|
|
2348
|
+
| "alertdialog"
|
|
2349
|
+
| "application"
|
|
2350
|
+
| "article"
|
|
2351
|
+
| "banner"
|
|
2352
|
+
| "blockquote"
|
|
2353
|
+
| "button"
|
|
2354
|
+
| "caption"
|
|
2355
|
+
| "cell"
|
|
2356
|
+
| "checkbox"
|
|
2357
|
+
| "code"
|
|
2358
|
+
| "columnheader"
|
|
2359
|
+
| "combobox"
|
|
2360
|
+
| "complementary"
|
|
2361
|
+
| "contentinfo"
|
|
2362
|
+
| "definition"
|
|
2363
|
+
| "dialog"
|
|
2364
|
+
| "directory"
|
|
2365
|
+
| "document"
|
|
2366
|
+
| "emphasis"
|
|
2367
|
+
| "feed"
|
|
2368
|
+
| "figure"
|
|
2369
|
+
| "form"
|
|
2370
|
+
| "generic"
|
|
2371
|
+
| "grid"
|
|
2372
|
+
| "gridcell"
|
|
2373
|
+
| "group"
|
|
2374
|
+
| "heading"
|
|
2375
|
+
| "img"
|
|
2376
|
+
| "insertion"
|
|
2377
|
+
| "link"
|
|
2378
|
+
| "list"
|
|
2379
|
+
| "listbox"
|
|
2380
|
+
| "listitem"
|
|
2381
|
+
| "log"
|
|
2382
|
+
| "main"
|
|
2383
|
+
| "marquee"
|
|
2384
|
+
| "math"
|
|
2385
|
+
| "menu"
|
|
2386
|
+
| "menubar"
|
|
2387
|
+
| "menuitem"
|
|
2388
|
+
| "menuitemcheckbox"
|
|
2389
|
+
| "menuitemradio"
|
|
2390
|
+
| "meter"
|
|
2391
|
+
| "navigation"
|
|
2392
|
+
| "none"
|
|
2393
|
+
| "note"
|
|
2394
|
+
| "option"
|
|
2395
|
+
| "presentation"
|
|
2396
|
+
| "progressbar"
|
|
2397
|
+
| "radio"
|
|
2398
|
+
| "radiogroup"
|
|
2399
|
+
| "region"
|
|
2400
|
+
| "row"
|
|
2401
|
+
| "rowgroup"
|
|
2402
|
+
| "rowheader"
|
|
2403
|
+
| "scrollbar"
|
|
2404
|
+
| "search"
|
|
2405
|
+
| "searchbox"
|
|
2406
|
+
| "separator"
|
|
2407
|
+
| "slider"
|
|
2408
|
+
| "spinbutton"
|
|
2409
|
+
| "status"
|
|
2410
|
+
| "strong"
|
|
2411
|
+
| "subscript"
|
|
2412
|
+
| "superscript"
|
|
2413
|
+
| "switch"
|
|
2414
|
+
| "tab"
|
|
2415
|
+
| "table"
|
|
2416
|
+
| "tablist"
|
|
2417
|
+
| "tabpanel"
|
|
2418
|
+
| "term"
|
|
2419
|
+
| "textbox"
|
|
2420
|
+
| "time"
|
|
2421
|
+
| "timer"
|
|
2422
|
+
| "toolbar"
|
|
2423
|
+
| "tooltip"
|
|
2424
|
+
| "tree"
|
|
2425
|
+
| "treegrid"
|
|
2426
|
+
| "treeitem",
|
|
2427
|
+
options?: {
|
|
2428
|
+
/**
|
|
2429
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
2430
|
+
*
|
|
2431
|
+
* @defaultValue false
|
|
2432
|
+
*/
|
|
2433
|
+
exact?: boolean;
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
2437
|
+
*
|
|
2438
|
+
* @defaultValue false
|
|
2439
|
+
*/
|
|
2440
|
+
includeHidden?: boolean;
|
|
2441
|
+
|
|
2442
|
+
/**
|
|
2443
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
2444
|
+
*/
|
|
2445
|
+
level?: number;
|
|
2446
|
+
|
|
2447
|
+
/**
|
|
2448
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
2449
|
+
*/
|
|
2450
|
+
name?: string | RegExp;
|
|
2451
|
+
|
|
2452
|
+
/**
|
|
2453
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
2454
|
+
*/
|
|
2455
|
+
checked?: boolean;
|
|
2456
|
+
|
|
2457
|
+
/**
|
|
2458
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
2459
|
+
*/
|
|
2460
|
+
disabled?: boolean;
|
|
2461
|
+
|
|
2462
|
+
/**
|
|
2463
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
2464
|
+
*/
|
|
2465
|
+
expanded?: boolean;
|
|
2466
|
+
|
|
2467
|
+
/**
|
|
2468
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
2469
|
+
*/
|
|
2470
|
+
pressed?: boolean;
|
|
2471
|
+
|
|
2472
|
+
/**
|
|
2473
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
2474
|
+
*/
|
|
2475
|
+
selected?: boolean;
|
|
2476
|
+
},
|
|
2477
|
+
): Locator;
|
|
2478
|
+
|
|
2479
|
+
/**
|
|
2480
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
2481
|
+
*
|
|
2482
|
+
* @example
|
|
2483
|
+
* ```js
|
|
2484
|
+
* const locator = frameLocator.getByAltText('pizza');
|
|
2485
|
+
*
|
|
2486
|
+
* await locator.click();
|
|
2487
|
+
* ```
|
|
2488
|
+
*
|
|
2489
|
+
* @param altText The alt text of the element.
|
|
2490
|
+
* @param options Options to use.
|
|
2491
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
2492
|
+
*/
|
|
2493
|
+
getByAltText(
|
|
2494
|
+
altText: string | RegExp,
|
|
2495
|
+
options?: {
|
|
2496
|
+
/**
|
|
2497
|
+
* Whether the locator should be exact.
|
|
2498
|
+
*
|
|
2499
|
+
* @defaultValue false
|
|
2500
|
+
*/
|
|
2501
|
+
exact?: boolean;
|
|
2502
|
+
},
|
|
2503
|
+
): Locator;
|
|
2504
|
+
|
|
2505
|
+
/**
|
|
2506
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2507
|
+
*
|
|
2508
|
+
* @example
|
|
2509
|
+
* ```js
|
|
2510
|
+
* const locator = frameLocator.getByLabel('Password');
|
|
2511
|
+
*
|
|
2512
|
+
* await locator.fill('my-password');
|
|
2513
|
+
* ```
|
|
2514
|
+
*
|
|
2515
|
+
* @param label The label text of the element.
|
|
2516
|
+
* @param options Options to use.
|
|
2517
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2518
|
+
*/
|
|
2519
|
+
getByLabel(
|
|
2520
|
+
label: string | RegExp,
|
|
2521
|
+
options?: {
|
|
2522
|
+
/**
|
|
2523
|
+
* Whether the locator should be exact.
|
|
2524
|
+
*
|
|
2525
|
+
* @defaultValue false
|
|
2526
|
+
*/
|
|
2527
|
+
exact?: boolean;
|
|
2528
|
+
},
|
|
2529
|
+
): Locator;
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
2533
|
+
*
|
|
2534
|
+
* Consider the following DOM structure:
|
|
2535
|
+
*
|
|
2536
|
+
* ```html
|
|
2537
|
+
* <div>Hello <span>world</span></div>
|
|
2538
|
+
* <div>Hello</div>
|
|
2539
|
+
* ```
|
|
2540
|
+
*
|
|
2541
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
2542
|
+
*
|
|
2543
|
+
* @example
|
|
2544
|
+
* ```js
|
|
2545
|
+
* // Matches <span>
|
|
2546
|
+
* frameLocator.getByText('world');
|
|
2547
|
+
*
|
|
2548
|
+
* // Matches first <div>
|
|
2549
|
+
* frameLocator.getByText('Hello world');
|
|
2550
|
+
*
|
|
2551
|
+
* // Matches second <div>
|
|
2552
|
+
* frameLocator.getByText('Hello', { exact: true });
|
|
2553
|
+
*
|
|
2554
|
+
* // Matches both <div>s
|
|
2555
|
+
* frameLocator.getByText(/Hello/);
|
|
2556
|
+
*
|
|
2557
|
+
* // Matches second <div>
|
|
2558
|
+
* frameLocator.getByText(/^hello$/i);
|
|
2559
|
+
* ```
|
|
2560
|
+
*
|
|
2561
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
2562
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
2563
|
+
* and ignores leading and trailing whitespace.
|
|
2564
|
+
*
|
|
2565
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
2566
|
+
* `value` instead of the text content. For example, locating by text
|
|
2567
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
2568
|
+
*
|
|
2569
|
+
* @param text Text to locate the element by.
|
|
2570
|
+
* @param options Options to use.
|
|
2571
|
+
* @returns The locator to the element with the corresponding text content.
|
|
2572
|
+
*/
|
|
2573
|
+
getByText(
|
|
2574
|
+
text: string | RegExp,
|
|
2575
|
+
options?: {
|
|
2576
|
+
/**
|
|
2577
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
2578
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
2579
|
+
* Note that exact match still trims whitespace.
|
|
2580
|
+
*
|
|
2581
|
+
* @defaultValue false
|
|
2582
|
+
*/
|
|
2583
|
+
exact?: boolean;
|
|
2584
|
+
},
|
|
2585
|
+
): Locator;
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
2589
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
2590
|
+
*
|
|
2591
|
+
* @example
|
|
2592
|
+
* HTML:
|
|
2593
|
+
* ```html
|
|
2594
|
+
* <button data-testid="submit-button">Submit</button>
|
|
2595
|
+
* ```
|
|
2596
|
+
*
|
|
2597
|
+
* JavaScript:
|
|
2598
|
+
* ```js
|
|
2599
|
+
* const locator = frameLocator.getByTestId('submit-button');
|
|
2600
|
+
*
|
|
2601
|
+
* await locator.click();
|
|
2602
|
+
* ```
|
|
2603
|
+
*
|
|
2604
|
+
* @param testId The test ID of the element.
|
|
2605
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2606
|
+
*/
|
|
2607
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
2611
|
+
*
|
|
2612
|
+
* @example
|
|
2613
|
+
* ```js
|
|
2614
|
+
* const locator = frameLocator.getByPlaceholder('name@example.com');
|
|
2615
|
+
*
|
|
2616
|
+
* await locator.fill('my.name@example.com');
|
|
2617
|
+
* ```
|
|
2618
|
+
*
|
|
2619
|
+
* @param placeholder The placeholder text of the element.
|
|
2620
|
+
* @param options Options to use.
|
|
2621
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2622
|
+
*/
|
|
2623
|
+
getByPlaceholder(
|
|
2624
|
+
placeholder: string | RegExp,
|
|
2625
|
+
options?: {
|
|
2626
|
+
/**
|
|
2627
|
+
* Whether the locator should be exact.
|
|
2628
|
+
*
|
|
2629
|
+
* @defaultValue false
|
|
2630
|
+
*/
|
|
2631
|
+
exact?: boolean;
|
|
2632
|
+
},
|
|
2633
|
+
): Locator;
|
|
2634
|
+
|
|
2635
|
+
/**
|
|
2636
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
2637
|
+
*
|
|
2638
|
+
* @example
|
|
2639
|
+
* ```js
|
|
2640
|
+
* const locator = frameLocator.getByTitle('Information box');
|
|
2641
|
+
*
|
|
2642
|
+
* await locator.click();
|
|
2643
|
+
* ```
|
|
2644
|
+
*
|
|
2645
|
+
* @param title The title text of the element.
|
|
2646
|
+
* @param options Options to use.
|
|
2647
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2648
|
+
*/
|
|
2649
|
+
getByTitle(
|
|
2650
|
+
title: string | RegExp,
|
|
2651
|
+
options?: {
|
|
2652
|
+
/**
|
|
2653
|
+
* Whether the locator should be exact.
|
|
2654
|
+
*
|
|
2655
|
+
* @defaultValue false
|
|
2656
|
+
*/
|
|
2657
|
+
exact?: boolean;
|
|
2658
|
+
},
|
|
2659
|
+
): Locator;
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
/**
|
|
2663
|
+
* JSHandle represents an in-page JavaScript object.
|
|
2664
|
+
*/
|
|
2665
|
+
export interface JSHandle<T = any> {
|
|
2666
|
+
/**
|
|
2667
|
+
* Returns either `null` or the object handle itself, if the object handle is
|
|
2668
|
+
* an instance of `ElementHandle`.
|
|
2669
|
+
* @returns The ElementHandle if available.
|
|
2670
|
+
*/
|
|
2671
|
+
asElement(): Promise<ElementHandle | null>;
|
|
2672
|
+
|
|
2673
|
+
/**
|
|
2674
|
+
* Stops referencing the element handle.
|
|
2675
|
+
*/
|
|
2676
|
+
dispose(): Promise<void>;
|
|
2677
|
+
|
|
2678
|
+
/**
|
|
2679
|
+
* Evaluates the page function and returns its return value.
|
|
2680
|
+
* This method passes this handle as the first argument to the page function.
|
|
2681
|
+
* @param pageFunction The function to be evaluated.
|
|
2682
|
+
* @param args The arguments to pass to the page function.
|
|
2683
|
+
* @returns The return value of `pageFunction`.
|
|
2684
|
+
*/
|
|
2685
|
+
evaluate<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<R>;
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* Evaluates the page function and returns a `JSHandle`.
|
|
2689
|
+
* This method passes this handle as the first argument to the page function.
|
|
2690
|
+
* Unlike `evaluate`, `evaluateHandle` returns the value as a `JSHandle`
|
|
2691
|
+
* @param pageFunction The function to be evaluated.
|
|
2692
|
+
* @param args The arguments to pass to the page function.
|
|
2693
|
+
* @returns A JSHandle of the return value of `pageFunction`.
|
|
2694
|
+
*/
|
|
2695
|
+
evaluateHandle<R, Arg>(pageFunction: PageFunction<Arg, R>, arg?: Arg): Promise<JSHandle<R>>;
|
|
2696
|
+
|
|
2697
|
+
/**
|
|
2698
|
+
* Fetches a map with own property names of of the `JSHandle` with their values as
|
|
2699
|
+
* `JSHandle` instances.
|
|
2700
|
+
* @returns A map with property names as keys and `JSHandle` instances for the property values.
|
|
2701
|
+
*/
|
|
2702
|
+
getProperties(): Promise<Map<string, JSHandle>>;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* Fetches a JSON representation of the object.
|
|
2706
|
+
* @returns A JSON representation of the object.
|
|
2707
|
+
*/
|
|
2708
|
+
jsonValue(): Promise<any>;
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
/**
|
|
2712
|
+
* Keyboard provides an API for managing a virtual keyboard.
|
|
2713
|
+
*/
|
|
2714
|
+
export interface Keyboard {
|
|
2715
|
+
/**
|
|
2716
|
+
* Sends a key down message to a session target.
|
|
2717
|
+
* 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).
|
|
2718
|
+
* @param key Name of key to press, such as `ArrowLeft`.
|
|
2719
|
+
*/
|
|
2720
|
+
down(key: string): Promise<void>;
|
|
2721
|
+
|
|
2722
|
+
/**
|
|
2723
|
+
* Dispatches an `input` event with the given `text`.
|
|
2724
|
+
* This method does not emit `keyDown`, `keyUp` or `keyPress` events.
|
|
2725
|
+
* @param text Event text.
|
|
2726
|
+
*/
|
|
2727
|
+
insertText(text: string): Promise<void>;
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* Sends a key press message to a session target.
|
|
2731
|
+
* A press message consists of successive key down and up messages.
|
|
2732
|
+
* @param key Sequence of keys to press.
|
|
2733
|
+
* @param options Specifies the typing options.
|
|
2734
|
+
*/
|
|
2735
|
+
press(key: string, options?: { delay?: number }): Promise<void>;
|
|
2736
|
+
|
|
2737
|
+
/**
|
|
2738
|
+
* Type sends a `press` message to a session target for each character in text.
|
|
2739
|
+
* It sends an insertText message if a character is not among
|
|
2740
|
+
* valid characters in the keyboard's layout.
|
|
2741
|
+
* Modifier keys `Shift`, `Control`, `Alt`, `Meta` are _not_ respected.
|
|
2742
|
+
* @param text A text to type into a focused element.
|
|
2743
|
+
* @param options Specifies the typing options.
|
|
2744
|
+
*/
|
|
2745
|
+
type(text: string, options?: { delay?: number }): Promise<void>;
|
|
2746
|
+
|
|
2747
|
+
/**
|
|
2748
|
+
* Sends a key up message to a session target.
|
|
2749
|
+
* 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).
|
|
2750
|
+
* @param key Name of key to release, such as `ArrowLeft`.
|
|
2751
|
+
*/
|
|
2752
|
+
up(key: string): Promise<void>;
|
|
2753
|
+
}
|
|
2754
|
+
|
|
2755
|
+
export interface LocatorOptions {
|
|
2756
|
+
/**
|
|
2757
|
+
* Matches only elements that contain the specified text. String or regular expression.
|
|
2758
|
+
*/
|
|
2759
|
+
hasText?: string | RegExp;
|
|
2760
|
+
|
|
2761
|
+
/**
|
|
2762
|
+
* Matches only elements that do not contain the specified text. String or regular expression.
|
|
2763
|
+
*/
|
|
2764
|
+
hasNotText?: string | RegExp;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
export interface LocatorFilterOptions {
|
|
2768
|
+
/**
|
|
2769
|
+
* Matches only elements that contain the specified text. String or regular expression.
|
|
2770
|
+
*/
|
|
2771
|
+
hasText?: string | RegExp;
|
|
2772
|
+
|
|
2773
|
+
/**
|
|
2774
|
+
* Matches only elements that do not contain the specified text. String or regular expression.
|
|
2775
|
+
*/
|
|
2776
|
+
hasNotText?: string | RegExp;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
/**
|
|
2780
|
+
* The Locator API makes it easier to work with dynamically changing elements.
|
|
2781
|
+
* Some of the benefits of using it over existing ways to locate an element
|
|
2782
|
+
* (e.g. Page.$()) include:
|
|
2783
|
+
*
|
|
2784
|
+
* - Helps with writing robust tests by finding an element even if the
|
|
2785
|
+
* underlying frame navigates.
|
|
2786
|
+
* - Makes it easier to work with dynamic web pages and SPAs built with Svelte,
|
|
2787
|
+
* React, Vue, etc.
|
|
2788
|
+
*/
|
|
2789
|
+
export interface Locator {
|
|
2790
|
+
/**
|
|
2791
|
+
* Returns an array of locators matching the selector.
|
|
2792
|
+
*
|
|
2793
|
+
* **Usage**
|
|
2794
|
+
*
|
|
2795
|
+
* ```js
|
|
2796
|
+
* // Select all options
|
|
2797
|
+
* for (const option of await page.locator('option').all())
|
|
2798
|
+
* await option.click();
|
|
2799
|
+
* ```
|
|
2800
|
+
*
|
|
2801
|
+
* @returns Array of locators
|
|
2802
|
+
*/
|
|
2803
|
+
all(): Promise<Locator[]>;
|
|
2804
|
+
|
|
2805
|
+
/**
|
|
2806
|
+
* Returns the bounding box of the element that this locator points to.
|
|
2807
|
+
*
|
|
2808
|
+
* **Usage**
|
|
2809
|
+
*
|
|
2810
|
+
* ```js
|
|
2811
|
+
* const locator = page.locator('#my-element');
|
|
2812
|
+
* const boundingBox = await locator.boundingBox();
|
|
2813
|
+
* ```
|
|
2814
|
+
*
|
|
2815
|
+
* @param options Options to use.
|
|
2816
|
+
* @returns The bounding box of the element, or null if the element is not visible.
|
|
2817
|
+
*/
|
|
2818
|
+
boundingBox(options?: TimeoutOptions): Promise<Rect | null>;
|
|
2819
|
+
|
|
2820
|
+
/**
|
|
2821
|
+
* Clears text boxes and input fields of any existing values.
|
|
2822
|
+
*
|
|
2823
|
+
* **Usage**
|
|
2824
|
+
*
|
|
2825
|
+
* ```js
|
|
2826
|
+
* // Clears the input field matching the selector.
|
|
2827
|
+
* page.locator('input[name="login"]').clear();
|
|
2828
|
+
* ```
|
|
2829
|
+
*
|
|
2830
|
+
* @param options Options to use.
|
|
2831
|
+
*/
|
|
2832
|
+
clear(options?: ElementHandleOptions): Promise<void>;
|
|
2833
|
+
|
|
2834
|
+
/**
|
|
2835
|
+
* Mouse click on the chosen element.
|
|
2836
|
+
* @param options Options to use.
|
|
2837
|
+
* @returns Promise which resolves when the element is successfully clicked.
|
|
2838
|
+
*/
|
|
2839
|
+
click(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
2840
|
+
|
|
2841
|
+
/**
|
|
2842
|
+
* Returns a `FrameLocator` that can be used to locate elements within an
|
|
2843
|
+
* `iframe`.
|
|
2844
|
+
* @returns A `FrameLocator`.
|
|
2845
|
+
*/
|
|
2846
|
+
contentFrame(): FrameLocator;
|
|
2847
|
+
|
|
2848
|
+
/**
|
|
2849
|
+
* Returns the number of elements matching the selector.
|
|
2850
|
+
*
|
|
2851
|
+
* **Usage**
|
|
2852
|
+
*
|
|
2853
|
+
* ```js
|
|
2854
|
+
* const count = await page.locator('input').count();
|
|
2855
|
+
* ```
|
|
2856
|
+
*
|
|
2857
|
+
* @returns Promise which resolves with the number of elements matching the selector.
|
|
2858
|
+
*/
|
|
2859
|
+
count(): Promise<number>;
|
|
2001
2860
|
|
|
2002
2861
|
/**
|
|
2003
2862
|
* Mouse double click on the chosen element.
|
|
@@ -2105,107 +2964,493 @@ export interface Locator {
|
|
|
2105
2964
|
*/
|
|
2106
2965
|
innerText(options?: TimeoutOptions): Promise<string>;
|
|
2107
2966
|
|
|
2108
|
-
/**
|
|
2109
|
-
* Returns the `element.textContent`.
|
|
2110
|
-
* @param options Options to use.
|
|
2111
|
-
* @returns Element's textContent.
|
|
2112
|
-
*/
|
|
2113
|
-
textContent(options?: TimeoutOptions): Promise<string | null>;
|
|
2967
|
+
/**
|
|
2968
|
+
* Returns the `element.textContent`.
|
|
2969
|
+
* @param options Options to use.
|
|
2970
|
+
* @returns Element's textContent.
|
|
2971
|
+
*/
|
|
2972
|
+
textContent(options?: TimeoutOptions): Promise<string | null>;
|
|
2973
|
+
|
|
2974
|
+
/**
|
|
2975
|
+
* Returns `input.value` for the selected `input`, `textarea` or `select` element.
|
|
2976
|
+
* @param options Options to use.
|
|
2977
|
+
* @returns The input value of the element.
|
|
2978
|
+
*/
|
|
2979
|
+
inputValue(options?: TimeoutOptions): Promise<string>;
|
|
2980
|
+
|
|
2981
|
+
/**
|
|
2982
|
+
* Returns locator to the last matching element.
|
|
2983
|
+
*
|
|
2984
|
+
* **Usage**
|
|
2985
|
+
*
|
|
2986
|
+
* ```js
|
|
2987
|
+
* const lastRow = await page.locator('tr').last();
|
|
2988
|
+
* ```
|
|
2989
|
+
*
|
|
2990
|
+
* @returns Locator.
|
|
2991
|
+
*/
|
|
2992
|
+
last(): Locator;
|
|
2993
|
+
|
|
2994
|
+
/**
|
|
2995
|
+
* The method finds all elements matching the selector and creates a new
|
|
2996
|
+
* locator that matches all of them. This method can be used to further
|
|
2997
|
+
* refine the locator by chaining additional selectors.
|
|
2998
|
+
*
|
|
2999
|
+
* @example
|
|
3000
|
+
* ```js
|
|
3001
|
+
* const rows = page.locator('table tr');
|
|
3002
|
+
* const cell = rows.locator('.selected');
|
|
3003
|
+
*
|
|
3004
|
+
* // Use with options to filter
|
|
3005
|
+
* const orangeButton = fruitsSection.locator('button', { hasText: 'Add to Cart' });
|
|
3006
|
+
* ```
|
|
3007
|
+
*
|
|
3008
|
+
* @param selector A selector to use when resolving DOM element.
|
|
3009
|
+
* @param options Options to use for filtering.
|
|
3010
|
+
* @returns The new locator.
|
|
3011
|
+
*/
|
|
3012
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
3013
|
+
|
|
3014
|
+
/**
|
|
3015
|
+
* Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
|
3016
|
+
*
|
|
3017
|
+
* **Usage**
|
|
3018
|
+
*
|
|
3019
|
+
* ```js
|
|
3020
|
+
* const secondRow = await page.locator('tr').nth(1);
|
|
3021
|
+
* ```
|
|
3022
|
+
*
|
|
3023
|
+
* @param index
|
|
3024
|
+
* @returns Locator
|
|
3025
|
+
*/
|
|
3026
|
+
nth(index: number): Locator;
|
|
3027
|
+
|
|
3028
|
+
/**
|
|
3029
|
+
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
3030
|
+
* otherwise only the first option matching one of the passed options is selected.
|
|
3031
|
+
*
|
|
3032
|
+
* @example
|
|
3033
|
+
* ```js
|
|
3034
|
+
* // Single selection matching the value or label
|
|
3035
|
+
* locator.selectOption('blue');
|
|
3036
|
+
*
|
|
3037
|
+
* // single selection matching the label
|
|
3038
|
+
* locator.selectOption({ label: 'Blue' });
|
|
3039
|
+
*
|
|
3040
|
+
* // multiple selection
|
|
3041
|
+
* locator.selectOption(['red', 'green', 'blue']);
|
|
3042
|
+
* ```
|
|
3043
|
+
*
|
|
3044
|
+
* @param values Values of options to select.
|
|
3045
|
+
* @param options Options to use.
|
|
3046
|
+
* @returns List of selected options.
|
|
3047
|
+
*/
|
|
3048
|
+
selectOption(
|
|
3049
|
+
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
3050
|
+
options?: ElementHandleOptions,
|
|
3051
|
+
): Promise<string[]>;
|
|
3052
|
+
|
|
3053
|
+
/**
|
|
3054
|
+
* Checks or unchecks the input checkbox element.
|
|
3055
|
+
* @param checked Whether to check or uncheck the element.
|
|
3056
|
+
* @param options Options to customize the check action.
|
|
3057
|
+
* @returns A promise that resolves when the element is checked or unchecked.
|
|
3058
|
+
*/
|
|
3059
|
+
setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
|
|
3060
|
+
|
|
3061
|
+
/**
|
|
3062
|
+
* Press a single key on the keyboard or a combination of keys.
|
|
3063
|
+
* 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).
|
|
3064
|
+
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
|
|
3065
|
+
* @param options Keyboard press options.
|
|
3066
|
+
*/
|
|
3067
|
+
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
3068
|
+
|
|
3069
|
+
/**
|
|
3070
|
+
* Type a text into the input field.
|
|
3071
|
+
* @param text Text to type into the input field.
|
|
3072
|
+
* @param options Typing options.
|
|
3073
|
+
*/
|
|
3074
|
+
type(text: string, options?: KeyboardPressOptions): Promise<void>;
|
|
3075
|
+
|
|
3076
|
+
/**
|
|
3077
|
+
* Hover over the element.
|
|
3078
|
+
* @param options Options to use.
|
|
3079
|
+
*/
|
|
3080
|
+
hover(options?: MouseMoveOptions): Promise<void>;
|
|
3081
|
+
|
|
3082
|
+
/**
|
|
3083
|
+
* Tap on the chosen element.
|
|
3084
|
+
* @param options Options to use.
|
|
3085
|
+
*/
|
|
3086
|
+
tap(options?: MouseMoveOptions): Promise<void>;
|
|
3087
|
+
|
|
3088
|
+
/**
|
|
3089
|
+
* Dispatches HTML DOM event types e.g. `click`.
|
|
3090
|
+
* @param type DOM event type.
|
|
3091
|
+
* @param eventInit Event-specific properties.
|
|
3092
|
+
* @param options Options to use.
|
|
3093
|
+
*/
|
|
3094
|
+
dispatchEvent(type: string, eventInit?: EvaluationArgument, options?: TimeoutOptions): Promise<void>;
|
|
3095
|
+
|
|
3096
|
+
/**
|
|
3097
|
+
* Wait for the element to be in a particular state e.g. `visible`.
|
|
3098
|
+
* @param options Wait options.
|
|
3099
|
+
*/
|
|
3100
|
+
waitFor(options?: { state?: ElementState } & TimeoutOptions): Promise<void>;
|
|
3101
|
+
|
|
3102
|
+
/**
|
|
3103
|
+
* Returns a new Locator that matches only elements with the given options.
|
|
3104
|
+
*
|
|
3105
|
+
* @example
|
|
3106
|
+
* ```js
|
|
3107
|
+
* // Filter list items that contain "Product 2" text
|
|
3108
|
+
* const product2Item = page
|
|
3109
|
+
* .locator('li')
|
|
3110
|
+
* .filter({ hasText: 'Product 2' })
|
|
3111
|
+
* .first();
|
|
3112
|
+
*
|
|
3113
|
+
* // Filter list items that do NOT contain "Product 2" using regex
|
|
3114
|
+
* const product1Item = page
|
|
3115
|
+
* .locator('li')
|
|
3116
|
+
* .filter({ hasNotText: /Product 2/ })
|
|
3117
|
+
* .first();
|
|
3118
|
+
* ```
|
|
3119
|
+
*
|
|
3120
|
+
* @param options Filter options.
|
|
3121
|
+
* @returns A new filtered Locator that can be chained with other methods.
|
|
3122
|
+
*/
|
|
3123
|
+
filter(options: LocatorFilterOptions): Locator;
|
|
3124
|
+
|
|
3125
|
+
/**
|
|
3126
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
3127
|
+
*
|
|
3128
|
+
* @example
|
|
3129
|
+
* ```js
|
|
3130
|
+
* const locator = locator.getByRole('button', { name: 'Pizza, Please!' });
|
|
3131
|
+
*
|
|
3132
|
+
* await locator.click();
|
|
3133
|
+
* ```
|
|
3134
|
+
*
|
|
3135
|
+
* @param role The role of the element.
|
|
3136
|
+
* @param options Options to use.
|
|
3137
|
+
* @returns The locator to the element with the corresponding role.
|
|
3138
|
+
*/
|
|
3139
|
+
getByRole(
|
|
3140
|
+
role:
|
|
3141
|
+
| "alert"
|
|
3142
|
+
| "alertdialog"
|
|
3143
|
+
| "application"
|
|
3144
|
+
| "article"
|
|
3145
|
+
| "banner"
|
|
3146
|
+
| "blockquote"
|
|
3147
|
+
| "button"
|
|
3148
|
+
| "caption"
|
|
3149
|
+
| "cell"
|
|
3150
|
+
| "checkbox"
|
|
3151
|
+
| "code"
|
|
3152
|
+
| "columnheader"
|
|
3153
|
+
| "combobox"
|
|
3154
|
+
| "complementary"
|
|
3155
|
+
| "contentinfo"
|
|
3156
|
+
| "definition"
|
|
3157
|
+
| "dialog"
|
|
3158
|
+
| "directory"
|
|
3159
|
+
| "document"
|
|
3160
|
+
| "emphasis"
|
|
3161
|
+
| "feed"
|
|
3162
|
+
| "figure"
|
|
3163
|
+
| "form"
|
|
3164
|
+
| "generic"
|
|
3165
|
+
| "grid"
|
|
3166
|
+
| "gridcell"
|
|
3167
|
+
| "group"
|
|
3168
|
+
| "heading"
|
|
3169
|
+
| "img"
|
|
3170
|
+
| "insertion"
|
|
3171
|
+
| "link"
|
|
3172
|
+
| "list"
|
|
3173
|
+
| "listbox"
|
|
3174
|
+
| "listitem"
|
|
3175
|
+
| "log"
|
|
3176
|
+
| "main"
|
|
3177
|
+
| "marquee"
|
|
3178
|
+
| "math"
|
|
3179
|
+
| "menu"
|
|
3180
|
+
| "menubar"
|
|
3181
|
+
| "menuitem"
|
|
3182
|
+
| "menuitemcheckbox"
|
|
3183
|
+
| "menuitemradio"
|
|
3184
|
+
| "meter"
|
|
3185
|
+
| "navigation"
|
|
3186
|
+
| "none"
|
|
3187
|
+
| "note"
|
|
3188
|
+
| "option"
|
|
3189
|
+
| "presentation"
|
|
3190
|
+
| "progressbar"
|
|
3191
|
+
| "radio"
|
|
3192
|
+
| "radiogroup"
|
|
3193
|
+
| "region"
|
|
3194
|
+
| "row"
|
|
3195
|
+
| "rowgroup"
|
|
3196
|
+
| "rowheader"
|
|
3197
|
+
| "scrollbar"
|
|
3198
|
+
| "search"
|
|
3199
|
+
| "searchbox"
|
|
3200
|
+
| "separator"
|
|
3201
|
+
| "slider"
|
|
3202
|
+
| "spinbutton"
|
|
3203
|
+
| "status"
|
|
3204
|
+
| "strong"
|
|
3205
|
+
| "subscript"
|
|
3206
|
+
| "superscript"
|
|
3207
|
+
| "switch"
|
|
3208
|
+
| "tab"
|
|
3209
|
+
| "table"
|
|
3210
|
+
| "tablist"
|
|
3211
|
+
| "tabpanel"
|
|
3212
|
+
| "term"
|
|
3213
|
+
| "textbox"
|
|
3214
|
+
| "time"
|
|
3215
|
+
| "timer"
|
|
3216
|
+
| "toolbar"
|
|
3217
|
+
| "tooltip"
|
|
3218
|
+
| "tree"
|
|
3219
|
+
| "treegrid"
|
|
3220
|
+
| "treeitem",
|
|
3221
|
+
options?: {
|
|
3222
|
+
/**
|
|
3223
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
3224
|
+
*
|
|
3225
|
+
* @defaultValue false
|
|
3226
|
+
*/
|
|
3227
|
+
exact?: boolean;
|
|
3228
|
+
|
|
3229
|
+
/**
|
|
3230
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
3231
|
+
*
|
|
3232
|
+
* @defaultValue false
|
|
3233
|
+
*/
|
|
3234
|
+
includeHidden?: boolean;
|
|
3235
|
+
|
|
3236
|
+
/**
|
|
3237
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
3238
|
+
*/
|
|
3239
|
+
level?: number;
|
|
3240
|
+
|
|
3241
|
+
/**
|
|
3242
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
3243
|
+
*/
|
|
3244
|
+
name?: string | RegExp;
|
|
3245
|
+
|
|
3246
|
+
/**
|
|
3247
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
3248
|
+
*/
|
|
3249
|
+
checked?: boolean;
|
|
3250
|
+
|
|
3251
|
+
/**
|
|
3252
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
3253
|
+
*/
|
|
3254
|
+
disabled?: boolean;
|
|
3255
|
+
|
|
3256
|
+
/**
|
|
3257
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
3258
|
+
*/
|
|
3259
|
+
expanded?: boolean;
|
|
3260
|
+
|
|
3261
|
+
/**
|
|
3262
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
3263
|
+
*/
|
|
3264
|
+
pressed?: boolean;
|
|
3265
|
+
|
|
3266
|
+
/**
|
|
3267
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
3268
|
+
*/
|
|
3269
|
+
selected?: boolean;
|
|
3270
|
+
},
|
|
3271
|
+
): Locator;
|
|
2114
3272
|
|
|
2115
3273
|
/**
|
|
2116
|
-
* Returns
|
|
3274
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
3275
|
+
*
|
|
3276
|
+
* @example
|
|
3277
|
+
* ```js
|
|
3278
|
+
* const locator = locator.getByAltText('pizza');
|
|
3279
|
+
*
|
|
3280
|
+
* await locator.click();
|
|
3281
|
+
* ```
|
|
3282
|
+
*
|
|
3283
|
+
* @param altText The alt text of the element.
|
|
2117
3284
|
* @param options Options to use.
|
|
2118
|
-
* @returns The
|
|
3285
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
2119
3286
|
*/
|
|
2120
|
-
|
|
3287
|
+
getByAltText(
|
|
3288
|
+
altText: string | RegExp,
|
|
3289
|
+
options?: {
|
|
3290
|
+
/**
|
|
3291
|
+
* Whether the locator should be exact.
|
|
3292
|
+
*
|
|
3293
|
+
* @defaultValue false
|
|
3294
|
+
*/
|
|
3295
|
+
exact?: boolean;
|
|
3296
|
+
},
|
|
3297
|
+
): Locator;
|
|
2121
3298
|
|
|
2122
3299
|
/**
|
|
2123
|
-
* Returns
|
|
2124
|
-
*
|
|
2125
|
-
* **Usage**
|
|
3300
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2126
3301
|
*
|
|
3302
|
+
* @example
|
|
2127
3303
|
* ```js
|
|
2128
|
-
* const
|
|
3304
|
+
* const locator = locator.getByLabel('Password');
|
|
3305
|
+
*
|
|
3306
|
+
* await locator.fill('my-password');
|
|
2129
3307
|
* ```
|
|
2130
3308
|
*
|
|
2131
|
-
* @
|
|
3309
|
+
* @param label The label text of the element.
|
|
3310
|
+
* @param options Options to use.
|
|
3311
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2132
3312
|
*/
|
|
2133
|
-
|
|
3313
|
+
getByLabel(
|
|
3314
|
+
label: string | RegExp,
|
|
3315
|
+
options?: {
|
|
3316
|
+
/**
|
|
3317
|
+
* Whether the locator should be exact.
|
|
3318
|
+
*
|
|
3319
|
+
* @defaultValue false
|
|
3320
|
+
*/
|
|
3321
|
+
exact?: boolean;
|
|
3322
|
+
},
|
|
3323
|
+
): Locator;
|
|
2134
3324
|
|
|
2135
3325
|
/**
|
|
2136
|
-
*
|
|
3326
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
2137
3327
|
*
|
|
2138
|
-
*
|
|
3328
|
+
* Consider the following DOM structure:
|
|
3329
|
+
*
|
|
3330
|
+
* ```html
|
|
3331
|
+
* <div>Hello <span>world</span></div>
|
|
3332
|
+
* <div>Hello</div>
|
|
3333
|
+
* ```
|
|
2139
3334
|
*
|
|
3335
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
3336
|
+
*
|
|
3337
|
+
* @example
|
|
2140
3338
|
* ```js
|
|
2141
|
-
*
|
|
3339
|
+
* // Matches <span>
|
|
3340
|
+
* locator.getByText('world');
|
|
3341
|
+
*
|
|
3342
|
+
* // Matches first <div>
|
|
3343
|
+
* locator.getByText('Hello world');
|
|
3344
|
+
*
|
|
3345
|
+
* // Matches second <div>
|
|
3346
|
+
* locator.getByText('Hello', { exact: true });
|
|
3347
|
+
*
|
|
3348
|
+
* // Matches both <div>s
|
|
3349
|
+
* locator.getByText(/Hello/);
|
|
3350
|
+
*
|
|
3351
|
+
* // Matches second <div>
|
|
3352
|
+
* locator.getByText(/^hello$/i);
|
|
2142
3353
|
* ```
|
|
2143
3354
|
*
|
|
2144
|
-
*
|
|
2145
|
-
*
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
*
|
|
2151
|
-
*
|
|
2152
|
-
* @param
|
|
3355
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
3356
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
3357
|
+
* and ignores leading and trailing whitespace.
|
|
3358
|
+
*
|
|
3359
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
3360
|
+
* `value` instead of the text content. For example, locating by text
|
|
3361
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
3362
|
+
*
|
|
3363
|
+
* @param text Text to locate the element by.
|
|
2153
3364
|
* @param options Options to use.
|
|
2154
|
-
* @returns
|
|
2155
|
-
*/
|
|
2156
|
-
selectOption(
|
|
2157
|
-
values: string | string[] | { value?: string; label?: string; index?: number },
|
|
2158
|
-
options?: ElementHandleOptions,
|
|
2159
|
-
): Promise<string[]>;
|
|
2160
|
-
|
|
2161
|
-
/**
|
|
2162
|
-
* Checks or unchecks the input checkbox element.
|
|
2163
|
-
* @param checked Whether to check or uncheck the element.
|
|
2164
|
-
* @param options Options to customize the check action.
|
|
2165
|
-
* @returns A promise that resolves when the element is checked or unchecked.
|
|
2166
|
-
*/
|
|
2167
|
-
setChecked(checked: boolean, options?: FrameCheckOptions): Promise<void>;
|
|
2168
|
-
|
|
2169
|
-
/**
|
|
2170
|
-
* Press a single key on the keyboard or a combination of keys.
|
|
2171
|
-
* 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).
|
|
2172
|
-
* @param key Name of the key to press or a character to generate, such as `ArrowLeft` or `a`.
|
|
2173
|
-
* @param options Keyboard press options.
|
|
2174
|
-
*/
|
|
2175
|
-
press(key: string, options?: KeyboardPressOptions): Promise<void>;
|
|
2176
|
-
|
|
2177
|
-
/**
|
|
2178
|
-
* Type a text into the input field.
|
|
2179
|
-
* @param text Text to type into the input field.
|
|
2180
|
-
* @param options Typing options.
|
|
3365
|
+
* @returns The locator to the element with the corresponding text content.
|
|
2181
3366
|
*/
|
|
2182
|
-
|
|
3367
|
+
getByText(
|
|
3368
|
+
text: string | RegExp,
|
|
3369
|
+
options?: {
|
|
3370
|
+
/**
|
|
3371
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
3372
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
3373
|
+
* Note that exact match still trims whitespace.
|
|
3374
|
+
*
|
|
3375
|
+
* @defaultValue false
|
|
3376
|
+
*/
|
|
3377
|
+
exact?: boolean;
|
|
3378
|
+
},
|
|
3379
|
+
): Locator;
|
|
2183
3380
|
|
|
2184
3381
|
/**
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
3382
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
3383
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
3384
|
+
*
|
|
3385
|
+
* @example
|
|
3386
|
+
* HTML:
|
|
3387
|
+
* ```html
|
|
3388
|
+
* <button data-testid="submit-button">Submit</button>
|
|
3389
|
+
* ```
|
|
3390
|
+
*
|
|
3391
|
+
* JavaScript:
|
|
3392
|
+
* ```js
|
|
3393
|
+
* const locator = locator.getByTestId('submit-button');
|
|
3394
|
+
*
|
|
3395
|
+
* await locator.click();
|
|
3396
|
+
* ```
|
|
3397
|
+
*
|
|
3398
|
+
* @param testId The test ID of the element.
|
|
3399
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2187
3400
|
*/
|
|
2188
|
-
|
|
3401
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2189
3402
|
|
|
2190
3403
|
/**
|
|
2191
|
-
*
|
|
3404
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
3405
|
+
*
|
|
3406
|
+
* @example
|
|
3407
|
+
* ```js
|
|
3408
|
+
* const locator = locator.getByPlaceholder('name@example.com');
|
|
3409
|
+
*
|
|
3410
|
+
* await locator.fill('my.name@example.com');
|
|
3411
|
+
* ```
|
|
3412
|
+
*
|
|
3413
|
+
* @param placeholder The placeholder text of the element.
|
|
2192
3414
|
* @param options Options to use.
|
|
3415
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2193
3416
|
*/
|
|
2194
|
-
|
|
3417
|
+
getByPlaceholder(
|
|
3418
|
+
placeholder: string | RegExp,
|
|
3419
|
+
options?: {
|
|
3420
|
+
/**
|
|
3421
|
+
* Whether the locator should be exact.
|
|
3422
|
+
*
|
|
3423
|
+
* @defaultValue false
|
|
3424
|
+
*/
|
|
3425
|
+
exact?: boolean;
|
|
3426
|
+
},
|
|
3427
|
+
): Locator;
|
|
2195
3428
|
|
|
2196
3429
|
/**
|
|
2197
|
-
*
|
|
2198
|
-
*
|
|
2199
|
-
* @
|
|
3430
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
3431
|
+
*
|
|
3432
|
+
* @example
|
|
3433
|
+
* ```js
|
|
3434
|
+
* const locator = locator.getByTitle('Information box');
|
|
3435
|
+
*
|
|
3436
|
+
* await locator.click();
|
|
3437
|
+
* ```
|
|
3438
|
+
*
|
|
3439
|
+
* @param title The title text of the element.
|
|
2200
3440
|
* @param options Options to use.
|
|
3441
|
+
* @returns The locator to the element with the corresponding title text.
|
|
2201
3442
|
*/
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
3443
|
+
getByTitle(
|
|
3444
|
+
title: string | RegExp,
|
|
3445
|
+
options?: {
|
|
3446
|
+
/**
|
|
3447
|
+
* Whether the locator should be exact.
|
|
3448
|
+
*
|
|
3449
|
+
* @defaultValue false
|
|
3450
|
+
*/
|
|
3451
|
+
exact?: boolean;
|
|
3452
|
+
},
|
|
3453
|
+
): Locator;
|
|
2209
3454
|
}
|
|
2210
3455
|
|
|
2211
3456
|
/**
|
|
@@ -2604,101 +3849,431 @@ export interface Page {
|
|
|
2604
3849
|
value: string,
|
|
2605
3850
|
options?: {
|
|
2606
3851
|
/**
|
|
2607
|
-
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
2608
|
-
* `stable`, `enabled`). Defaults to `false`.
|
|
3852
|
+
* Setting this to `true` will bypass the actionability checks (`visible`,
|
|
3853
|
+
* `stable`, `enabled`). Defaults to `false`.
|
|
3854
|
+
*/
|
|
3855
|
+
force?: boolean;
|
|
3856
|
+
|
|
3857
|
+
/**
|
|
3858
|
+
* If set to `true` and a navigation occurs from performing this action, it
|
|
3859
|
+
* will not wait for it to complete. Defaults to `false`.
|
|
3860
|
+
*/
|
|
3861
|
+
noWaitAfter?: boolean;
|
|
3862
|
+
|
|
3863
|
+
/**
|
|
3864
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3865
|
+
* If given selector resolves to more than one element, the call throws
|
|
3866
|
+
* an exception. Defaults to `false`.
|
|
3867
|
+
*/
|
|
3868
|
+
strict?: boolean;
|
|
3869
|
+
|
|
3870
|
+
/**
|
|
3871
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3872
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3873
|
+
* `page` methods.
|
|
3874
|
+
*
|
|
3875
|
+
* Setting the value to `0` will disable the timeout.
|
|
3876
|
+
*/
|
|
3877
|
+
timeout?: number;
|
|
3878
|
+
},
|
|
3879
|
+
): Promise<void>;
|
|
3880
|
+
|
|
3881
|
+
/**
|
|
3882
|
+
* **NOTE** Use locator-based `locator.focus([options])` instead.
|
|
3883
|
+
*
|
|
3884
|
+
* This method fetches an element with `selector` and focuses it.
|
|
3885
|
+
*
|
|
3886
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3887
|
+
* elements satisfying the selector, the first will be used.
|
|
3888
|
+
* @param options
|
|
3889
|
+
*/
|
|
3890
|
+
focus(
|
|
3891
|
+
selector: string,
|
|
3892
|
+
options?: {
|
|
3893
|
+
/**
|
|
3894
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3895
|
+
* If given selector resolves to more than one element, the call throws
|
|
3896
|
+
* an exception. Defaults to `false`.
|
|
3897
|
+
*/
|
|
3898
|
+
strict?: boolean;
|
|
3899
|
+
|
|
3900
|
+
/**
|
|
3901
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3902
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3903
|
+
* `page` methods.
|
|
3904
|
+
*
|
|
3905
|
+
* Setting the value to `0` will disable the timeout.
|
|
3906
|
+
*/
|
|
3907
|
+
timeout?: number;
|
|
3908
|
+
},
|
|
3909
|
+
): Promise<void>;
|
|
3910
|
+
|
|
3911
|
+
/**
|
|
3912
|
+
* Frames returns an array of frames on the page.
|
|
3913
|
+
*/
|
|
3914
|
+
frames(): Frame[];
|
|
3915
|
+
|
|
3916
|
+
/**
|
|
3917
|
+
* **NOTE** Use locator-based locator.getAttribute(name[, options]) instead.
|
|
3918
|
+
*
|
|
3919
|
+
* Returns the element attribute value for the given attribute name.
|
|
3920
|
+
*
|
|
3921
|
+
* @param selector A selector to search for an element. If there are multiple
|
|
3922
|
+
* elements satisfying the selector, the first will be used.
|
|
3923
|
+
* @param name Attribute name to get the value for.
|
|
3924
|
+
* @param options
|
|
3925
|
+
*/
|
|
3926
|
+
getAttribute(
|
|
3927
|
+
selector: string,
|
|
3928
|
+
name: string,
|
|
3929
|
+
options?: {
|
|
3930
|
+
/**
|
|
3931
|
+
* When `true`, the call requires selector to resolve to a single element.
|
|
3932
|
+
* If given selector resolves to more than one element, the call throws
|
|
3933
|
+
* an exception. Defaults to `false`.
|
|
3934
|
+
*/
|
|
3935
|
+
strict?: boolean;
|
|
3936
|
+
|
|
3937
|
+
/**
|
|
3938
|
+
* Maximum time in milliseconds. Defaults to `30` seconds. Default is
|
|
3939
|
+
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
3940
|
+
* `page` methods.
|
|
3941
|
+
*
|
|
3942
|
+
* Setting the value to `0` will disable the timeout.
|
|
3943
|
+
*/
|
|
3944
|
+
timeout?: number;
|
|
3945
|
+
},
|
|
3946
|
+
): Promise<string | null>;
|
|
3947
|
+
|
|
3948
|
+
/**
|
|
3949
|
+
* Returns {@link Locator} to the element with the corresponding role.
|
|
3950
|
+
*
|
|
3951
|
+
* @example
|
|
3952
|
+
* ```js
|
|
3953
|
+
* const locator = page.getByRole('button', { name: 'Pizza, Please!' });
|
|
3954
|
+
*
|
|
3955
|
+
* await locator.click();
|
|
3956
|
+
* ```
|
|
3957
|
+
*
|
|
3958
|
+
* @param role The role of the element.
|
|
3959
|
+
* @param options Options to use.
|
|
3960
|
+
* @returns The locator to the element with the corresponding role.
|
|
3961
|
+
*/
|
|
3962
|
+
getByRole(
|
|
3963
|
+
role:
|
|
3964
|
+
| "alert"
|
|
3965
|
+
| "alertdialog"
|
|
3966
|
+
| "application"
|
|
3967
|
+
| "article"
|
|
3968
|
+
| "banner"
|
|
3969
|
+
| "blockquote"
|
|
3970
|
+
| "button"
|
|
3971
|
+
| "caption"
|
|
3972
|
+
| "cell"
|
|
3973
|
+
| "checkbox"
|
|
3974
|
+
| "code"
|
|
3975
|
+
| "columnheader"
|
|
3976
|
+
| "combobox"
|
|
3977
|
+
| "complementary"
|
|
3978
|
+
| "contentinfo"
|
|
3979
|
+
| "definition"
|
|
3980
|
+
| "dialog"
|
|
3981
|
+
| "directory"
|
|
3982
|
+
| "document"
|
|
3983
|
+
| "emphasis"
|
|
3984
|
+
| "feed"
|
|
3985
|
+
| "figure"
|
|
3986
|
+
| "form"
|
|
3987
|
+
| "generic"
|
|
3988
|
+
| "grid"
|
|
3989
|
+
| "gridcell"
|
|
3990
|
+
| "group"
|
|
3991
|
+
| "heading"
|
|
3992
|
+
| "img"
|
|
3993
|
+
| "insertion"
|
|
3994
|
+
| "link"
|
|
3995
|
+
| "list"
|
|
3996
|
+
| "listbox"
|
|
3997
|
+
| "listitem"
|
|
3998
|
+
| "log"
|
|
3999
|
+
| "main"
|
|
4000
|
+
| "marquee"
|
|
4001
|
+
| "math"
|
|
4002
|
+
| "menu"
|
|
4003
|
+
| "menubar"
|
|
4004
|
+
| "menuitem"
|
|
4005
|
+
| "menuitemcheckbox"
|
|
4006
|
+
| "menuitemradio"
|
|
4007
|
+
| "meter"
|
|
4008
|
+
| "navigation"
|
|
4009
|
+
| "none"
|
|
4010
|
+
| "note"
|
|
4011
|
+
| "option"
|
|
4012
|
+
| "presentation"
|
|
4013
|
+
| "progressbar"
|
|
4014
|
+
| "radio"
|
|
4015
|
+
| "radiogroup"
|
|
4016
|
+
| "region"
|
|
4017
|
+
| "row"
|
|
4018
|
+
| "rowgroup"
|
|
4019
|
+
| "rowheader"
|
|
4020
|
+
| "scrollbar"
|
|
4021
|
+
| "search"
|
|
4022
|
+
| "searchbox"
|
|
4023
|
+
| "separator"
|
|
4024
|
+
| "slider"
|
|
4025
|
+
| "spinbutton"
|
|
4026
|
+
| "status"
|
|
4027
|
+
| "strong"
|
|
4028
|
+
| "subscript"
|
|
4029
|
+
| "superscript"
|
|
4030
|
+
| "switch"
|
|
4031
|
+
| "tab"
|
|
4032
|
+
| "table"
|
|
4033
|
+
| "tablist"
|
|
4034
|
+
| "tabpanel"
|
|
4035
|
+
| "term"
|
|
4036
|
+
| "textbox"
|
|
4037
|
+
| "time"
|
|
4038
|
+
| "timer"
|
|
4039
|
+
| "toolbar"
|
|
4040
|
+
| "tooltip"
|
|
4041
|
+
| "tree"
|
|
4042
|
+
| "treegrid"
|
|
4043
|
+
| "treeitem",
|
|
4044
|
+
options?: {
|
|
4045
|
+
/**
|
|
4046
|
+
* Whether the accessible `options.name` should be checked exactly for equality.
|
|
4047
|
+
*
|
|
4048
|
+
* @defaultValue false
|
|
4049
|
+
*/
|
|
4050
|
+
exact?: boolean;
|
|
4051
|
+
|
|
4052
|
+
/**
|
|
4053
|
+
* Whether to include elements that are normally excluded from the accessibility tree.
|
|
4054
|
+
*
|
|
4055
|
+
* @defaultValue false
|
|
4056
|
+
*/
|
|
4057
|
+
includeHidden?: boolean;
|
|
4058
|
+
|
|
4059
|
+
/**
|
|
4060
|
+
* A number attribute that is traditionally used for headings h1-h6.
|
|
4061
|
+
*/
|
|
4062
|
+
level?: number;
|
|
4063
|
+
|
|
4064
|
+
/**
|
|
4065
|
+
* An accessible name for the element, such as a text in a button or a label for an input.
|
|
2609
4066
|
*/
|
|
2610
|
-
|
|
4067
|
+
name?: string | RegExp;
|
|
2611
4068
|
|
|
2612
4069
|
/**
|
|
2613
|
-
*
|
|
2614
|
-
* will not wait for it to complete. Defaults to `false`.
|
|
4070
|
+
* A boolean attribute that can be used to indicate if a checkbox is checked or not.
|
|
2615
4071
|
*/
|
|
2616
|
-
|
|
4072
|
+
checked?: boolean;
|
|
2617
4073
|
|
|
2618
4074
|
/**
|
|
2619
|
-
*
|
|
2620
|
-
* If given selector resolves to more than one element, the call throws
|
|
2621
|
-
* an exception. Defaults to `false`.
|
|
4075
|
+
* A boolean attribute that can be used to indicate if an element is disabled or not.
|
|
2622
4076
|
*/
|
|
2623
|
-
|
|
4077
|
+
disabled?: boolean;
|
|
2624
4078
|
|
|
2625
4079
|
/**
|
|
2626
|
-
*
|
|
2627
|
-
|
|
2628
|
-
|
|
4080
|
+
* A boolean attribute that can be used to indicate if an element is expanded or not.
|
|
4081
|
+
*/
|
|
4082
|
+
expanded?: boolean;
|
|
4083
|
+
|
|
4084
|
+
/**
|
|
4085
|
+
* A boolean attribute that can be used to indicate if an element is pressed or not.
|
|
4086
|
+
*/
|
|
4087
|
+
pressed?: boolean;
|
|
4088
|
+
|
|
4089
|
+
/**
|
|
4090
|
+
* A boolean attribute that can be used to indicate if an element is selected or not.
|
|
4091
|
+
*/
|
|
4092
|
+
selected?: boolean;
|
|
4093
|
+
},
|
|
4094
|
+
): Locator;
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* Returns {@link Locator} to the element with the corresponding alt text.
|
|
4098
|
+
*
|
|
4099
|
+
* @example
|
|
4100
|
+
* ```js
|
|
4101
|
+
* const locator = page.getByAltText('pizza');
|
|
4102
|
+
*
|
|
4103
|
+
* await locator.click();
|
|
4104
|
+
* ```
|
|
4105
|
+
*
|
|
4106
|
+
* @param altText The alt text of the element.
|
|
4107
|
+
* @param options Options to use.
|
|
4108
|
+
* @returns The locator to the element with the corresponding alt text.
|
|
4109
|
+
*/
|
|
4110
|
+
getByAltText(
|
|
4111
|
+
altText: string | RegExp,
|
|
4112
|
+
options?: {
|
|
4113
|
+
/**
|
|
4114
|
+
* Whether the locator should be exact.
|
|
2629
4115
|
*
|
|
2630
|
-
*
|
|
4116
|
+
* @defaultValue false
|
|
2631
4117
|
*/
|
|
2632
|
-
|
|
4118
|
+
exact?: boolean;
|
|
2633
4119
|
},
|
|
2634
|
-
):
|
|
4120
|
+
): Locator;
|
|
2635
4121
|
|
|
2636
4122
|
/**
|
|
2637
|
-
*
|
|
4123
|
+
* Returns {@link Locator} to the element with the corresponding label text.
|
|
2638
4124
|
*
|
|
2639
|
-
*
|
|
4125
|
+
* @example
|
|
4126
|
+
* ```js
|
|
4127
|
+
* const locator = page.getByLabel('Password');
|
|
2640
4128
|
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
4129
|
+
* await locator.fill('my-password');
|
|
4130
|
+
* ```
|
|
4131
|
+
*
|
|
4132
|
+
* @param label The label text of the element.
|
|
4133
|
+
* @param options Options to use.
|
|
4134
|
+
* @returns The locator to the element with the corresponding label text.
|
|
2644
4135
|
*/
|
|
2645
|
-
|
|
2646
|
-
|
|
4136
|
+
getByLabel(
|
|
4137
|
+
label: string | RegExp,
|
|
2647
4138
|
options?: {
|
|
2648
4139
|
/**
|
|
2649
|
-
*
|
|
2650
|
-
*
|
|
2651
|
-
*
|
|
4140
|
+
* Whether the locator should be exact.
|
|
4141
|
+
*
|
|
4142
|
+
* @defaultValue false
|
|
2652
4143
|
*/
|
|
2653
|
-
|
|
4144
|
+
exact?: boolean;
|
|
4145
|
+
},
|
|
4146
|
+
): Locator;
|
|
2654
4147
|
|
|
4148
|
+
/**
|
|
4149
|
+
* Allows locating elements by their text content. Returns {@link Locator}.
|
|
4150
|
+
*
|
|
4151
|
+
* Consider the following DOM structure:
|
|
4152
|
+
*
|
|
4153
|
+
* ```html
|
|
4154
|
+
* <div>Hello <span>world</span></div>
|
|
4155
|
+
* <div>Hello</div>
|
|
4156
|
+
* ```
|
|
4157
|
+
*
|
|
4158
|
+
* You can locate by text substring, exact string, or a regular expression:
|
|
4159
|
+
*
|
|
4160
|
+
* @example
|
|
4161
|
+
* ```js
|
|
4162
|
+
* // Matches <span>
|
|
4163
|
+
* page.getByText('world');
|
|
4164
|
+
*
|
|
4165
|
+
* // Matches first <div>
|
|
4166
|
+
* page.getByText('Hello world');
|
|
4167
|
+
*
|
|
4168
|
+
* // Matches second <div>
|
|
4169
|
+
* page.getByText('Hello', { exact: true });
|
|
4170
|
+
*
|
|
4171
|
+
* // Matches both <div>s
|
|
4172
|
+
* page.getByText(/Hello/);
|
|
4173
|
+
*
|
|
4174
|
+
* // Matches second <div>
|
|
4175
|
+
* page.getByText(/^hello$/i);
|
|
4176
|
+
* ```
|
|
4177
|
+
*
|
|
4178
|
+
* Matching by text always normalizes whitespace, even with exact match. For
|
|
4179
|
+
* example, it turns multiple spaces into one, turns line breaks into spaces
|
|
4180
|
+
* and ignores leading and trailing whitespace.
|
|
4181
|
+
*
|
|
4182
|
+
* Input elements of the type `button` and `submit` are matched by their
|
|
4183
|
+
* `value` instead of the text content. For example, locating by text
|
|
4184
|
+
* `"Log in"` matches `<input type=button value="Log in">`.
|
|
4185
|
+
*
|
|
4186
|
+
* @param text Text to locate the element by.
|
|
4187
|
+
* @param options Options to use.
|
|
4188
|
+
* @returns The locator to the element with the corresponding text content.
|
|
4189
|
+
*/
|
|
4190
|
+
getByText(
|
|
4191
|
+
text: string | RegExp,
|
|
4192
|
+
options?: {
|
|
2655
4193
|
/**
|
|
2656
|
-
*
|
|
2657
|
-
*
|
|
2658
|
-
*
|
|
4194
|
+
* Whether to find an exact match: case-sensitive and whole-string.
|
|
4195
|
+
* Default to false. Ignored when locating by a regular expression.
|
|
4196
|
+
* Note that exact match still trims whitespace.
|
|
2659
4197
|
*
|
|
2660
|
-
*
|
|
4198
|
+
* @defaultValue false
|
|
2661
4199
|
*/
|
|
2662
|
-
|
|
4200
|
+
exact?: boolean;
|
|
2663
4201
|
},
|
|
2664
|
-
):
|
|
4202
|
+
): Locator;
|
|
2665
4203
|
|
|
2666
4204
|
/**
|
|
2667
|
-
*
|
|
4205
|
+
* Returns {@link Locator} to the element with the corresponding test ID.
|
|
4206
|
+
* Note that this method only supports the `data-testid` attribute.
|
|
4207
|
+
*
|
|
4208
|
+
* @example
|
|
4209
|
+
* HTML:
|
|
4210
|
+
* ```html
|
|
4211
|
+
* <button data-testid="submit-button">Submit</button>
|
|
4212
|
+
* ```
|
|
4213
|
+
*
|
|
4214
|
+
* JavaScript:
|
|
4215
|
+
* ```js
|
|
4216
|
+
* const locator = page.getByTestId('submit-button');
|
|
4217
|
+
*
|
|
4218
|
+
* await locator.click();
|
|
4219
|
+
* ```
|
|
4220
|
+
*
|
|
4221
|
+
* @param testId The test ID of the element.
|
|
4222
|
+
* @returns The locator to the element with the corresponding test ID.
|
|
2668
4223
|
*/
|
|
2669
|
-
|
|
4224
|
+
getByTestId(testId: string | RegExp): Locator;
|
|
2670
4225
|
|
|
2671
4226
|
/**
|
|
2672
|
-
*
|
|
4227
|
+
* Returns {@link Locator} to the element with the corresponding placeholder text.
|
|
2673
4228
|
*
|
|
2674
|
-
*
|
|
4229
|
+
* @example
|
|
4230
|
+
* ```js
|
|
4231
|
+
* const locator = page.getByPlaceholder('name@example.com');
|
|
2675
4232
|
*
|
|
2676
|
-
*
|
|
2677
|
-
*
|
|
2678
|
-
*
|
|
2679
|
-
* @param
|
|
4233
|
+
* await locator.fill('my.name@example.com');
|
|
4234
|
+
* ```
|
|
4235
|
+
*
|
|
4236
|
+
* @param placeholder The placeholder text of the element.
|
|
4237
|
+
* @param options Options to use.
|
|
4238
|
+
* @returns The locator to the element with the corresponding placeholder text.
|
|
2680
4239
|
*/
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
name: string,
|
|
4240
|
+
getByPlaceholder(
|
|
4241
|
+
placeholder: string | RegExp,
|
|
2684
4242
|
options?: {
|
|
2685
4243
|
/**
|
|
2686
|
-
*
|
|
2687
|
-
*
|
|
2688
|
-
*
|
|
4244
|
+
* Whether the locator should be exact.
|
|
4245
|
+
*
|
|
4246
|
+
* @defaultValue false
|
|
2689
4247
|
*/
|
|
2690
|
-
|
|
4248
|
+
exact?: boolean;
|
|
4249
|
+
},
|
|
4250
|
+
): Locator;
|
|
2691
4251
|
|
|
4252
|
+
/**
|
|
4253
|
+
* Returns {@link Locator} to the element with the corresponding title text.
|
|
4254
|
+
*
|
|
4255
|
+
* @example
|
|
4256
|
+
* ```js
|
|
4257
|
+
* const locator = page.getByTitle('Information box');
|
|
4258
|
+
*
|
|
4259
|
+
* await locator.click();
|
|
4260
|
+
* ```
|
|
4261
|
+
*
|
|
4262
|
+
* @param title The title text of the element.
|
|
4263
|
+
* @param options Options to use.
|
|
4264
|
+
* @returns The locator to the element with the corresponding title text.
|
|
4265
|
+
*/
|
|
4266
|
+
getByTitle(
|
|
4267
|
+
title: string | RegExp,
|
|
4268
|
+
options?: {
|
|
2692
4269
|
/**
|
|
2693
|
-
*
|
|
2694
|
-
* overridden by the `setDefaultTimeout` option on `BrowserContext` or
|
|
2695
|
-
* `page` methods.
|
|
4270
|
+
* Whether the locator should be exact.
|
|
2696
4271
|
*
|
|
2697
|
-
*
|
|
4272
|
+
* @defaultValue false
|
|
2698
4273
|
*/
|
|
2699
|
-
|
|
4274
|
+
exact?: boolean;
|
|
2700
4275
|
},
|
|
2701
|
-
):
|
|
4276
|
+
): Locator;
|
|
2702
4277
|
|
|
2703
4278
|
/**
|
|
2704
4279
|
* Navigates to the specified url and returns the main resource response.
|
|
@@ -3027,9 +4602,18 @@ export interface Page {
|
|
|
3027
4602
|
* when the action takes place, which means locators can span over navigations
|
|
3028
4603
|
* where the underlying dom changes.
|
|
3029
4604
|
*
|
|
4605
|
+
* @example
|
|
4606
|
+
* ```js
|
|
4607
|
+
* const textbox = page.locator('#text1');
|
|
4608
|
+
*
|
|
4609
|
+
* // Create a locator with text filtering options
|
|
4610
|
+
* const submitButton = page.locator('button', { hasText: 'Pizza, Please!' });
|
|
4611
|
+
* ```
|
|
4612
|
+
*
|
|
3030
4613
|
* @param selector A selector to use when resolving DOM element.
|
|
4614
|
+
* @param options Options to use for filtering.
|
|
3031
4615
|
*/
|
|
3032
|
-
locator(selector: string): Locator;
|
|
4616
|
+
locator(selector: string, options?: LocatorOptions): Locator;
|
|
3033
4617
|
|
|
3034
4618
|
/**
|
|
3035
4619
|
* The page's main frame. Page is made up of frames in a hierarchical. At the
|
|
@@ -3218,6 +4802,16 @@ export interface Page {
|
|
|
3218
4802
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
3219
4803
|
}): Promise<Response | null>;
|
|
3220
4804
|
|
|
4805
|
+
/**
|
|
4806
|
+
* Adds a route to the page to modify network requests made by that page.
|
|
4807
|
+
*
|
|
4808
|
+
* Once routing is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
|
|
4809
|
+
*/
|
|
4810
|
+
route(
|
|
4811
|
+
url: string | RegExp,
|
|
4812
|
+
handler: (route: Route) => any,
|
|
4813
|
+
): Promise<void>;
|
|
4814
|
+
|
|
3221
4815
|
/**
|
|
3222
4816
|
* Returns the buffer with the captured screenshot from the browser.
|
|
3223
4817
|
*
|
|
@@ -3273,6 +4867,18 @@ export interface Page {
|
|
|
3273
4867
|
* This select one or more options which match the values from a <select>
|
|
3274
4868
|
* element.
|
|
3275
4869
|
*
|
|
4870
|
+
* @example
|
|
4871
|
+
* ```js
|
|
4872
|
+
* // Single selection matching the value or label
|
|
4873
|
+
* page.selectOption('#colors-options', 'blue');
|
|
4874
|
+
*
|
|
4875
|
+
* // single selection matching the label
|
|
4876
|
+
* page.selectOption('#colors-options', { label: 'Blue' });
|
|
4877
|
+
*
|
|
4878
|
+
* // multiple selection
|
|
4879
|
+
* page.selectOption('#colors-options', ['red', 'green', 'blue']);
|
|
4880
|
+
* ```
|
|
4881
|
+
*
|
|
3276
4882
|
* @param selector A selector to search for an element. If there are multiple
|
|
3277
4883
|
* elements satisfying the selector, the first will be used.
|
|
3278
4884
|
* @param values Options to select. If the select has multiple attribute, all
|
|
@@ -3787,6 +5393,13 @@ export interface Page {
|
|
|
3787
5393
|
*/
|
|
3788
5394
|
timeout?: number;
|
|
3789
5395
|
|
|
5396
|
+
/**
|
|
5397
|
+
* An exact string or regex pattern to match while waiting for the
|
|
5398
|
+
* navigation. Note that if the parameter is a string, the method will
|
|
5399
|
+
* wait for navigation to URL that is exactly equal to the string.
|
|
5400
|
+
*/
|
|
5401
|
+
url?: string | RegExp;
|
|
5402
|
+
|
|
3790
5403
|
/**
|
|
3791
5404
|
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
3792
5405
|
* either:
|
|
@@ -3802,6 +5415,79 @@ export interface Page {
|
|
|
3802
5415
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
3803
5416
|
}): Promise<Response | null>;
|
|
3804
5417
|
|
|
5418
|
+
/**
|
|
5419
|
+
* Waits for the page to navigate to the specified URL.
|
|
5420
|
+
*
|
|
5421
|
+
* @example
|
|
5422
|
+
* ```js
|
|
5423
|
+
* await page.locator('a[href="/login"]').click();
|
|
5424
|
+
* await page.waitForURL(/.*\/login$/);
|
|
5425
|
+
* ```
|
|
5426
|
+
*
|
|
5427
|
+
* @param url An exact match or regular expression to match the URL.
|
|
5428
|
+
* @param options Options to use.
|
|
5429
|
+
*/
|
|
5430
|
+
waitForURL(
|
|
5431
|
+
url: string | RegExp,
|
|
5432
|
+
options?: {
|
|
5433
|
+
/**
|
|
5434
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds.
|
|
5435
|
+
* The default value can be changed via the
|
|
5436
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
5437
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
5438
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
5439
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
5440
|
+
*
|
|
5441
|
+
* Setting the value to `0` will disable the timeout.
|
|
5442
|
+
*/
|
|
5443
|
+
timeout?: number;
|
|
5444
|
+
|
|
5445
|
+
/**
|
|
5446
|
+
* When to consider operation succeeded, defaults to `load`. Events can be
|
|
5447
|
+
* either:
|
|
5448
|
+
* - `'domcontentloaded'` - consider operation to be finished when the
|
|
5449
|
+
* `DOMContentLoaded` event is fired.
|
|
5450
|
+
* - `'load'` - consider operation to be finished when the `load` event is
|
|
5451
|
+
* fired.
|
|
5452
|
+
* - `'networkidle'` - **DISCOURAGED** consider operation to be finished
|
|
5453
|
+
* when there are no network connections for at least `500` ms. Don't use
|
|
5454
|
+
* this method for testing especially with chatty websites where the event
|
|
5455
|
+
* may never fire, rely on web assertions to assess readiness instead.
|
|
5456
|
+
*/
|
|
5457
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
5458
|
+
},
|
|
5459
|
+
): Promise<void>;
|
|
5460
|
+
|
|
5461
|
+
/**
|
|
5462
|
+
* Waits for the page to match against the URL for a Response object
|
|
5463
|
+
*
|
|
5464
|
+
* @example
|
|
5465
|
+
* ```js
|
|
5466
|
+
* const responsePromise = page.waitForResponse('https://example.com/resource');
|
|
5467
|
+
* await page.goto('https://example.com/resource');
|
|
5468
|
+
* const response = await responsePromise;
|
|
5469
|
+
* ```
|
|
5470
|
+
*
|
|
5471
|
+
* @param response Request URL string or regex to match against Response object.
|
|
5472
|
+
* @param options Options to use.
|
|
5473
|
+
*/
|
|
5474
|
+
waitForResponse(
|
|
5475
|
+
response: string | RegExp,
|
|
5476
|
+
options?: {
|
|
5477
|
+
/**
|
|
5478
|
+
* Maximum operation time in milliseconds. Defaults to `30` seconds.
|
|
5479
|
+
* The default value can be changed via the
|
|
5480
|
+
* browserContext.setDefaultNavigationTimeout(timeout),
|
|
5481
|
+
* browserContext.setDefaultTimeout(timeout),
|
|
5482
|
+
* page.setDefaultNavigationTimeout(timeout) or
|
|
5483
|
+
* page.setDefaultTimeout(timeout) methods.
|
|
5484
|
+
*
|
|
5485
|
+
* Setting the value to `0` will disable the timeout.
|
|
5486
|
+
*/
|
|
5487
|
+
timeout?: number;
|
|
5488
|
+
},
|
|
5489
|
+
): Promise<Response | null>;
|
|
5490
|
+
|
|
3805
5491
|
/**
|
|
3806
5492
|
* **NOTE** Use web assertions that assert visibility or a locator-based
|
|
3807
5493
|
* locator.waitFor([options]) instead.
|
|
@@ -4089,6 +5775,112 @@ export interface Response {
|
|
|
4089
5775
|
url(): string;
|
|
4090
5776
|
}
|
|
4091
5777
|
|
|
5778
|
+
/**
|
|
5779
|
+
* Route represents a network request intercepted by page.route() function and allows to modify its behavior.
|
|
5780
|
+
*
|
|
5781
|
+
* Once routing is enabled, every request intercepted by a route will stall unless it's continued, fulfilled or aborted.
|
|
5782
|
+
* When several routes match the given pattern, they run in the order opposite to their registration.
|
|
5783
|
+
* That way the last registered route can always override all the previous ones.
|
|
5784
|
+
*/
|
|
5785
|
+
export interface Route {
|
|
5786
|
+
/**
|
|
5787
|
+
* Aborts the request with the given error code.
|
|
5788
|
+
*
|
|
5789
|
+
* **Usage**
|
|
5790
|
+
*
|
|
5791
|
+
* ```js
|
|
5792
|
+
* // Abort all images requests
|
|
5793
|
+
* await page.route(/(\.png$)|(\.jpg$)/, async (route) => {
|
|
5794
|
+
* await route.abort();
|
|
5795
|
+
* });
|
|
5796
|
+
* ```
|
|
5797
|
+
*
|
|
5798
|
+
* @param errorCode The error code to abort the request with, can be one of the following:
|
|
5799
|
+
* 'aborted', 'accessdenied', 'addressunreachable', 'blockedbyclient', 'blockedbyresponse', 'connectionaborted','connectionclosed',
|
|
5800
|
+
* 'connectionfailed', 'connectionrefused', 'connectionreset', 'internetdisconnected', 'namenotresolved', 'timedout', 'failed'.
|
|
5801
|
+
*/
|
|
5802
|
+
abort(errorCode: string): Promise<void>;
|
|
5803
|
+
|
|
5804
|
+
/**
|
|
5805
|
+
* Continues the request with optional overrides.
|
|
5806
|
+
*
|
|
5807
|
+
* **Usage**
|
|
5808
|
+
*
|
|
5809
|
+
* ```js
|
|
5810
|
+
* await page.route('**\/*', async (route, request) => {
|
|
5811
|
+
* // Override headers
|
|
5812
|
+
* const headers = {
|
|
5813
|
+
* ...request.headers(),
|
|
5814
|
+
* foo: 'foo-value', // set "foo" header
|
|
5815
|
+
* bar: undefined, // remove "bar" header
|
|
5816
|
+
* };
|
|
5817
|
+
* await route.continue({ headers });
|
|
5818
|
+
* });
|
|
5819
|
+
* ```
|
|
5820
|
+
*
|
|
5821
|
+
* @param options Optional overrides for the request.
|
|
5822
|
+
*/
|
|
5823
|
+
continue(options?: {
|
|
5824
|
+
/**
|
|
5825
|
+
* Optional HTTP headers to override.
|
|
5826
|
+
*/
|
|
5827
|
+
headers?: { [key: string]: string };
|
|
5828
|
+
/**
|
|
5829
|
+
* Optional method to override the request method (e.g., 'GET', 'POST').
|
|
5830
|
+
*/
|
|
5831
|
+
method?: string;
|
|
5832
|
+
/**
|
|
5833
|
+
* Optional post data to override the request body.
|
|
5834
|
+
*/
|
|
5835
|
+
postData?: string | ArrayBuffer;
|
|
5836
|
+
/**
|
|
5837
|
+
* Optional URL to override the request URL.
|
|
5838
|
+
*/
|
|
5839
|
+
url?: string;
|
|
5840
|
+
}): Promise<void>;
|
|
5841
|
+
|
|
5842
|
+
/**
|
|
5843
|
+
* Fulfills the request with the given response.
|
|
5844
|
+
*
|
|
5845
|
+
* **Usage**
|
|
5846
|
+
* ```js
|
|
5847
|
+
* // Respond with a custom JSON response
|
|
5848
|
+
* await page.route('**\/*', async (route) => {
|
|
5849
|
+
* await route.fulfill({
|
|
5850
|
+
* status: 200,
|
|
5851
|
+
* contentType: 'application/json',
|
|
5852
|
+
* body: JSON.stringify({ message: 'Hello, world!' }),
|
|
5853
|
+
* });
|
|
5854
|
+
* });
|
|
5855
|
+
* ```
|
|
5856
|
+
*
|
|
5857
|
+
* @param options The response options to fulfill the request with.
|
|
5858
|
+
*/
|
|
5859
|
+
fulfill(options: {
|
|
5860
|
+
/**
|
|
5861
|
+
* Optional body of the response, can be a string or an ArrayBuffer.
|
|
5862
|
+
*/
|
|
5863
|
+
body?: string | ArrayBuffer;
|
|
5864
|
+
/**
|
|
5865
|
+
* Optional content type of the response.
|
|
5866
|
+
*/
|
|
5867
|
+
contentType?: string;
|
|
5868
|
+
/**
|
|
5869
|
+
* Optional HTTP headers to return.
|
|
5870
|
+
*/
|
|
5871
|
+
headers?: { [key: string]: string };
|
|
5872
|
+
/**
|
|
5873
|
+
* Optional HTTP status code to return. Defaults to `200`.
|
|
5874
|
+
*/
|
|
5875
|
+
status?: number;
|
|
5876
|
+
}): Promise<void>;
|
|
5877
|
+
|
|
5878
|
+
/**
|
|
5879
|
+
* Returns the matching request that this route is handling.
|
|
5880
|
+
*/
|
|
5881
|
+
request(): Request;
|
|
5882
|
+
}
|
|
5883
|
+
|
|
4092
5884
|
/**
|
|
4093
5885
|
* Touchscreen provides an api for interacting with a virtual touchscreen. It
|
|
4094
5886
|
* operates in main-frame CSS pixels relative to the top-left corner of the
|