Documentation ¶
Index ¶
- Variables
- func MustStopClient()
- func Run()
- func SetAfterAll(fn func())
- func SetAfterEach(fn TestFunction)
- func SetBeforeAll(fn func())
- func SetBeforeEach(fn TestFunction)
- func SetClient(d *Driver, opts *Opts) error
- func SetTest(fn TestFunction, name ...string)
- func StopClient() error
- type Asserter
- type Driver
- type E
- type Element
- func (e *Element) Clear() *Element
- func (e *Element) Click() *Element
- func (e *Element) GetAttribute(attribute string) string
- func (e *Element) GetText() string
- func (e *Element) IsEnabled() bool
- func (e *Element) IsPresent() bool
- func (e *Element) IsSelected() bool
- func (e *Element) IsVisible() bool
- func (e *Element) SendKeys(input string) *Element
- func (e *Element) ShouldHave() *Asserter
- func (e *Element) WaitFor(timeout time.Duration) *Waiter
- type Elements
- type Handle
- type Opts
- type Session
- func (s *Session) AcceptAlert() *Session
- func (s *Session) AddError(err string)
- func (s *Session) Back() *Session
- func (s *Session) CloseWindow() *Session
- func (s *Session) DeleteSession()
- func (s *Session) DismissAlert() *Session
- func (s *Session) ExecuteScript(script string, args ...string) interface{}
- func (s *Session) Forward() *Session
- func (s *Session) GetAlertText() string
- func (s *Session) GetCurrentURL() string
- func (s *Session) GetID() string
- func (s *Session) GetPageSoure() string
- func (s *Session) GetTitle() string
- func (s *Session) GetWindowHandle() string
- func (s *Session) GetWindowHandles() []string
- func (s *Session) NewElement(e interface{}) *Element
- func (s *Session) NewElements(e interface{}) *Elements
- func (s *Session) NewTab() *Handle
- func (s *Session) NewWindow() *Handle
- func (s *Session) OpenURL(url string) *Session
- func (s *Session) RaiseErrors() string
- func (s *Session) Refresh() *Session
- func (s *Session) SendAlertText(text string) *Session
- func (s *Session) SwitchHandle(handle string)
- func (s *Session) SwitchToFrame(e *Element) *Session
- func (s *Session) SwitchToParentFrame() *Session
- func (s *Session) TakeScreenshot(name string) *Session
- func (s *Session) UseCSS()
- func (s *Session) UseXPath()
- type TestFunction
- type Valuer
- type Waiter
- func (w *Waiter) UntilIsEnabled() *Element
- func (w *Waiter) UntilIsNotEnabled() *Element
- func (w *Waiter) UntilIsNotPresent() *Element
- func (w *Waiter) UntilIsNotSelected() *Element
- func (w *Waiter) UntilIsNotVisible() *Element
- func (w *Waiter) UntilIsPresent() *Element
- func (w *Waiter) UntilIsSelected() *Element
- func (w *Waiter) UntilIsVisible() *Element
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func MustStopClient ¶
func MustStopClient()
MustStopClient is a convenience function that wraps StopClient and panics in case an error is encountered.
func Run ¶
func Run()
Run executes all set tests. If the client is not set, it sets one with the default driver based on the config settings.
func SetAfterAll ¶
func SetAfterAll(fn func())
SetAfterAll sets the function that will be executed after all tests.
func SetAfterEach ¶
func SetAfterEach(fn TestFunction)
SetAfterEach sets the function that will be executed after each test.
func SetBeforeAll ¶
func SetBeforeAll(fn func())
SetBeforeAll sets the function that will be executed before all tests.
func SetBeforeEach ¶
func SetBeforeEach(fn TestFunction)
SetBeforeEach sets the function that will be executed before each test.
func SetClient ¶
SetClient creates a new client instance with the provided driver. Based on the configuration settings, a driver may be started. Optionally, Opts can be provided for additional configuration.
func SetTest ¶
func SetTest(fn TestFunction, name ...string)
SetTest sets the test function. The name is used to identify the test is optional. If no name is provided, test_<test_id> is used. If the given name is already in use, test ID is appended to the name.
Types ¶
type Asserter ¶
type Asserter struct {
// contains filtered or unexported fields
}
Asserter is a helper struct to assert the element's text, attributes, etc.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver resembles a browser Driver and parameters to connect to it.
func NewDriver ¶
NewDriver creates a new Driver with the supplied path to the browser driver executable and remote URL to use. If remoteURL is empty, ErrInvalidParameters error is returned.
type Element ¶
type Element struct { E // contains filtered or unexported fields }
Element describes web element.
func (*Element) GetAttribute ¶
GetAttribute returns the value of the given attribute of the element. If the element does not have the given attribute, an empty string is returned.
func (*Element) IsSelected ¶
IsSelected checks if the element is selected.
func (*Element) ShouldHave ¶
ShouldHave returns an Asserter for the given element. The returned Asserter can be used to assert the element's text, attributes, etc.
type Elements ¶
type Elements struct { E // contains filtered or unexported fields }
Elements describes a collection of Element type.
type Opts ¶
type Opts struct {
ConfigDirectory string
}
Opts contains configuration options for the client. TODO: Allow overwriting config values.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a single user agent. It describes connection between browser driver and the client.
func NewSession ¶
NewSession creates a new session with the capabilities described in config.
func (*Session) AcceptAlert ¶
AcceptAlert accepts currently open alert dialog.
func (*Session) CloseWindow ¶
CloseWindow closes the current browsing context. If there are no open handles for this browsing context, the session will be closed. Reference: https://www.w3.org/TR/webdriver/#close-window
func (*Session) DeleteSession ¶
func (s *Session) DeleteSession()
DeleteSession deletes the given session.
func (*Session) DismissAlert ¶
DismissAlert dismisses currently open alert dialog.
func (*Session) ExecuteScript ¶
ExecuteScript executes user defined JavaScript function written as a string. ...args are passed to the function as arguments. Function's return value is returned as interface{}.
func (*Session) GetAlertText ¶
GetAlertText gets text of currently open alert dialog.
func (*Session) GetCurrentURL ¶
GetCurrentURL returns the current URL of the browsing context.
func (*Session) GetPageSoure ¶
GetPageSoure returns HTML source of the current page.
func (*Session) GetWindowHandle ¶
GetWindowHandle returns the current browsing context handle.
func (*Session) GetWindowHandles ¶
GetWindowHandles returns all open browsing contexts' handles.
func (*Session) NewElement ¶
NewElement returns a new Element. The parameter can be either a selector ( uses session's default locator) or *E or E struct.
func (*Session) NewElements ¶
NewElements return a new Elements. The parameter can be either a selector ( uses session's default locator) or *E or E struct.
func (*Session) RaiseErrors ¶
RaiseErrors raises all the session's errors.
func (*Session) SendAlertText ¶
SendAlertText sends text to currently open prompt dialog.
func (*Session) SwitchHandle ¶
SwitchHandle switches to the handle using the provided handle ID.
func (*Session) SwitchToFrame ¶
SwitchToFrame switches current browsing context to the specified iframe using the provided element. If nil is provided, the session will switch to the top-level browsing context.
func (*Session) SwitchToParentFrame ¶
SwitchToParentFrame switches to the parent frame of the given browsing context.
func (*Session) TakeScreenshot ¶
TakeScreenshot takes a screenshot of the current browsing context. Screenshot file is created in screenshot_path directory based on the config. The file can have .png, .jpg or .jpeg extension.
type TestFunction ¶
type TestFunction func(s *Session)
TestFunction describes one test for the given session. It is used in selenium.Run() to execute tests.
type Valuer ¶
type Valuer struct {
// contains filtered or unexported fields
}
Valuer is a helper struct to compare the actual value of an element with the expected using various comparison functions.
type Waiter ¶
type Waiter struct {
// contains filtered or unexported fields
}
Waiter is a helper struct to wait for an element to be present, visible, etc.
func (*Waiter) UntilIsEnabled ¶
UntilIsEnabled waits until the element is enabled.
func (*Waiter) UntilIsNotEnabled ¶
UntilIsNotEnabled waits until the element is not enabled.
func (*Waiter) UntilIsNotPresent ¶
UntilIsNotPresent waits until the element is not present.
func (*Waiter) UntilIsNotSelected ¶
UntilIsNotSelected waits until the element is not selected.
func (*Waiter) UntilIsNotVisible ¶
UntilIsNotVisible waits until the element is visible.
func (*Waiter) UntilIsPresent ¶
UntilIsPresent waits until the element is present.
func (*Waiter) UntilIsSelected ¶
UntilIsSelected waits until the element is selected.
func (*Waiter) UntilIsVisible ¶
UntilIsVisible waits until the element is visible.