The Remote Chrome Context For Testing Like Webdriver.
npm install @contexts/chrome
@contexts/chrome is The Remote Chrome Context For Testing Like Webdriver.
``sh`
yarn add -E @contexts/chrome
- Table Of Contents
- API
- class ChromeContext
* async navigate(url: string)
async evaluate(expression: string, json?: boolean): Page
* get Network
* get
- Copyright
The package is available by importing its default function:
`js`
import ChromeContext from '@contexts/chrome'
The class can be used either as a context, or as a persistent context in _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
`
Navigates to a webpage.
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`.
The enabled page.
The enabled network.
![]() | © Art Deco for Depack 2019 | ![]() | Tech Nation Visa Sucks |
|---|