new Finder()
- Source:
Extends
Methods
allowWindowClose() → {FinderBase}
- Description:
Declare that the action closes the window itself, like clicking a link calling window.close(). Such an action can not return its result because the page is already gone, which is reported as an error like "Target page, context or browser has been closed". This method makes the action ignore that error.
- Source:
- Overrides:
Example
const newWin = await page.waitForNewWindow(()=>{ ... })
await newWin.page.find("a.close-link").allowWindowClose().click();
Returns:
new finder object
- Type
- FinderBase
attachFile(filePath, options) → {Promise}
- Description:
Attach the file given with filePath. This method implemented at FinderExtentions by Browser. so please read api-document of FinderExtentions you use.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | Specify the path of the file to be attached |
options |
object | options given to FinderExtentions |
Returns:
- Type
- Promise
attribute() → {Promise}
- Description:
Get a attribute of element which is found first by Finder.
- Source:
- Overrides:
Returns:
Promise resolved with element.attributes[attrName].value
- Type
- Promise
beChecked() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have been checked
- Type
- Finder
beSelected() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have been selected
- Type
- Finder
beVisible() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which is visible (extracted by checkVisibility)
- Type
- Finder
check() → {Promise}
- Description:
Set "checked" property true on all elements which is found by Finder
- Source:
- Overrides:
Returns:
- Type
- Promise
checked() → {Promise}
- Description:
Get a value of element.checked which is found first by Finder.
- Source:
- Overrides:
Returns:
Promise resolved with element.checked
- Type
- Promise
chooseRadioButton() → {Promise}
- Description:
Alias of "click"
- Source:
- Overrides:
Returns:
- Type
- Promise
click() → {Promise}
- Description:
Click an element which is found first by Finder
- Source:
- Overrides:
Returns:
Promise resolved after click event
- Type
- Promise
clone(callback) → {Object}
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | Optional. if callback function given, it is called with the cloned as argument |
Returns:
cloned object
- Type
- Object
closest() → {Finder}
- Source:
- Overrides:
Returns:
return Finder object for the closest node.
- Type
- Finder
count() → {Promise}
- Description:
Get a count of elements which is found by Finder.
- Source:
- Overrides:
Returns:
Promise resolved with matched number
- Type
- Promise
evaluate() → {Promise}
- Description:
Evaluate this finder and resolve with the result (the match count, or the action result).
- Source:
- Overrides:
Returns:
Promise resolved in evaluated JavaScript code
- Type
- Promise
evaluateAction() → {Promise}
- Description:
Evaluate as a action (used by click, fillIn, check, ...). The difference from
evaluate()is how it behaves when an element is not found. When config.autoWaiting.enabled is false, throws "Element not found" error. When config.autoWaiting.enabled is true, retries until the target element exists, is visible and is not disabled. When config.slowMotion is over 0, wait that msec before running the action.
- Source:
- Overrides:
Returns:
Promise resolved in evaluated JavaScript code
- Type
- Promise
every()
- Description:
return true if all elements which is found by Finder satisfied given filter
- Source:
Example
await page.find("input").every(FinderFilter.haveValue("123")) // return true or false
executeJs() → {Promise}
- Description:
execute "JavaScript code" given as argument
- Source:
Returns:
- Type
- Promise
exist() → {Promise}
- Source:
- Overrides:
Returns:
return true if count of elements which is found by Finder is over one.
- Type
- Promise
fillIn(text, options) → {Promise}
- Description:
Fill the given text into the element as a user does with the keyboard. Unlike setValue() which assigns the value by script, the browser itself types it, so frameworks (React and so on) recognize it as a real user input. This method implemented at FinderExtentions by Browser. so please read api-document of FinderExtentions you use.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | text to be filled in |
options |
object | options given to FinderExtentions |
Returns:
- Type
- Promise
find() → {FinderBase}
- Source:
- Overrides:
Returns:
new finder object which have added conditions
- Type
- FinderBase
first() → {Finder}
- Source:
- Overrides:
Returns:
return Finder for the first matched element. this is same to "indexOf(0)"
- Type
- Finder
haveAttribute() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have specified attrName. If value given, return filtered Finder object which have specified attribute-value
- Type
- Finder
haveContent() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have the specified text
- Type
- Finder
haveCssClass() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have specified CssClass
- Type
- Finder
haveCssProperty() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have specified CssProperty
- Type
- Finder
haveText() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have the specified text
- Type
- Finder
haveValue() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which have the specified value
- Type
- Finder
inIframe(finderForIframe) → {Finder}
- Description:
Make this finder object executed in given iframe.
- Source:
Example
await page.find("h3").inIframe(page.find("iframe").first()).text()
Parameters:
| Name | Type | Description |
|---|---|---|
finderForIframe |
Finder | finder object for iframe |
Returns:
- Type
- Finder
indexOf() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which is in given index in elements
- Type
- Finder
isClickable() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which is clickable like a, button, input[type=button]
- Type
- Finder
keydown(options) → {Promise}
- Description:
Press given key on element which is found by Finder.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | options is passed to the KeyboardEvent constructor. The default value is the Enter key. |
Returns:
- Type
- Promise
map() → {FinderBase}
- Source:
- Overrides:
Returns:
new finder object with added mapping function
- Type
- FinderBase
noWait() → {FinderBase}
- Description:
Disable auto-waiting for this finder. The action is executed immediately even when config.autoWaiting.enabled is true. If target element is not found when called, throw exception.
- Source:
- Overrides:
Returns:
new finder object
- Type
- FinderBase
notBeChecked() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which do not have been checked
- Type
- Finder
notBeSelected() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which do not have been selected
- Type
- Finder
notExist() → {Promise}
- Source:
- Overrides:
Returns:
return true if count of elements which is found by Finder is zero.
- Type
- Promise
notHaveAttribute() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which do not have specified attrName. If value given, return filtered Finder object which do not have specified attribute-value.
- Type
- Finder
notHaveContent() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which does not have the specified text
- Type
- Finder
notHaveCssClass() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which do not have specified CssClass
- Type
- Finder
notHaveCssProperty() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which do not have specified CssProperty
- Type
- Finder
notHaveText() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which does not have the specified text
- Type
- Finder
notHaveValue() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object which does not have the specified value
- Type
- Finder
parent() → {Finder}
- Source:
- Overrides:
Returns:
return Finder object for the parent element.
- Type
- Finder
select() → {Promise}
- Description:
Set "selected" property true on element which is found by Finder. This method is supposed to be called on the "option" element
- Source:
- Overrides:
Returns:
- Type
- Promise
selectOption() → {Promise}
- Description:
Set "selected" property true on option element whose textContent match the given string. This method is assumed to be called on a select element This method is the same as `page.find("select").find("option").haveText(content).select();
- Source:
Returns:
- Type
- Promise
setText() → {Promise}
- Description:
Set given text to textContent of all elements which is found by Finder
- Source:
- Overrides:
Returns:
Promise resolved after setting textContent
- Type
- Promise
setValue(val, options) → {Promise}
- Description:
Set given value to value of all elements which is found by Finder. Unlike fillIn(), this assigns the value by script and does not move the focus by default.
- Source:
- Overrides:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
val |
string | value to be set |
||||||
options |
object |
Properties
|
Returns:
Promise resolved after setting value
- Type
- Promise
submit() → {Promise}
- Description:
Submit the form as if pressing Enter on an element within the form
- Source:
- Overrides:
Returns:
- Type
- Promise
text(options) → {Promise}
- Description:
Get a textContent of element which is found first by Finder.
- Source:
- Overrides:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
Returns:
Promise resolved with element.textContent
- Type
- Promise
textIncludes() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object whose textContent includes given content
- Type
- Finder
textMatch() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object whose textContent matches given regexp
- Type
- Finder
toArray() → {Promise}
- Source:
Returns:
Promise which resolved with array of finder, that array length is matched number
- Type
- Promise
toJsCode(options) → {string}
- Description:
generate and return javascript code for finding element by this finder object
- Source:
- Overrides:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Properties
|
Returns:
- Type
- string
uncheck() → {Promise}
- Description:
Set "checked" property true on all elements which is found by Finder
- Source:
- Overrides:
Returns:
- Type
- Promise
value() → {Promise}
- Description:
Get a value of element which is found first by Finder.
- Source:
- Overrides:
Returns:
Promise resolved with element.value
- Type
- Promise
valueIncludes() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object whose value includes given value
- Type
- Finder
valueMatch() → {Finder}
- Source:
- Overrides:
Returns:
return filtered Finder object whose value matches given regexp
- Type
- Finder
waitTimeout(msec) → {FinderBase}
- Description:
Override the auto-waiting timeout for this finder.
- Source:
- Overrides:
Parameters:
| Name | Type | Description |
|---|---|---|
msec |
number | timeout in milliseconds |
Returns:
new finder object
- Type
- FinderBase
withRetry(opts) → {FinderBase}
- Description:
Make evaluate() poll (retry) until the target condition is met, or the timeout elapses.
- Source:
- Overrides:
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object |
Properties
|
Returns:
new finder object
- Type
- FinderBase