Documentation ¶
Overview ¶
Package capabilities performs operations on maps representing WebDriver capabilities.
Index ¶
- func CanReuseSession(caps *Capabilities) bool
- func Merge(m1, m2 map[string]interface{}) map[string]interface{}
- func NoOPResolver(prefix, name string) (string, error)
- type Capabilities
- func (c *Capabilities) MergeOver(other map[string]interface{}) *Capabilities
- func (c *Capabilities) Resolve(resolver Resolver) (*Capabilities, error)
- func (c *Capabilities) Strip(capsToStrip ...string) *Capabilities
- func (c *Capabilities) ToJWP() (map[string]interface{}, error)
- func (c *Capabilities) ToMixedMode() map[string]interface{}
- func (c *Capabilities) ToW3C() map[string]interface{}
- type Resolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanReuseSession ¶
func CanReuseSession(caps *Capabilities) bool
CanReuseSession returns true if the "google:canReuseSession" is set.
func Merge ¶
Merge takes two JSON objects, and merges them.
The resulting object will have all of the keys in the two input objects. For each key that is in both objects:
- if both objects have objects for values, then the result object will have a value resulting from recursively calling Merge.
- if both objects have lists for values, then the result object will have a value resulting from concatenating the two lists.
- Otherwise the result object will have the value from the second object.
func NoOPResolver ¶
NoOPResolver resolves to %prefix:name%.
Types ¶
type Capabilities ¶
type Capabilities struct { AlwaysMatch map[string]interface{} FirstMatch []map[string]interface{} W3CSupported bool }
Capabilities is a WebDriver capabilities object. It is modeled after W3C capabilities, but supports use as W3C, JWP, or mixed-mode.
func FromNewSessionArgs ¶
func FromNewSessionArgs(args map[string]interface{}) (*Capabilities, error)
FromNewSessionArgs creates a Capabilities object from the arguments to new session. AlwaysMatch will be the result of merging alwaysMatch, requiredCapabilities, and desiredCapabilities. Unlike Metadata capabilities merging and MergeOver, this is a shallow merge, and any conflicts will result in an error. Additionally if any capability in firstMatch conflicts with a capability in alwaysMatch, requiredCapabilities, or desiredCapabilities, an error will be returned.
func (*Capabilities) MergeOver ¶
func (c *Capabilities) MergeOver(other map[string]interface{}) *Capabilities
MergeOver creates a new Capabilities with AlwaysMatch == (c.AlwaysMatch deeply merged over other), FirstMatch == c.FirstMatch, and W3Supported == c.W3CSupported.
func (*Capabilities) Resolve ¶
func (c *Capabilities) Resolve(resolver Resolver) (*Capabilities, error)
Resolve returns a new Capabilities object with all %PREFIX:NAME% substrings replaced using resolver.
func (*Capabilities) Strip ¶
func (c *Capabilities) Strip(capsToStrip ...string) *Capabilities
Strip returns a copy of c with all top-level capabilities capsToStrip and with nil values removed.
func (*Capabilities) ToJWP ¶
func (c *Capabilities) ToJWP() (map[string]interface{}, error)
ToJWP creates a map suitable for use as arguments to a New Session request for JSON Wire Protocol remote ends. Since JWP does not support an equivalent to FirstMatch, if FirstMatch contains more than 1 entry then this returns an error (if it contains exactly 1 entry, it will be merged over AlwaysMatch).
func (*Capabilities) ToMixedMode ¶
func (c *Capabilities) ToMixedMode() map[string]interface{}
ToMixedMode creates a map suitable for use as arguments to a New Session request for arbitrary remote ends. If FirstMatch contains more than 1 entry then this returns W3C-only capabilities. If W3CSupported is false then this will return JWP-only capabilities.
func (*Capabilities) ToW3C ¶
func (c *Capabilities) ToW3C() map[string]interface{}
ToW3C creates a map suitable for use as arguments to a New Session request for W3C remote ends.