driverhub

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package driverhub provides a handler for proxying connections to a Selenium server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHandlerProvider

func HTTPHandlerProvider(p *proxy.Proxy) (proxy.HTTPHandler, error)

NewHandler creates a handler for /wd/hub paths that delegates to a WebDriver server instance provided by env.

func HandlerProviderFunc

func HandlerProviderFunc(provider handlerProvider)

HandlerProviderFunc adds additional handlers that will wrap any previously defined handlers.

It is important to note that later added handlers will wrap earlier added handlers. E.g. if you call as follows:

HandlerProviderFunc(hp1)
HandlerProviderFunc(hp2)
HandlerProviderFunc(hp3)

The generated handler will be constructed as follows:

hp3(session, caps, hp2(session, caps, hp1(session, caps, base)))

where base is the a default function that forwards commands to WebDriver unchanged.

Types

type HandlerFunc

type HandlerFunc func(context.Context, Request) (Response, error)

HandlerFunc is a func for handling a request to a WebDriver session.

type Request

type Request struct {
	// HTTP Method for this request (e.g. http.MethodGet, ...).
	Method string
	// Path of the request after the session id.
	Path []string
	// Any HTTP headers sent with the request.
	Header http.Header
	// The body of the request.
	Body []byte
}

Request wraps a request to a WebDriver session.

type Response

type Response struct {
	// HTTP status code to return (e.g. http.StatusOK, ...).
	Status int
	// Any HTTP Headers that should be included in the response.
	Header http.Header
	// The body of the response.
	Body []byte
}

Response describes what response should be returned for a request to WebDriver session.

func ResponseFromError

func ResponseFromError(err error) (Response, error)

ResponseFromError generates a Response object for err.

func SuccessfulResponse

func SuccessfulResponse(value interface{}) (Response, error)

SuccessfulResponse generate a response object indicating success.

type WebDriverHub

type WebDriverHub struct {
	*mux.Router
	environment.Env
	*metadata.Metadata
	*http.Client
	diagnostics.Diagnostics
	Proxy    *proxy.Proxy
	Debugger *debugger.Debugger
	// contains filtered or unexported fields
}

WebDriverHub routes message to the various WebDriver sessions.

func (*WebDriverHub) AddReusableSession

func (h *WebDriverHub) AddReusableSession(session *WebDriverSession) error

AddReusableSession adds a session that can be reused.

func (*WebDriverHub) AddSession

func (h *WebDriverHub) AddSession(id string, session *WebDriverSession)

AddSession adds a session to WebDriverHub.

func (*WebDriverHub) GetActiveSessions

func (h *WebDriverHub) GetActiveSessions() []string

GetActiveSessions returns the ids for all currently active sessions.

func (*WebDriverHub) GetReusableSession

func (h *WebDriverHub) GetReusableSession(ctx context.Context, caps *capabilities.Capabilities) (*WebDriverSession, bool)

GetReusableSession grabs a reusable session if one is available that matches caps.

func (*WebDriverHub) GetSession

func (h *WebDriverHub) GetSession(id string) *WebDriverSession

GetSession gets the session for a given WebDriver session id..

func (*WebDriverHub) Healthy

func (h *WebDriverHub) Healthy(ctx context.Context) error

Healthy returns nil if the WebDriverHub is ready for use, and an error otherwise.

func (*WebDriverHub) Name

func (h *WebDriverHub) Name() string

Name is the name of the component used in error messages.

func (*WebDriverHub) NextID

func (h *WebDriverHub) NextID() int

NextID gets the next available internal id for a session.

func (*WebDriverHub) RemoveSession

func (h *WebDriverHub) RemoveSession(id string)

RemoveSession removes a session from WebDriverHub.

func (*WebDriverHub) ServeHTTP

func (h *WebDriverHub) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*WebDriverHub) Shutdown

func (h *WebDriverHub) Shutdown(ctx context.Context) error

Shutdown shuts down any running sessions.

type WebDriverSession

type WebDriverSession struct {
	*mux.Router
	diagnostics.Diagnostics
	WebDriverHub *WebDriverHub
	webdriver.WebDriver
	ID int

	RequestedCaps *capabilities.Capabilities
	Metadata      *metadata.Metadata
	// contains filtered or unexported fields
}

WebDriverSession is an http.Handler for forwarding requests to a WebDriver session.

func CreateSession

func CreateSession(id int, hub *WebDriverHub, driver webdriver.WebDriver, caps *capabilities.Capabilities) (*WebDriverSession, error)

CreateSession creates a WebDriverSession object.

func (*WebDriverSession) Name

func (s *WebDriverSession) Name() string

Name is the name of the component used in error messages.

func (*WebDriverSession) Quit

Quit can be called by handlers to quit this session.

func (*WebDriverSession) Unpause

func (s *WebDriverSession) Unpause(id int)

Unpause makes the session usable again and associates it with the given session id.

Directories

Path Synopsis
Package debugger enables WTL Debugger.
Package debugger enables WTL Debugger.
Package drivermu implements a handler that temporally serializes all commands to a session.
Package drivermu implements a handler that temporally serializes all commands to a session.
Package googlescreenshot includes a handler for an advanced screenshot endpoint at POST google/screenshot.
Package googlescreenshot includes a handler for an advanced screenshot endpoint at POST google/screenshot.
Package quithandler checks if a window close command is closing the last window and treats it as a quit if it is.
Package quithandler checks if a window close command is closing the last window and treats it as a quit if it is.
Package scripttimeout translates calls to set script timeout into calls on the WebDriver object so it can record the last set script timeout.
Package scripttimeout translates calls to set script timeout into calls on the WebDriver object so it can record the last set script timeout.

Jump to

Keyboard shortcuts

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