Utility node.js library for Chrome Webview traversal and manipulation.
npm install webview-query --save
For example, you have NW.js app with webview tag within.
html:
<webview id="view1"></webview>
js:
const { Webview } = require('webview-query');
const webview = new Webview(view1);
// inside async function:
await webview.location('https://github.com');
console.log(await webview.title());
// -> "The world's leading software development platform · GitHub"
console.log(await webview.text('.jumbotron h1'));
// -> "Built for developers"
webview.val('form.home-hero-signup input[id="user[login]"]', 'Hello GitHub!');
- webview
Chrome webview element
Kind: global class
- Webview
- new Webview(webview)
- .webview :
webview
- .runJs(code) ⇒
Promise
- .title(value) ⇒
Promise
- .location(value) ⇒
Promise
- .exists(selector) ⇒
Promise.<boolean>
- .length(selector) ⇒
Promise.<number>
- .val(selector, value) ⇒
Promise
- .attr(selector, attribute, value) ⇒
Promise
- .text(selector, value) ⇒
Promise
- .html(selector, value, [options]) ⇒
Promise
- .click(selector) ⇒
Promise
Webview is a class for Chrome webview promise-based traversal and manipulation.
Param | Type | Description |
---|---|---|
webview | webview |
Chrome webview element. |
webview.webview : webview
Kind: instance property of Webview
Run arbitrary javascript code inside webview context.
Kind: instance method of Webview
Returns: Promise
- Promise object represents the result of the script.
Param | Type | Description |
---|---|---|
code | string |
Javascript code. |
Set webview document new title.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
value | string |
New document title. |
Set webview new location.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
value | string |
URL or path to local file. |
Check the existence of an element(s).
Kind: instance method of Webview
Returns: Promise.<boolean>
- Promise object represents the element(s) existence.
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
Return number of elements matched by selector.
Kind: instance method of Webview
Returns: Promise.<number>
- Promise object represents the number of elements currently matched..
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
Set the value of every matched element.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
value | string |
Value to set. |
Set an attribute for every matched element.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
attribute | string |
The name of the attribute to set. |
value | string |
A value to set for the attribute.. |
Set the text contents of the matched elements.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
value | string |
The text to set as the content of each matched element. |
Set the HTML contents of every matched element.
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
value | string |
A string of HTML to set as the content of each matched element. |
[options] | object |
Options. |
[options.outer] | boolean |
If true the result will be outer HTML, inner HTML otherwise. |
Execute click action for the matched element(s).
Kind: instance method of Webview
Param | Type | Description |
---|---|---|
selector | string |
CSS selector. |
Chrome webview element
Kind: global external
See: https://developer.chrome.com/apps/tags/webview