selenium

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

README

Selenium Runner

Selenium runner opens a web session to run a various action on web driver or web elements.

Service Id Action Description Request Response
selenium start start standalone selenium server ServerStartRequest ServerStartResponse
selenium stop stop standalone selenium server ServerStopRequest ServerStopResponse
selenium open open a new browser with session id for further testing OpenSessionRequest OpenSessionResponse
selenium close close browser session CloseSessionRequest CloseSessionResponse
selenium call-driver call a method on web driver, i.e wb.GET(url) WebDriverCallRequest ServiceCallResponse
selenium call-element call a method on a web element, i.e. we.Click() WebElementCallRequest WebElementCallResponse
selenium run run set of action on a page RunRequest RunResponse

call-driver and call-element actions's method and parameters are proxied to stand along selenium server via selenium client

Selenium run request defines sequence of action/commands. In case a selector is not specified, call method's caller is a WebDriver, otherwise WebElement defined by selector. Wait provides ability to wait either some time amount or for certain condition to take place, with regexp to extract data

Run request provide commands expression for easy selenium interaction:

Command syntax:

  [RESULT_KEY=] [(WEB_ELEMENT_SELECTOR).]METHOD_NAME(PARAMETERS)
  
  i.e:
  (#name).sendKeys('dummy 123')
  (xpath://SELECT[@id='typeId']/option[text()='type1']).click()
  get(http://127.0.0.1:8080/form.html)
  

Time wait


        - command: CurrentURL = CurrentURL()
        exit: $CurrentURL:/dummy/
        sleepTimeMs: 1000
        repeat: 10

Inline pipeline tasks

endly -r=test

@test.yaml

Documentation

Index

Constants

View Source
const (
	//ServiceID represents a ServiceID
	ServiceID = "selenium"

	//Selenium represents name of selenium server
	Selenium = "selenium-server-standalone"
	//GeckoDriver represents name of gecko driver
	GeckoDriver = "geckodriver"
)

Variables

This section is empty.

Functions

func New

func New() endly.Service

NewSeleniumService creates a new selenium service

func NewParser

func NewParser() *parser

NewParser creates a new criteria parser

func Sessions

func Sessions(context *endly.Context) map[string]*Session

Types

type Action

type Action struct {
	Key      string //optional result key
	Selector *WebElementSelector
	Calls    []*MethodCall
}

Action represents various calls on web element

func NewAction

func NewAction(key, selector string, method string, params ...interface{}) *Action

NewAction creates a new action

type CloseSessionRequest

type CloseSessionRequest struct {
	SessionID string
}

CloseSessionRequest represents close session request.

func NewCloseSessionRequestFromURL

func NewCloseSessionRequestFromURL(URL string) (*CloseSessionRequest, error)

NewCloseSessionRequestFromURL creates a new close session request from URL

type CloseSessionResponse

type CloseSessionResponse struct {
	SessionID string
}

CloseSessionResponse represents close session response.

type MethodCall

type MethodCall struct {
	Wait       *model.Repeater
	Method     string
	Parameters []interface{}
}

MethodCall represents selenium call.

func NewMethodCall

func NewMethodCall(method string, repeatable *model.Repeater, parameters ...interface{}) *MethodCall

NewMethodCall creates a new method call

type OpenSessionRequest

type OpenSessionRequest struct {
	Browser        string
	RemoteSelenium *url.Resource `description:"http selenium server endpoint"`
	SessionID      string        `description:"if specified this ID will be used for a sessionID"`
}

OpenSessionRequest represents open session request

func NewOpenSessionRequest

func NewOpenSessionRequest(browser string, remote *url.Resource) *OpenSessionRequest

NewOpenSessionRequest creates a new open session request

func (*OpenSessionRequest) Validate

func (r *OpenSessionRequest) Validate() error

Validate validate open session request

type OpenSessionResponse

type OpenSessionResponse struct {
	SessionID string
}

OpenSessionResponse represents open session response.

type RunRequest

type RunRequest struct {
	SessionID      string
	Browser        string
	RemoteSelenium *url.Resource //remote selenium resource
	Actions        []*Action
	Commands       []interface{} `` /* 130-byte string literal not displayed */
	Expect         interface{}   `description:"If specified it will validated response as actual"`
}

RunRequest represents group of selenium web elements calls

func NewRunRequest

func NewRunRequest(sessionID, browser string, remote *url.Resource, actions ...*Action) *RunRequest

NewRunRequest creates a new run request

func NewRunRequestFromURL

func NewRunRequestFromURL(URL string) (*RunRequest, error)

NewRunRequestFromURL creates a new request from URL

func (*RunRequest) Init

func (r *RunRequest) Init() error

func (*RunRequest) IsInput

func (r *RunRequest) IsInput() bool

IsInput returns this request (CLI reporter interface)

func (*RunRequest) Messages

func (r *RunRequest) Messages() []*msg.Message

IsInput returns this request (CLI reporter interface)

func (*RunRequest) Validate

func (r *RunRequest) Validate() error

Validate validates run request.

type RunResponse

type RunResponse struct {
	SessionID    string
	Data         map[string]interface{}
	LookupErrors []string
	Assert       *validator.AssertResponse
}

RunResponse represents selenium call response

func (*RunResponse) IsOutput

func (r *RunResponse) IsOutput() bool

IsOutput returns this response (CLI reporter interface)

func (*RunResponse) Messages

func (r *RunResponse) Messages() []*msg.Message

Messages returns messages

type ServiceCallResponse

type ServiceCallResponse struct {
	Result []interface{}
	Data   data.Map
}

ServiceCallResponse represents selenium call response

type Session

type Session struct {
	ID      string
	Browser string
	// contains filtered or unexported fields
}

Session represents a selenium session

type StartRequest

type StartRequest struct {
	Target     *url.Resource
	Port       int
	Sdk        string
	SdkVersion string
	Version    string
}

StartRequest represents a selenium server start request

func NewStartRequestFromURL

func NewStartRequestFromURL(URL string) (*StartRequest, error)

NewStartRequestFromURL creates a new start request from URL

func (*StartRequest) Validate

func (r *StartRequest) Validate() error

type StartResponse

type StartResponse struct {
	Pid             int
	ServerPath      string
	GeckodriverPath string
}

StartResponse repreents a selenium server stop request

type StopRequest

type StopRequest struct {
	Target *url.Resource
	Port   int
}

StopRequest represents server stop request

func NewStopRequestFromURL

func NewStopRequestFromURL(URL string) (*StopRequest, error)

NewStopRequestFromURL creates a new start request from URL

type StopResponse

type StopResponse struct {
}

StopResponse represents a selenium stop request

type WebDriverCallRequest

type WebDriverCallRequest struct {
	SessionID string
	Key       string
	Call      *MethodCall
}

WebDriverCallRequest represents selenium call driver request

type WebElementCallRequest

type WebElementCallRequest struct {
	SessionID string
	Selector  *WebElementSelector
	Call      *MethodCall
}

WebElementCallRequest represents a web element call reqesut

type WebElementCallResponse

type WebElementCallResponse struct {
	Result      []interface{}
	LookupError string
	Data        map[string]interface{}
}

WebElementCallResponse represents seleniun web element response

type WebElementSelector

type WebElementSelector struct {
	By    string //selector type
	Value string //selector value
	Key   string //optional result key
}

WebElementSelector represents a web element selector

func NewWebElementSelector

func NewWebElementSelector(by, value string) *WebElementSelector

NewWebElementSelector creates a new instance of web element selector

func (*WebElementSelector) Init

func (s *WebElementSelector) Init() error

Validate checks is selector is valid.

func (*WebElementSelector) Validate

func (s *WebElementSelector) Validate() error

Validate checks is selector is valid.

type WebSelector

type WebSelector string

func (WebSelector) ByAndValue

func (s WebSelector) ByAndValue() (by, value string)

Jump to

Keyboard shortcuts

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