webfriend

package module
v0.12.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 21 Imported by: 1

README

   “Your friendly friend in modern web automation and testing.”

ALPHA ALERT

This software is under heavy development and should not be considered production-ready. Much of it works, but much is still yet to be implemented. It is a ground-up rewrite of my Python version of this project. Documentation and examples are missing and incomplete at this time, but I am working on it as I am able.

I welcome polite feedback, comments, and suggestions.

Overview

Webfriend is a Golang library and command-line utility that integrates with the Chrome DevTools Protocol to control a Google Chrome or Chromium browser instance. There is also a purpose-built scripting language (called Friendscript) that is designed to be an easy-to-learn environment for writing simple or complex browser automation scripts.

Some of the things that you can use Webfriend for:

  • Take full-page screenshots of web pages.

  • Automate tedious or repetitive tasks on web pages that otherwise would require extensive user input with a keyboard, mouse, or touchscreen device.

  • Execute pre-defined tests against web pages and serve as an automated testing framework for verifying frontend functionality.

  • Automatically login to websites with complex authentication flows.

  • Extract (i.e. scrape) information from web pages and present it in a structured way that other languages and scripts can use as input.

  • Inject Javascript code into the browser, evaluate it, then return the results for output or further processing.

Operation and Usage

Webfriend by default operates using Headless Chrome mode, but can also just as easily run Chrome in the foreground in a graphical environment. Importantly, headless operation allows you to run Webfriend on servers without running Xfvb or X11. In this sense, it operates as a potentially-faster alternative to phantomjs or Selenium while also providing almost all of the capabilities of the complete Google Chrome/Chromium browser.

Using Friendscript, straightforward and composable scripts can be written and combined together to create fast, modular, and flexible processes that can be used to solve real problems.

Installation

go install github.com/PerformLine/go-webfriend/webfriend

Documentation

Documentation

Index

Constants

View Source
const Slogan = `Your friendly friend in web browser automation.`
View Source
const Version = `0.10.4`

Variables

View Source
var MaxReaderWait = time.Duration(5) * time.Second

Functions

This section is empty.

Types

type CallDoc

type CallDoc struct {
	Name        string     `json:"name"`
	Description string     `json:"description,omitempty"`
	Argument    *DocItem   `json:"argument,omitempty"`
	Options     []*DocItem `json:"options,omitempty"`
	Return      *DocItem   `json:"return,omitempty"`
}

type CallDocSet

type CallDocSet []*CallDoc

type DocItem

type DocItem struct {
	Name         string      `json:"name,omitempty"`
	Type         string      `json:"types"`
	Required     bool        `json:"required,omitempty"`
	Description  string      `json:"description,omitempty"`
	DefaultValue interface{} `json:"default,omitempty"`
	Examples     []string    `json:"examples,omitempty"`
	Parameters   []*DocItem  `json:"parameters,omitempty"`
}

type Environment

type Environment struct {
	*friendscript.Environment
	Cookies *cookies.Commands
	Core    *core.Commands
	Page    *page.Commands
	File    *file.Commands
	// contains filtered or unexported fields
}

func NewEnvironment

func NewEnvironment(browser *browser.Browser) *Environment

func (*Environment) Browser

func (self *Environment) Browser() *browser.Browser

func (*Environment) Documentation

func (self *Environment) Documentation() []*ModuleDoc

func (*Environment) MustModule

func (self *Environment) MustModule(name string) friendscript.Module

type ModuleDoc

type ModuleDoc struct {
	DisplayName string     `json:"display_name"`
	Name        string     `json:"name"`
	Summary     string     `json:"summary,omitempty"`
	Description string     `json:"description,omitempty"`
	Commands    CallDocSet `json:"commands"`
	// contains filtered or unexported fields
}

func (*ModuleDoc) AddCommand

func (self *ModuleDoc) AddCommand(name string, doc *CallDoc)

Directories

Path Synopsis
cmd
commands
cookies
Commands for interacting with the browser's cookie storage backend.
Commands for interacting with the browser's cookie storage backend.
core
Commonly used commands for basic browser interaction.
Commonly used commands for basic browser interaction.
file
File IO commands
File IO commands
page
Commands for inspecting and manipulating the current DOM document and browser viewport.
Commands for inspecting and manipulating the current DOM document and browser viewport.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL