feat(Frame): introduce Frame.select

This patch adds `Frame.select` method that does the same functionality as
former `Page.select`, but on a per-frame level.

The `Page.select` method becomes a shortcut for the ÷main frame's select.

Fixes #1139
This commit is contained in:
Suvrat Jain
2017-11-02 10:36:04 +05:30
committed by Andrey Lushnikov
parent bc7f211474
commit fede2643ac
3 changed files with 38 additions and 12 deletions

View File

@@ -128,6 +128,7 @@
* [frame.isDetached()](#frameisdetached)
* [frame.name()](#framename)
* [frame.parentFrame()](#frameparentframe)
* [frame.select(selector, ...values)](#frameselectselector-values)
* [frame.title()](#frametitle)
* [frame.url()](#frameurl)
* [frame.waitFor(selectorOrFunctionOrTimeout[, options[, ...args]])](#framewaitforselectororfunctionortimeout-options-args)
@@ -932,13 +933,15 @@ Shortcut for [page.mainFrame().executionContext().queryObjects(prototypeHandle)]
- returns: <[Promise]<[Array]<[string]>>> Returns an array of option values that have been successfully selected.
Triggers a `change` and `input` event once all the provided options have been selected.
If there's no `<select>` element matching `selector`, the method throws an error.
If there's no `<select>` element matching `selector`, the method throws an error.
```js
page.select('select#colors', 'blue'); // single selection
page.select('select#colors', 'red', 'green', 'blue'); // multiple selections
```
Shortcut for [page.mainFrame.select()](#frameselectselector-values)
#### page.setContent(html, options)
- `html` <[string]> HTML markup to assign to the page.
- `options` <[Object]> Navigation parameters which might have the following properties:
@@ -1504,6 +1507,19 @@ If the name is empty, returns the id attribute instead.
#### frame.parentFrame()
- returns: <[Frame]> Returns parent frame, if any. Detached frames and main frames return `null`.
#### frame.select(selector, ...values)
- `selector` <[string]> A [selector] to query frame for
- `...values` <...[string]> Values of options to select. If the `<select>` has the `multiple` attribute, all values are considered, otherwise only the first one is taken into account.
- returns: <[Promise]<[string]>>
Triggers a `change` and `input` event once all the provided options have been selected.
If there's no `<select>` element matching `selector`, the method throws an error.
```js
frame.select('select#colors', 'blue'); // single selection
frame.select('select#colors', 'red', 'green', 'blue'); // multiple selections
```
#### frame.title()
- returns: <[Promise]<[string]>> Returns page's title.