Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Infrastructure
    • Rize

Implements

  • Actions
  • Assertions
  • Basic
  • Page
  • Retrieval

Index

Constructors

constructor

  • Creates an instance of Rize.

    Parameters

    • Default value options: LaunchOptions & RizeOptions = {}

    Returns Rize

Accessors

browser

browser:

Low-level instance of puppeteer's browser.

page

page:

Low-level instance of puppeteer's current page.

Methods

addClass

  • addClass(selector: string, className: string): this
  • Add a class to an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.addClass('div', 'class-you-want-to-add')
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Class name.

    Returns this

addScriptTag

  • addScriptTag(type: "url" | "path" | "content", value: string, options?: object): this
  • Add a <script> tag to page. Note that the <script> tag will be appended to <head> section.

    If you pass url to argument type, you should specify a JavaScript file URL in argument value.

    If you pass path to argument type, you should specify a path to a JavaScript file in argument value.

    If you pass content to argument type, you should pass pure JavaScript code in argument value.

    Additional Notes:

    If your script is written in ES module, you can pass esModule: true to the options argument.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.addScriptTag('url', 'https://example.org/script.js')
    rize.addScriptTag('path', 'path/to/file.js')
    rize.addScriptTag('content', 'console.log("Pure JS code.")')
    

    Parameters

    • type: "url" | "path" | "content"

      Can be url, path or content.

    • value: string
    • Default value options: object = { esModule: false }
      • esModule: boolean

    Returns this

addStyleTag

  • addStyleTag(type: keyof StyleTagOptions, value: string): this
  • Add a <style> tag to page. Note that the <style> tag will be appended to <head> section.

    If you pass url to argument type, you should specify a CSS file URL in argument value.

    If you pass path to argument type, you should specify a path to a CSS file in argument value.

    If you pass content to argument type, you should pass pure CSS code in argument value.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.addStyleTag('url', 'https://example.org/style.css')
    rize.addStyleTag('path', 'path/to/file.css')
    rize.addStyleTag('content', 'div { font-size: 5px; }')
    

    Parameters

    • type: keyof StyleTagOptions

      Can be url, path or content.

    • value: string

    Returns this

assertAttribute

  • assertAttribute(selector: string, attribute: string, value: string): this
  • Assert that an element by the given selector has the given attribute and value.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div class="rabbit-house"></div>
    
    const rize = new Rize()
    rize.assertAttribute('div', 'class', 'rabbit-house')
    

    Parameters

    • selector: string

      CSS selector.

    • attribute: string

      Attribute name.

    • value: string

      Expected value.

    Returns this

assertChecked

  • assertChecked(selector: string): this
  • Assert that the given checkbox has been checked.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input type="checkbox" checked />
    
    const rize = new Rize()
    rize.assertChecked('input')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertClassHas

  • assertClassHas(selector: string, className: string): this
  • Assert that an element by given selector has the given class name.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div class="rabbit-house"></div>
    
    const rize = new Rize()
    rize.assertClassHas('div', 'rabbit-house')
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Expected class name.

    Returns this

assertClassMissing

  • assertClassMissing(selector: string, className: string): this
  • Assert that the given element does not have the given class name.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div class="rabbit-house"></div>
    
    const rize = new Rize()
    rize.assertClassMissing('div', 'rabbit')
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Class name.

    Returns this

assertCookieHas

  • assertCookieHas(name: string, value?: undefined | string): this
  • Assert that the cookie of current page has the given name and value.

    You can pass an expected value as the second argument. Then it will check the value of given name in cookie.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertCookieHas('name')
    rize.assertCookieHas('name', 'value')
    

    Parameters

    • name: string

      Expected cookie name.

    • Optional value: undefined | string

      Expected cookie value.

    Returns this

assertDontSee

  • assertDontSee(text: string): this
  • Assert that the given text appears on the page.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertDontSee('Nothing in HTML.')
    

    Parameters

    • text: string

      Expected text.

    Returns this

assertDontSeeIn

  • assertDontSeeIn(selector: string, text: string): this
  • Assert that the given text does not appear within the given selector.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div class="my-class">some text in HTML</div>
    
    const rize = new Rize()
    rize.assertDontSeeIn('.my-class', 'nothing')
    

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Expected text you don't want to see.

    Returns this

assertElementHidden

  • assertElementHidden(selector: string): this
  • Assert that the given element is hidden.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertElementHidden('div')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertElementMissing

  • assertElementMissing(selector: string): this
  • Assert that the given element is missing.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertElementMissing('.nope')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertElementPresent

  • assertElementPresent(selector: string): this
  • Assert that the given element is present, though it is not visible.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertElementPresent('div')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertElementVisible

  • assertElementVisible(selector: string): this
  • Assert that the given element is visible.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertElementVisible('div')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertHashBeginsWith

  • assertHashBeginsWith(expected: string): this
  • Assert that the current hash begins with the given string.

    since

    0.5.0

    example
    
    // Suppose the URL is "http://localhost/#rabbit-house"
    
    const rize = new Rize()
    rize.assertHashBeginsWith('rabbit')
    rize.assertHashBeginsWith('#rabbit')
    

    Parameters

    • expected: string

      Expected string.

    Returns this

assertHashIs

  • assertHashIs(expected: string): this
  • Assert that the current hash equals the given string.

    since

    0.5.0

    example
    
    // Suppose the URL is "http://localhost/#rize"
    
    const rize = new Rize()
    rize.assertHashIs('rize')
    rize.assertHashIs('#rize')
    

    Parameters

    • expected: string

      Expected hash.

    Returns this

assertNotChecked

  • assertNotChecked(selector: string): this
  • Assert that the given checkbox has not been checked.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input type="checkbox" />
    
    const rize = new Rize()
    rize.assertNotChecked('input')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

assertNotSelected

  • assertNotSelected(selector: string, value: string): this
  • Assert that the given <option> element has not been selected.

    The selector argument should point to a <select> element.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <select>
      <option value="chino" />
      <option value="cocoa" />
      <option value="rize" selected />
    </select>
    
    const rize = new Rize()
    rize.assertNotSelected('select', 'chino')
    

    Parameters

    • selector: string

      CSS selector which points to a <select> element.

    • value: string

      Value of <option> element.

    Returns this

assertPathBeginsWith

  • assertPathBeginsWith(expected: string): this
  • Assert that the current path begins with the given string.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/rabbit-house/rize"
    
    const rize = new Rize()
    rize.assertPathBeginsWith('/rabbit-house')
    

    Parameters

    • expected: string

      Expected string.

    Returns this

assertPathIs

  • assertPathIs(expected: string): this
  • Assert that the current path matches the given path.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/rabbit-house/rize"
    
    const rize = new Rize()
    rize.assertPathIs('/rabbit-house/rize')
    

    Parameters

    • expected: string

      Expected path.

    Returns this

assertQueryStringHas

  • assertQueryStringHas(key: string, value?: undefined | string): this
  • Assert that query string has the given key.

    You can pass an expected value as the second argument. Then it will check the value of given key in query string.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/?key=value"
    
    const rize = new Rize()
    rize.assertQueryStringHas('key')
    rize.assertQueryStringHas('key', 'value')
    

    Parameters

    • key: string

      Expected key in query string.

    • Optional value: undefined | string

      Expected value of a key in query string.

    Returns this

assertQueryStringMissing

  • assertQueryStringMissing(key: string): this
  • Assert that the given key is not in query string.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/?key=value"
    
    const rize = new Rize()
    rize.assertQueryStringMissing('nope')
    

    Parameters

    • key: string

      Expected missing key.

    Returns this

assertRadioNotSelected

  • assertRadioNotSelected(selector: string, value: string): this
  • Assert that the given radio button has not been selected.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input type="radio" name="characters" value="rize" checked />
    <input type="radio" name="characters" value="chino" />
    
    const rize = new Rize()
    rize.assertRadioNotSelected('input', 'chino')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Radio button value.

    Returns this

assertRadioSelected

  • assertRadioSelected(selector: string, value: string): this
  • Assert that the given radio button has been selected.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input type="radio" name="characters" value="rize" checked />
    <input type="radio" name="characters" value="chino" />
    
    const rize = new Rize()
    rize.assertRadioSelected('input', 'rize')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Radio button value.

    Returns this

assertSee

  • assertSee(text: string): this
  • Assert that the page contains the given text.

    Text created and rendered by JavaScript dynamically is acceptable.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.assertSee('some text in HTML.')
    

    Parameters

    • text: string

      Expected text.

    Returns this

assertSeeIn

  • assertSeeIn(selector: string, text: string): this
  • Assert that the given text can be found by the given selector.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div class="my-class">some text in HTML</div>
    
    const rize = new Rize()
    rize.assertSeeIn('.my-class', 'some text in HTML')
    

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Expected text you don't want to see.

    Returns this

assertSelected

  • assertSelected(selector: string, value: string): this
  • Assert that the given <option> element has been selected.

    The selector argument should point to a <select> element.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <select>
      <option value="chino" />
      <option value="cocoa" />
      <option value="rize" selected />
    </select>
    
    const rize = new Rize()
    rize.assertSelected('select', 'rize')
    

    Parameters

    • selector: string

      CSS selector which points to a <select> element.

    • value: string

      Value of <option> element.

    Returns this

assertStyleHas

  • assertStyleHas(selector: string, property: string, value: string): this
  • Assert that an element has the given style.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <div style="font-size: 5px"></div>
    
    const rize = new Rize()
    rize.assertStyleHas('div', 'font-size', '5px')
    

    Parameters

    • selector: string

      CSS selector.

    • property: string

      CSS property.

    • value: string

      CSS value.

    Returns this

assertTitle

  • assertTitle(title: string): this
  • Assert that current page title matches the given title.

    since

    0.1.0

    example
    
    // Suppose the title of page is "Tedeza Rize".
    
    const rize = new Rize()
    rize.assertTitle('Tedeza Rize')
    

    Parameters

    • title: string

      Expected title.

    Returns this

assertTitleContains

  • assertTitleContains(title: string): this
  • Assert that current page title contains the give string.

    since

    0.1.0

    example
    
    // Suppose the title of page is "Tedeza Rize".
    
    const rize = new Rize()
    rize.assertTitleContains('Rize')
    

    Parameters

    • title: string

      Expected string.

    Returns this

assertTitleMatch

  • assertTitleMatch(regex: RegExp | string): this
  • Assert that title of current page matches the given regular expression.

    since

    0.1.0

    example
    
    // Suppose the title of page is "Tedeza Rize".
    
    const rize = new Rize()
    rize.assertTitleMatch('Rize$')
    rize.assertTitleMatch(/Rize$/)
    

    Parameters

    • regex: RegExp | string

      Regular expression.

    Returns this

assertUrlIs

  • assertUrlIs(expected: string): this
  • Assert that the current URL matches the given URL.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/"
    
    const rize = new Rize()
    rize.assertUrlIs('http://localhost/')
    

    Parameters

    • expected: string

      Expected URL.

    Returns this

assertUrlMatch

  • assertUrlMatch(regex: RegExp | string): this
  • Assert that the current URL matches the given regular expression.

    since

    0.1.0

    example
    
    // Suppose the URL is "http://localhost/"
    
    const rize = new Rize()
    rize.assertUrlMatch('^http')
    rize.assertUrlMatch(/^http/)
    

    Parameters

    • regex: RegExp | string

      Regular expression.

    Returns this

assertValueContains

  • assertValueContains(selector: string, value: string): this
  • Assert that the given element contains expected value.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input value="value" />
    
    const rize = new Rize()
    rize.assertValueContains('input', 'val')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Expected value.

    Returns this

assertValueIs

  • assertValueIs(selector: string, value: string): this
  • Assert that the given element has expected value.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input value="val" />
    
    const rize = new Rize()
    rize.assertValueIs('input', 'val')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Expected value.

    Returns this

assertValueIsNot

  • assertValueIsNot(selector: string, value: string): this
  • Assert that the given element does not have expected value.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <input value="val" />
    
    const rize = new Rize()
    rize.assertValueIsNot('input', 'value')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Expected value.

    Returns this

attribute

  • attribute(selector: string, attribute: string): Promise<string | null>
  • Retrieve an attribute of an element.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const classes = await rize.attribute('div', 'class')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    • attribute: string

      Attribute name.

    Returns Promise<string | null>

    Attribute value.

awaitPromise

  • awaitPromise(): Promise<void>
  • Return an empty Promise object.

    since

    0.6.0

    example
    
    (async () => {
      const rize = new Rize()
      await rize.awaitPromise()
    })()
    

    Returns Promise<void>

back

  • back(options?: puppeteer.NavigationOptions): this

blur

  • blur(selector: string): this
  • Blur an element.

    since

    0.6.0

    example
    
    const rize = new Rize()
    rize.blur('a')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

check

  • check(selector: string): this
  • Check the given checkbox.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.check('input[type="checkbox"]')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

clear

  • clear(selector: string): this
  • Clear value of <input> element or text content of <textarea> element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.clear('input')
    rize.clear('textarea')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

click

  • click(selector: string): this
  • Click an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.click('button')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

clickLink

  • clickLink(text: string): this
  • Click an element which contains given text.

    since

    0.5.0

    example
    
    const rize = new Rize()
    rize.clickLink('click me')
    

    Parameters

    • text: string

      Text on the <a> element.

    Returns this

closePage

  • closePage(name?: undefined | string): this
  • Close current page, but it doesn't exit the browser.

    You cannot visit the page any more!

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.closePage()  // Close current active page.
    rize.closePage('page1')  // Close a specified page.
    

    Parameters

    • Optional name: undefined | string

      The name of page you want to close.

    Returns this

cookie

  • cookie(): Promise<Cookie>
  • Retrieve cookie of current page.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const cookie = await rize.cookie()
    })()
    

    Returns Promise<Cookie>

cookies

  • cookies(): Promise<Cookie[]>
  • Retrieve cookies of current page.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const cookies = await rize.cookies()
    })()
    

    Returns Promise<Cookie[]>

deleteCookie

  • deleteCookie(...cookies: DeleteCookie[]): this
  • Delete cookie(s).

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.deleteCookie({ name: 'name' })
    

    Parameters

    • Rest ...cookies: DeleteCookie[]

    Returns this

doubleClick

  • doubleClick(selector: string): this
  • Double click an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.doubleClick('button')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

end

  • end(): Promise<void>
  • end(callback: function): void
  • Exit browser and return a Promise.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.end().then(() => console.log('Browser has exited.'))
    

    Returns Promise<void>

  • Exit browser. You can pass a callback, and the callback will be called after browser exited.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.end(() => console.log('Browser has exited.'))
    

    Parameters

    • callback: function
        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    Returns void

evaluate

  • evaluate(fn: Function | string, ...args: any[]): this
  • Evaluate a function or an expression in browser.

    This method will not retrieve the return value and this method returns this to make API chainable. If you want to retrieve the return value, please use evaluateWithReturn method.

    Note that this function or expression will be evaluated in browser environment, not in Node.js environment. So you can visit variables in browser also you cannot visit variables in Node.js.

    If you want to execute a function in Node.js environment, please use execute method instead.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.evaluate(() => document.querySelector('div'))
    rize.evaluate(selector => document.querySelector(selector), 'div')
    rize.evaluate('document.querySelector("div")')
    

    Parameters

    • fn: Function | string

      Function or expression.

    • Rest ...args: any[]

      Arguments of function.

    Returns this

evaluateWithReturn

  • evaluateWithReturn<T>(fn: function | string, ...args: any[]): Promise<T>
  • Evaluate a function or an expression in browser and retrieve return value.

    Note that this function or expression will be evaluated in browser environment, not in Node.js environment. So you can visit variables in browser also you cannot visit variables in Node.js.

    If you want to execute a function in Node.js environment, please use execute method instead.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const title = await rize.evaluateWithReturn(() => document.title)
      const text = await rize.evaluateWithReturn('document.body.textContent')
    })()
    

    Type parameters

    • T

    Parameters

    • fn: function | string

      Function or expression.

    • Rest ...args: any[]

      Arguments of function.

    Returns Promise<T>

    Promise-wrapped return value of the given function.

execute

  • execute(fn: function): this
  • Execute a function.

    When you use function keyword (not arrow function), this context in the function points to current Rize instance.

    NOTE that the function will be executed in Node environment, not in browser.

    If you want to evaluate an function in browser environment, please use evaluate method instead.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.execute(function (browser, page) {
      this === rize  // true
      browser === rize.browser  // true
      page === rize.page  // true
    })
    

    Parameters

    • fn: function

      The function to be execute.

        • (this: Rize, browser: Browser, page: Page, ...args: any[]): void
        • Parameters

          • this: Rize
          • browser: Browser
          • page: Page
          • Rest ...args: any[]

          Returns void

    Returns this

find

  • find<T>(selector: string, fn: function): T
  • find<T, U1>(selector: string, fn: function, arg1: U1): T
  • find<T, U1, U2>(selector: string, fn: function, arg1: U1, arg2: U2): T
  • Find an element by CSS selector and execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.find('button#greeting', rize.click)
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const text = await rize.find('span#greeting', rize.text)
    })()
    

    Type parameters

    • T

    Parameters

    • selector: string

      CSS selector.

    • fn: function

      One of available Rize APIs.

        • (selector: string): T
        • Parameters

          • selector: string

          Returns T

    Returns T

    Return value of the operation.

  • Find an element by CSS selector and execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.find('input#name', rize.type, 'my-name')
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const font = await rize.find('span#greeting', rize.style, 'font-size')
    })()
    

    Type parameters

    • T

    • U1

    Parameters

    • selector: string

      CSS selector.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1): T
        • Parameters

          • selector: string
          • arg1: U1

          Returns T

    • arg1: U1

      The first argument of the operation.

    Returns T

    Return value of the operation.

  • Find an element by CSS selector and execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.find('div#message', rize.assertAttribute, 'id', 'message')
    

    Type parameters

    • T

    • U1

    • U2

    Parameters

    • selector: string

      CSS selector.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1, arg2: U2): T
        • Parameters

          • selector: string
          • arg1: U1
          • arg2: U2

          Returns T

    • arg1: U1

      The first argument of the operation.

    • arg2: U2

      The second argument of the operation.

    Returns T

    Return value of the operation.

findAll

  • findAll<T>(selector: string, index: number, fn: function): T
  • findAll<T, U1>(selector: string, index: number, fn: function, arg1: U1): T
  • findAll<T, U1, U2>(selector: string, index: number, fn: function, arg1: U1, arg2: U2): T
  • Find all elements by CSS selector and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findAll('button', 2, rize.click)
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const text = await rize.findAll('span', 2, rize.text)
    })()
    

    Type parameters

    • T

    Parameters

    • selector: string

      CSS selector.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string): T
        • Parameters

          • selector: string

          Returns T

    Returns T

    Return value of the operation.

  • Find all elements by CSS selector and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findAll('input', 1, rize.type, 'my-name')
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const font = await rize.findAll('span', 1, rize.style, 'font-size')
    })()
    

    Type parameters

    • T

    • U1

    Parameters

    • selector: string

      CSS selector.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1): T
        • Parameters

          • selector: string
          • arg1: U1

          Returns T

    • arg1: U1

      The first argument of the operation.

    Returns T

    Return value of the operation.

  • Find all elements by CSS selector and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findAll('div', 2, rize.assertAttribute, 'id', 'message')
    

    Type parameters

    • T

    • U1

    • U2

    Parameters

    • selector: string

      CSS selector.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1, arg2: U2): T
        • Parameters

          • selector: string
          • arg1: U1
          • arg2: U2

          Returns T

    • arg1: U1

      The first argument of the operation.

    • arg2: U2

      The second argument of the operation.

    Returns T

    Return value of the operation.

findByXPath

  • findByXPath<T>(expression: string, index: number, fn: function): T
  • findByXPath<T, U1>(expression: string, index: number, fn: function, arg1: U1): T
  • findByXPath<T, U1, U2>(expression: string, index: number, fn: function, arg1: U1, arg2: U2): T
  • Find all elements by XPath and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findByXPath('/html/body//div', 2, rize.click)
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const text = await rize.findByXPath('/html/body//span', 2, rize.text)
    })()
    

    Type parameters

    • T

    Parameters

    • expression: string

      XPath expression.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string): T
        • Parameters

          • selector: string

          Returns T

    Returns T

    Return value of the operation.

  • Find all elements by XPath and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findByXPath('/html/body//input', 1, rize.type, 'my-name')
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const font = await rize.findByXPath(
        '/html/body//span',
        1,
        rize.style,
        'font-size'
      )
    })()
    

    Type parameters

    • T

    • U1

    Parameters

    • expression: string

      XPath expression.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1): T
        • Parameters

          • selector: string
          • arg1: U1

          Returns T

    • arg1: U1

      The first argument of the operation.

    Returns T

    Return value of the operation.

  • Find all elements by XPath and pick one to execute an operation.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.findByXPath(
      '/html/body//div',
      2,
      rize.assertAttribute,
      'id',
      'message'
    )
    

    Type parameters

    • T

    • U1

    • U2

    Parameters

    • expression: string

      XPath expression.

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1, arg2: U2): T
        • Parameters

          • selector: string
          • arg1: U1
          • arg2: U2

          Returns T

    • arg1: U1

      The first argument of the operation.

    • arg2: U2

      The second argument of the operation.

    Returns T

    Return value of the operation.

findWithText

  • findWithText<T>(selector: string, text: string, index: number, fn: function): T
  • findWithText<T, U1>(selector: string, text: string, index: number, fn: function, arg1: U1): T
  • findWithText<T, U1, U2>(selector: string, text: string, index: number, fn: function, arg1: U1, arg2: U2): T
  • Find all elements by the given selector and given text and pick one to execute an operation.

    since

    0.3.0

    example
    
    const rize = new Rize()
    rize.findWithText('button', 'some-text', 2, rize.click)
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const text = await rize.findWithText('span', 'some-text', 2, rize.text)
    })()
    

    Type parameters

    • T

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Expected text that should be in a element,

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string): T
        • Parameters

          • selector: string

          Returns T

    Returns T

    Return value of the operation.

  • Find all elements by the given selector and given text and pick one to execute an operation.

    since

    0.3.0

    example
    
    const rize = new Rize()
    rize.findWithText('input', 'some-text', 1, rize.type, 'my-name')
    
    // or
    
    ;(async () => {
      const rize = new Rize()
      const font = await rize.findWithText(
        'span',
        'some-text',
        1,
        rize.style,
        'font-size'
      )
    })()
    

    Type parameters

    • T

    • U1

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Expected text that should be in a element,

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1): T
        • Parameters

          • selector: string
          • arg1: U1

          Returns T

    • arg1: U1

      The first argument of the operation.

    Returns T

    Return value of the operation.

  • Find all elements by the given selector and given text and pick one to execute an operation.

    since

    0.3.0

    example
    
    const rize = new Rize()
    rize.findWithText(
      'div',
      'some-text',
      2,
      rize.assertAttribute,
      'id',
      'message'
    )
    

    Type parameters

    • T

    • U1

    • U2

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Expected text that should be in a element,

    • index: number

      Index of the array of result. It starts from 0.

    • fn: function

      One of available Rize APIs.

        • (selector: string, arg1: U1, arg2: U2): T
        • Parameters

          • selector: string
          • arg1: U1
          • arg2: U2

          Returns T

    • arg1: U1

      The first argument of the operation.

    • arg2: U2

      The second argument of the operation.

    Returns T

    Return value of the operation.

focus

  • focus(selector: string): this
  • Focus on an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.focus('a')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

forward

  • forward(options?: puppeteer.NavigationOptions): this

goto

  • goto(url: string): this
  • Go to a give URL. If the URL cannot be accessed, an error will be threw.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.goto('https://github.com/')
    

    Parameters

    • url: string

      URL to be navigated.

    Returns this

hasClass

  • hasClass(selector: string, className: string): Promise<boolean>
  • Retrieve a boolean value indicates if an element has a given class name.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const exists = await rize.hasClass('div', 'pull-right')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Expected class name.

    Returns Promise<boolean>

hover

  • hover(selector: string): this
  • Hover on an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.hover('a')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

html

  • html(selector?: string, range?: "inner" | "outer"): Promise<string>
  • Retrieve inner HTML content.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const html = await rize.html()
      const divHtml = await rize.html('div')
      const outer = await rize.html('div', 'outer')
    })()
    

    Parameters

    • Default value selector: string = "html"

      CSS selector. Default is html.

    • Default value range: "inner" | "outer" = "inner"

      Determines retrieve inner HTML or outer HTML.

    Returns Promise<string>

isPresent

  • isPresent(selector: string): Promise<boolean>
  • Retrieve if an element is present.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const isPresent = await rize.isPresent('div.nope')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    Returns Promise<boolean>

isVisible

  • isVisible(selector: string): Promise<boolean>
  • Retrieve if an element is visible.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const isVisible = await rize.isVisible('div')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    Returns Promise<boolean>

keyDown

  • keyDown(key: string): this

keyUp

  • keyUp(key: string): this

mouseClick

  • mouseClick(x: number, y: number, options?: puppeteer.MousePressOptions): this
  • Click a mouse button at given coordinate.

    see

    https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#mouseclickoptions

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.mouseClick(1, 1)
    rize.mouseClick(1, 1, { button: 'right' })
    rize.mouseClick(1, 1, { clickCount: 2 })
    rize.mouseClick(1, 1, { button: 'right', clickCount: 2 })
    

    Parameters

    • x: number
    • y: number
    • Optional options: puppeteer.MousePressOptions

      puppeteer's mouse options.

    Returns this

mouseDown

  • mouseDown(button?: puppeteer.MouseButtons, clickCount?: number): this
  • Dispatches a mousedown event.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.mouseDown()
    rize.mouseDown('middle')
    rize.mouseDown('right')
    rize.mouseDown('left', 2)
    rize.mouseDown('right', 2)
    

    Parameters

    • Default value button: puppeteer.MouseButtons = "left"

      Mouse button. It can be left, 'rightormiddle`.

    • Default value clickCount: number = 1

      Click count.

    Returns this

mouseMoveTo

  • mouseMoveTo(x: number, y: number): this
  • Move mouse to the given coordinate.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.mouseMoveTo(1, 1)
    

    Parameters

    • x: number
    • y: number

    Returns this

mouseUp

  • mouseUp(button?: puppeteer.MouseButtons, clickCount?: number): this
  • Dispatches a mouseup event.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.mouseUp()
    rize.mouseUp('middle')
    rize.mouseUp('right')
    rize.mouseUp('left', 2)
    rize.mouseUp('right', 2)
    

    Parameters

    • Default value button: puppeteer.MouseButtons = "left"

      Mouse button. It can be left, 'rightormiddle`.

    • Default value clickCount: number = 1

      Click count.

    Returns this

newPage

  • newPage(name?: string, options?: object): this
  • Open a new page.

    This method has two options.

    If force is true, when you open a new page with duplicated name, existing page will be replaced with this new one. Otherwise, the existing page will be kept and no new page will be created.

    If stayCurrent is true, after opened a new page, the active page won't be changed. Otherwise, the active page will be switched to the new page.

    since

    0.2.0

    example
    
    const rize = new Rize()
    rize.newPage()
    rize.newPage('page1')
    rize.newPage('page1', { force: true })
    rize.newPage('page2', { stayCurrent: true })
    

    Parameters

    • Default value name: string = ""

      A string to identify the new page. It's useful when switching page.

    • Default value options: object = {}
      • Optional force?: undefined | true | false
      • Optional stayCurrent?: undefined | true | false

    Returns this

pagesCount

  • pagesCount(): Promise<number>
  • Retrieve the number of pages.

    since

    0.2.0

    example
    
    (async () => {
      const rize = new Rize()
      const count = await rize.pagesCount()
    })()
    

    Returns Promise<number>

press

  • press(key: string, selector?: undefined | string): this

queryString

  • queryString(key: string): Promise<string | string[] | undefined>
  • Retrieve value of a key in query string.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const value = await rize.queryString('key')
    })()
    

    Parameters

    • key: string

      Query string key.

    Returns Promise<string | string[] | undefined>

radio

  • radio(selector: string, value: string): this
  • Select the given value of a radio button field.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.radio('input[name="who"]', 'you')
    

    Parameters

    • selector: string

      CSS selector.

    • value: string

      Value of the radio button.

    Returns this

refresh

  • refresh(options?: puppeteer.NavigationOptions): this
  • Refresh current page.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.refresh()
    

    Parameters

    • Optional options: puppeteer.NavigationOptions

      puppeteer's navigation options.

    Returns this

removeClass

  • removeClass(selector: string, className: string): this
  • Remove an existing class

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.removeClass('div', 'class-already-existed')
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Existing class name.

    Returns this

rightClick

  • rightClick(selector: string): this
  • Right click an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.rightClick('body')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

savePDF

  • savePDF(path: string, options?: puppeteer.PDFOptions): this
  • Save a PDF file of current page.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.savePDF('/path/to/file.pdf')  // save to a absolute path
    rize.savePDF('save/file.pdf')  // save to a relative path (current directory)
    

    Parameters

    • path: string

      Path to PDF file.

    • Optional options: puppeteer.PDFOptions

      puppeteer's PDF options.

    Returns this

saveScreenshot

  • saveScreenshot(path: string, options?: puppeteer.ScreenshotOptions): this
  • Save a screenshot of current page.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.saveScreenshot('/path/to/file.png')  // save to a absolute path
    rize.saveScreenshot('pics/file.png')  // save to a relative path (current directory)
    

    Parameters

    • path: string

      Path to screenshot file.

    • Optional options: puppeteer.ScreenshotOptions

      puppeteer's screenshots options.

    Returns this

select

  • select(selector: string, values: string | string[]): this
  • Select one or more values on an <select> element.

    since

    0.1.0

    example

    Suppose the HTML structure:

    <body>
      <select id="single">
        <option>rize</option>
        <option selected>syaro</option>
      </select>
      <select multiple="multiple" id="multiple">
        <option>rize</option>
        <option>chino</option>
        <option>cocoa</option>
      </select>
    </body>
    
    const rize = new Rize()
    rize.select('#single', 'rize')  // Single choice
    rize.select('#multiple', ['chino', 'rize'])  // Multiple choices
    

    Parameters

    • selector: string

      CSS selector.

    • values: string | string[]

      Values you want to choose, which can be one or more.

    Returns this

sendChar

  • sendChar(char: string): this
  • Dispatches a keypress and input event. This does not send a keydown or keyup event.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.sendChar('呵')
    

    Parameters

    • char: string

      Character to send into the page.

    Returns this

setCookie

  • setCookie(...cookies: SetCookie[]): this
  • Set cookie(s).

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.setCookie({ name: 'name', value: 'value' })
    

    Parameters

    • Rest ...cookies: SetCookie[]

    Returns this

sleep

  • sleep(ms: number): this
  • Sleep and wait for a time.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.sleep(500)  // stop for 500ms
    

    Parameters

    • ms: number

      Time to sleep. The unit is millisecond.

    Returns this

style

  • style(selector: string, property: string): Promise<string>
  • Retrieve style value of an element.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const value = await rize.style('div', 'font-size')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    • property: string

      CSS property.

    Returns Promise<string>

switchPage

  • switchPage(name: string | number): this
  • Switch to another existing page.

    If the argument is a number, it will search the page by index in internal pages array and switch to it.

    If the argument is a string, it will search the page by the name and switch to it.

    since

    0.2.0

    example
    
    const rize = new Rize()
    rize.switchPage(0)
    rize.switchPage('page1')
    

    Parameters

    • name: string | number

      The index of the page or the name of the page.

    Returns this

text

  • text(selector?: string): Promise<string>
  • Retrieve text content.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const bodyText = await rize.text()
      const divText = await rize.text('div')
    })()
    

    Parameters

    • Default value selector: string = "body"

      CSS selector. Default is body.

    Returns Promise<string>

title

  • title(): Promise<string>
  • Retrieve the title of current page.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const title = await rize.title()
    })()
    

    Returns Promise<string>

toggleClass

  • toggleClass(selector: string, className: string): this
  • Toggle a class. If the given class name is existed, it will be removed. If the given class name is not existed, it will be added.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.toggleClass('div', 'class-name')
    

    Parameters

    • selector: string

      CSS selector.

    • className: string

      Class name.

    Returns this

type

  • type(selector: string, text: string): this
  • Type some text on an element.

    This method won't clear existing value of an element and it only will append the given text.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.type('input', 'text')
    

    Parameters

    • selector: string

      CSS selector.

    • text: string

      Text to be typed.

    Returns this

uncheck

  • uncheck(selector: string): this
  • Uncheck the given checkbox.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.uncheck('input[type="checkbox"]')
    

    Parameters

    • selector: string

      CSS selector.

    Returns this

uploadFile

  • uploadFile(selector: string, path: string): this
  • Send a file by the given path to an element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.uploadFile('input[type="file"]', '/path/to/file')
    

    Parameters

    • selector: string

      CSS selector.

    • path: string

      Path to file.

    Returns this

url

  • url(): Promise<string>
  • Retrieve the URL of current page.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const url = await rize.url()
    })()
    

    Returns Promise<string>

value

  • value(selector: string): Promise<string | null>
  • value(selector: string, newValue: string): this
  • Retrieve value of an <input> element.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const value = await rize.value('input')
    })()
    

    Parameters

    • selector: string

      CSS selector.

    Returns Promise<string | null>

  • Set a value of an <input> element.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.value('input', 'new-value')
    

    Parameters

    • selector: string

      CSS selector.

    • newValue: string

      New value.

    Returns this

viewport

  • viewport(): Promise<Viewport>
  • Retrieve viewport information.

    since

    0.1.0

    example
    
    (async () => {
      const rize = new Rize()
      const viewport = await rize.viewport()
    })()
    

    Returns Promise<Viewport>

waitForElement

  • waitForElement(selector: string, timeout?: undefined | number): this
  • Pause and wait for an element by the given selector.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.waitForElement('div')
    rize.waitForElement('div', 500)  // Timeout is 500ms
    

    Parameters

    • selector: string

      CSS selector.

    • Optional timeout: undefined | number

      Maximum time.

    Returns this

waitForEvaluation

  • waitForEvaluation(fn: string | Function, timeout?: undefined | number, ...args: any[]): this
  • Pause and wait for evaluating an expression or a function.

    The function or expression you given will be evaluated in browser not in Node.js environment.

    NOTE:

    The function or expression will be evaluated many times and puppeteer will check the result of expression or the return value of function. If the result or return value is a falsy value, your function or expression will be evaluated again. And if the result or return value is a truthy value, your function or expression won't be evaulated any more and then go ahead.

    That is, your function or expression will be evaluated in a loop until the result or return value is a truthy value.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.waitForEvaluation(() => window.innerWidth < 100)
    rize.waitForEvaluation('window.innerWidth < 100')
    rize.waitForEvaluation(() => window.innerWidth < 100, 30000)
    rize.waitForEvaluation('window.innerWidth < 100', 30000)
    rize.waitForEvaluation(width => window.innerWidth < width, 30000, 100)
    

    Parameters

    • fn: string | Function

      Expression (you should pass it as string) or function.

    • Optional timeout: undefined | number

      Maximum time to wait for in milliseconds.

    • Rest ...args: any[]

      Arguments of function. No need for expression.

    Returns this

waitForNavigation

  • waitForNavigation(timeout?: undefined | number): this
  • Pause and wait for navigation. (including redirecting and refreshing)

    You can specify maximum navigation time (in milliseconds). Pass 0 to disable.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.waitForNavigation()
    rize.waitForNavigation(500)  // Timeout is 500ms
    

    Parameters

    • Optional timeout: undefined | number

      Maximum navigation time in milliseconds.

    Returns this

withAuth

  • withAuth(username: string, password: string): this
  • Provide credentials for http authentication.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.withAuth('yourname', 'secret')
    

    Parameters

    • username: string
    • password: string

    Returns this

withHeaders

  • withHeaders(headers: puppeteer.Headers): this
  • Set extra HTTP headers.

    The extra HTTP headers will be sent with every request the page initiates.

    This method does not guarantee the order of headers in the outgoing requests.

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.withHeaders({ 'X-Requested-With': 'XMLHttpRequest' })
    

    Parameters

    • headers: puppeteer.Headers

      Extra http headers to be sent with every request.

    Returns this

withUserAgent

  • withUserAgent(userAgent: string): this
  • Set the give user agent string.

    see

    http://useragentstring.com/

    since

    0.1.0

    example
    
    const rize = new Rize()
    rize.withUserAgent('Chrome')
    

    Parameters

    • userAgent: string

      The user agent string you want to use.

    Returns this

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc