webdriver

package
v0.77.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

README

webdriver Runner

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

Service Id Action Description Request Response
webdriver start start standalone webdriver server ServerStartRequest ServerStartResponse
webdriver stop stop standalone webdriver server ServerStopRequest ServerStopResponse
webdriver open open a new browser with session id for further testing OpenSessionRequest OpenSessionResponse
webdriver close close browser session CloseSessionRequest CloseSessionResponse
webdriver call-driver call a method on web driver, i.e wb.GET(url) WebDriverCallRequest ServiceCallResponse
webdriver call-element call a method on a web element, i.e. we.Click() WebElementCallRequest WebElementCallResponse
webdriver 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 webdriver server via webdriver client

See webdriver selector for more details on how to use xpath, css, id, name, class, tag, link, partial link, dom, and xpath selectors.

webdriver 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 webdriver 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

defaults:
  target:
     URL: ssh://127.0.0.1/
     credentials: localhost
pipeline:
  init:
    action: webdriver:start
  test:
    action: webdriver:run
    remotewebdriver:
      URL: http://127.0.0.1:8085
    commands:
      - get(http://play.golang.org/?simple=1)
      - (#code).clear
      - (#code).sendKeys(package main

          import "fmt"

          func main() {
              fmt.Println("Hello Endly!")
          }
        )
      - (#run).click
      - command: output = (#output).text
        exit: $output.Text:/Endly/
        sleepTimeMs: 1000
        repeat: 10
      - close
    expect:
      output:
        Text: /Hello Endly!/

Documentation

Index

Constants

View Source
const (
	PathKindUndefined = PathKind(iota)
	PathKindSimple
	PathKindComposite
)
View Source
const (
	//ServiceID represents a ServiceID
	ServiceID = "webdriver"

	//SeleniumServer represents name of selenium server
	SeleniumServer = "selenium-server-standalone"
	//GeckoDriver represents name of gecko driver
	GeckoDriver    = "geckodriver"
	ChromeDriver   = "chromedriver"
	ChromeBrowser  = "chrome"
	FirefoxBrowser = "firefox"
	Selenium       = "webdriver"
)

Variables

This section is empty.

Functions

func IsStaleElementError added in v0.73.1

func IsStaleElementError(err error) bool

func New

func New() endly.Service

New creates a new webdriver 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
	PathKind
	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
	Method     string
	Parameters []interface{}
}

MethodCall represents selenium call.

type OpenSessionRequest

type OpenSessionRequest struct {
	Browser      string
	Capabilities []string
	Remote       string `description:"webdriver server endpoint"`
	SessionID    string `description:"if specified this SessionID will be used for a sessionID"`
}

OpenSessionRequest represents open session request

func NewOpenSessionRequest

func NewOpenSessionRequest(browser string, remote string) *OpenSessionRequest

NewOpenSessionRequest creates a new open session request

func (*OpenSessionRequest) Init

func (r *OpenSessionRequest) Init() error

Init initializes request

type OpenSessionResponse

type OpenSessionResponse struct {
	SessionID string
}

OpenSessionResponse represents open session response.

type PathKind added in v0.73.0

type PathKind int

type RunRequest

type RunRequest struct {
	SessionID      string
	Browser        string
	RemoteSelenium string //remote selenium resource
	Actions        []*Action
	ActionDelaysMs int           `description:"slows down action with specified delay"`
	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 string, 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 {
	SessionID string
	Browser   string
	Pid       int
	Server    string

	Capabilities []string
	// contains filtered or unexported fields
}

Session represents a selenium session

func (Session) Close

func (s Session) Close()

func (Session) Driver added in v0.74.0

func (s Session) Driver() selenium.WebDriver

type StartRequest

type StartRequest struct {
	Target       *location.Resource
	Driver       string
	Server       string
	Sdk          string
	Capabilities []string
	Port         int
}

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) Init

func (r *StartRequest) Init() error

func (*StartRequest) Validate

func (r *StartRequest) Validate() error

type StartResponse

type StartResponse struct {
	Pid        int
	ServerPath string
	DriverPath string
	SessionID  string
}

StartResponse represents a selenium server stop request

type StopRequest

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

StopRequest represents server stop request

func NewStopRequestFromURL

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

NewStopRequestFromURL creates a new start request from URL

func (*StopRequest) Init

func (r *StopRequest) Init() error

type StopResponse

type StopResponse struct {
}

StopResponse represents a selenium stop request

type Wait

type Wait struct {
	WaitTimeMs    int
	ThinkTimeMs   int
	IgnoreTimeout bool
	Exit          string
	// contains filtered or unexported fields
}

type WebDriverCallRequest

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

WebDriverCallRequest represents selenium call driver request

type WebElementCallRequest

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

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)

Directories

Path Synopsis
extension

Jump to

Keyboard shortcuts

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