Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dpck/chrome
The Remote Chrome Context For Testing Like Webdriver.
https://github.com/dpck/chrome
Last synced: about 1 month ago
JSON representation
The Remote Chrome Context For Testing Like Webdriver.
- Host: GitHub
- URL: https://github.com/dpck/chrome
- Owner: dpck
- License: mit
- Created: 2019-03-20T13:49:29.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-20T14:23:22.000Z (almost 6 years ago)
- Last Synced: 2024-11-05T08:39:13.261Z (about 2 months ago)
- Language: JavaScript
- Homepage: https://artd.eco/depack
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @contexts/chrome
[![npm version](https://badge.fury.io/js/%40contexts%2Fchrome.svg)](https://npmjs.org/package/@contexts/chrome)
`@contexts/chrome` is The Remote Chrome Context For Testing Like Webdriver.
```sh
yarn add -E @contexts/chrome
```## Table Of Contents
- [Table Of Contents](#table-of-contents)
- [API](#api)
- [class `ChromeContext`](#class-chromecontext)
* [`async navigate(url: string)`](#async-navigateurl-string-void)
* [`async evaluate(expression: string, json?: boolean): *`](#async-evaluateexpression-stringjson-boolean-)
* [get `Page`](#get-page)
* [get `Network`](#get-network)
- [Copyright](#copyright)## API
The package is available by importing its default function:
```js
import ChromeContext from '@contexts/chrome'
```## class `ChromeContext`
The class can be used either as a context, or as a persistent context in [_Zoroaster_](https://github.com/contexttesting/zoroaster) testing framework to eliminate the need to manually write set-up and tear-down routines in tests. The context will connect to a headless chrome and expose API for testing.
```js
import { ok } from 'zoroaster/assert'
import ChromeContext from '@contexts/chrome'/** @type {Object.} */
const T = {
persistentContext: ChromeContext,
async 'navigates to a web page'({ Page, evaluate, navigate }) {
await navigate('about:blank')
await Page.loadEventFired()
const { value } = await evaluate('window.navigator.userAgent', false)
ok(/HeadlessChrome/.test(value))
},
}export default T
```### `async navigate(`
`url: string,`
`): void`Navigates to a webpage.
### `async evaluate(`
`expression: string,`
`json?: boolean,`
`): *`Evaluates an expression and returns the result. By default, the outcome will be serialised on the client and deserialised on the receiving end by the context using JSON to enable passing objects. To disable that, the `json` argument should be set to `false`.
### get `Page`
The enabled page.
### get `Network`
The enabled network.
## Copyright
© Art Deco for Depack 2019Tech Nation Visa Sucks