saucelabs/foxdriver

Name: foxdriver

Owner: Sauce Labs

Description: Foxdriver is a Node library which provides a high-level API to control Firefox over the Remote Debugging Protocol

Created: 2017-08-23 14:09:57.0

Updated: 2018-05-22 04:26:06.0

Pushed: 2017-11-28 10:29:32.0

Homepage: null

Size: 211

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Foxdriver Build Status

Foxdriver is a Node library which provides a high-level API to control Firefox over the Remote Debugging Protocol.

Getting Started
Installation

To use Foxdriver in your project, run:

rn add foxdriver

m i foxdriver
Usage

The Firefox Remote Debugging Protocol consists of multiple actors that provide different methods. The Foxdriver API allows you to launch a Firefox instance and connects to the protocol interface automatically. From there you can access the methods of all actors.

Example - opening page and get console.logs

rt Foxdriver from 'foxdriver'

nc () => {
const { browser, tab } = await Foxdriver.launch({
    url: 'https://www.mozilla.org/en-US'
})

// enable actor
await tab.console.startListeners()
// wait until page is loaded
await new Promise((resolve) => setTimeout(resolve, 3000))
// receive logs and page errors
const logs = await tab.console.getCachedMessages()
console.log(logs)

// close browser
browser.close()

You can also attach yourself to an already running Firefox browser. This requires to start the browser with the -start-debugger-server=<port> cli argument and have the following settings set:

To attach yourself to the browser you then need to create a Foxdriver instance with the correct port and host and call the connect() method:

rt Foxdriver from 'foxdriver'

nc () => {
const { browser, tab } = await Foxdriver.attach('localhost', 9222)
const preferences = await browser.preference.getAllPrefs()

// ...

API
Foxdriver
Foxdriver.attach(host, port)

Attaches client to an already running instance.

Foxdriver.launch(options)

Attaches client to an already running instance.

class: Browser close()

Disconnects from the browser instance and closes browser if launched via launch() method

class: Tab tab.attach()

Attaches to this tab

tab.detach()

Detaches from this tab

tab.reload()

Reloads current page url.

tab.navigateTo(url)

Navigates to a certain url

For more information please see API docs.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.