Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/src/api/class-elementhandle.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,8 @@ Throws for non-input elements. However, if the element is inside the `<label>` e
### option: ElementHandle.inputValue.timeout = %%-input-timeout-js-%%
* since: v1.13

### option: ElementHandle.inputValue.signal = %%-input-signal-%%

## async method: ElementHandle.isChecked
* since: v1.8
* discouraged: Use locator-based [`method: Locator.isChecked`] instead. Read more about [locators](../locators.md).
Expand Down
11 changes: 11 additions & 0 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12979,6 +12979,17 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* @param options
*/
inputValue(options?: {
/**
* Allows to cancel the operation using an
* [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
* operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
* which can be changed using
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
* `timeout: 0` to disable the timeout entirely.
*/
signal?: AbortSignal;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down
8 changes: 6 additions & 2 deletions packages/playwright-core/src/client/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3238,8 +3238,12 @@ export type ElementHandleInnerTextOptions = {};
export type ElementHandleInnerTextResult = {
value: string,
};
export type ElementHandleInputValueParams = {};
export type ElementHandleInputValueOptions = {};
export type ElementHandleInputValueParams = {
timeout: number,
};
export type ElementHandleInputValueOptions = {

};
export type ElementHandleInputValueResult = {
value: string,
};
Expand Down
4 changes: 2 additions & 2 deletions packages/playwright-core/src/client/elementHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class ElementHandle<T extends Node = Node> extends JSHandle<T> implements
return value === undefined ? null : value;
}

async inputValue(): Promise<string> {
return (await this._elementChannel.inputValue({}, undefined)).value;
async inputValue(options: channels.ElementHandleInputValueOptions & TimeoutOptions = {}): Promise<string> {
return (await this._elementChannel.inputValue({ ...options, timeout: this._frame._timeout(options) }, options.signal)).value;
}

async textContent(): Promise<string | null> {
Expand Down
4 changes: 3 additions & 1 deletion packages/playwright-core/src/protocol/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,9 @@ scheme.ElementHandleInnerTextParams = tOptional(tObject({}));
scheme.ElementHandleInnerTextResult = tObject({
value: tString,
});
scheme.ElementHandleInputValueParams = tOptional(tObject({}));
scheme.ElementHandleInputValueParams = tObject({
timeout: tFloat,
});
scheme.ElementHandleInputValueResult = tObject({
value: tString,
});
Expand Down
8 changes: 6 additions & 2 deletions packages/playwright-core/src/server/channels.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3241,8 +3241,12 @@ export type ElementHandleInnerTextOptions = {};
export type ElementHandleInnerTextResult = {
value: string,
};
export type ElementHandleInputValueParams = {};
export type ElementHandleInputValueOptions = {};
export type ElementHandleInputValueParams = {
timeout: number,
};
export type ElementHandleInputValueOptions = {

};
export type ElementHandleInputValueResult = {
value: string,
};
Expand Down
11 changes: 11 additions & 0 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12979,6 +12979,17 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
* @param options
*/
inputValue(options?: {
/**
* Allows to cancel the operation using an
* [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal). If the signal is aborted, the
* operation will be aborted and throw an error. Note that providing a signal does not disable the default timeout,
* which can be changed using
* [browserContext.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-browsercontext#browser-context-set-default-timeout)
* or [page.setDefaultTimeout(timeout)](https://playwright.dev/docs/api/class-page#page-set-default-timeout); pass
* `timeout: 0` to disable the timeout entirely.
*/
signal?: AbortSignal;

/**
* Maximum time in milliseconds. Defaults to `0` - no timeout. The default value can be changed via `actionTimeout`
* option in the config, or by using the
Expand Down
2 changes: 2 additions & 0 deletions packages/protocol/spec/handles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ ElementHandle:
inputValue:
title: Get input value
group: getter
parameters:
timeout: float
returns:
value: string
flags:
Expand Down
Loading