devbrowser

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2025 License: MIT Imports: 6 Imported by: 1

README

devbrowser

Project Badges

A lightweight Go library for launching and controlling web browsers programmatically, designed for automation and development tools.

Usage

The main entry point is the New function, which creates a new browser controller:

import "github.com/cdvelop/devbrowser"

type myServerConfig struct{}
func (myServerConfig) GetServerPort() string { return "8080" }

type myUI struct{}
func (myUI) ReturnFocus() {}

func main() {
	exitChan := make(chan bool)
	browser := devbrowser.New(myServerConfig{}, myUI{}, exitChan)
	err := browser.OpenBrowser()
	if err != nil {
		// handle error
	}
	// ... use browser ...
	browser.CloseBrowser()
}

Public API

  • New(sc serverConfig, ui userInterface, exitChan chan bool) *DevBrowser: Create a new DevBrowser instance.
  • (*DevBrowser) OpenBrowser() error: Launch a new browser window.
  • (*DevBrowser) CloseBrowser() error: Close the browser and clean up resources.
  • (*DevBrowser) Reload() error: Reload the current page in the browser.
  • (*DevBrowser) RestartBrowser() error: Restart the browser (close and reopen).
  • (*DevBrowser) BrowserStartUrlChanged(fieldName, oldValue, newValue string) error: Handle changes to the start URL and restart the browser if open.
  • (*DevBrowser) BrowserPositionAndSizeChanged(fieldName, oldValue, newValue string) error: Change the browser window's position and size, and restart the browser.
  • (*DevBrowser) Name() string and (*DevBrowser) Label() string: For UI integration, returns the component name and label.
  • (*DevBrowser) Execute(progress func(msgs ...any)): For UI integration, toggles browser open/close and reports progress.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DevBrowser

type DevBrowser struct {
	context.Context    // Este campo no se codificará en YAML
	context.CancelFunc // Este campo no se codificará en YAML
	// contains filtered or unexported fields
}

func New

func New(sc serverConfig, ui userInterface, exitChan chan bool) *DevBrowser

func (*DevBrowser) BrowserPositionAndSizeChanged

func (h *DevBrowser) BrowserPositionAndSizeChanged(fieldName string, oldValue, newValue string) error

func (*DevBrowser) BrowserStartUrlChanged

func (h *DevBrowser) BrowserStartUrlChanged(fieldName string, oldValue, newValue string) error

func (*DevBrowser) CloseBrowser

func (h *DevBrowser) CloseBrowser() error

func (*DevBrowser) CreateBrowserContext

func (h *DevBrowser) CreateBrowserContext() error

func (*DevBrowser) Execute

func (h *DevBrowser) Execute(progress func(msgs ...any))

func (*DevBrowser) Label

func (h *DevBrowser) Label() string

func (*DevBrowser) Name

func (h *DevBrowser) Name() string

func (*DevBrowser) OpenBrowser

func (h *DevBrowser) OpenBrowser() error

func (*DevBrowser) Reload

func (b *DevBrowser) Reload() (err error)

func (*DevBrowser) RestartBrowser

func (h *DevBrowser) RestartBrowser() error

Jump to

Keyboard shortcuts

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