-
Notifications
You must be signed in to change notification settings - Fork 2
/
types.go
161 lines (142 loc) · 5.32 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// This file is part of marionette-go
//
// marionette-go is distributed in two licenses: The Mozilla Public License,
// v. 2.0 and the GNU Lesser Public License.
//
// marionette-go is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.
//
// See License.txt for further information.
package marionette
import "encoding/json"
const (
ChromeContext = "chrome"
ContentContext = "content"
)
// Message represents messages to/from marionette server
type Message struct {
Type int
Serial uint32
Error error
Data interface{}
}
// Proxy represents proxy info
type Proxy struct {
Type string `json:"proxyType,omitempty"`
AutoconfigUrl string `json:"proxyAutoconfigUrl,omitempty"`
FTP string `json:"ftpProxy,omitempty"`
FTPPort int `json:"ftpProxyPort,omitempty"`
HTTP string `json:"httpProxy,omitempty"`
HTTPPort int `json:"httpProxyPort,omitempty"`
SSL string `json:"sslProxy,omitempty"`
SSLPort int `json:"sslProxyPort,omitempty"`
Socks string `json:"socksProxy,omitempty"`
SocksPort int `json:"socksProxyPort,omitempty"`
SocksVersion string `json:"socksVersion,omitempty"`
NoProxy []string `json:"noProxy,omitempty"`
}
// Timeouts represnets timeout values
//
// Refer driver.js for further info
// https://github.com/mozilla/gecko-dev/blob/master/testing/marionette/driver.js
type Timeouts struct {
Implicit int `json:"implicit,omitempty"`
PageLoad int `json:"pageLoad,omitempty"`
Script int `json:"script,omitempty"`
}
// Capabilities represents marionette server capabilities
type Capabilities struct {
// web driver
BrowserName string `json:"browserName,omitempty"`
BrowserVersion string `json:"browserVersion,omitempty"`
PlatformName string `json:"platformName,omitempty"`
PlatformVersion string `json:"platformversion,omitempty"`
AcceptInsecureCerts bool `json:"acceptInsecureCerts,omitempty"`
PageLoadStrategy string `json:"pageLoadStrategy,omitempty"`
Proxy *Proxy `json:"proxy,omitempty"`
SetWindowRect bool `json:"setWindowRect,omitempty"`
Timeouts *Timeouts `json:"timeouts,omitempty"`
StrictFileInteractability bool `json:"strictFileInteractability,omitempty"`
UnhandledPromptBehavior string `json:"unhandledPromptBehavior,omitempty"`
// features
Rotatable bool `json:"rotatable,omitempty"`
// proprietary
AccessibilityChecks bool `json:"moz:accessibilityChecks,omitempty"`
BuildID string `json:"buildID,omitempty"`
Headless bool `json:"headless,omitempty"`
ProcessID int `json:"processID,omitempty"`
Profile string `json:"profile,omitempty"`
ShutdownTimeout int `json:"shutdownTimeout,omitempty"`
SpecialPointerOrigin bool `json:"moz:useNonSpecCompliantPointerOrigin,omitempty"`
WebdriverClick bool `json:"moz:webdriverClick,omitempty"`
}
// Rect represents size/placement info about a window/element/...
type Rect struct {
X float64 `json:"x"`
Y float64 `json:"y"`
W float64 `json:"width"`
H float64 `json:"height"`
}
// FindStrategy denotes how you find element
type FindStrategy string
const (
ClassName FindStrategy = "class name"
Selector FindStrategy = "css selector"
ID FindStrategy = "id"
Name FindStrategy = "name"
LinkText FindStrategy = "link text"
PartialLinkText FindStrategy = "partial link text"
TagName FindStrategy = "tag name"
XPath FindStrategy = "xpath"
Anon FindStrategy = "anon"
AnonAttribute FindStrategy = "anon attribute"
)
const (
// Type of WebElements
ElementType = "element-6066-11e4-a52e-4f735466cecf"
WindowType = "window-fcc6-11e5-b4f8-330a88ab9d7f"
FrameType = "frame-075b-4da1-b6ba-e579c2d3230a"
ChromeElementType = "chromeelement-9fc5-4b51-a3c8-01716eedeb04"
)
// WebElement is an element (window/frame/html element) referenced by an UUID
type WebElement struct {
Type string
UUID string
}
func (el *WebElement) MarshalJSON() (data []byte, err error) {
return json.Marshal(el.UUID)
}
type Cookie struct {
Name string `json:"name"`
Value string `json:"value"`
Path string `json:"path,omitempty"`
Domain string `json:"domain,omitempty"`
Secure bool `json:"secure,omitempty"`
HttpOnly bool `json:"httpOnly,omitempty"`
Expiry int64 `json:"expiry,omitempty"`
}
const (
// screen orientations
PORTRAIT = "portrait"
LANDSCAPE = "landscape"
PORTRAIT_PRIMARY = "portrait-primary"
LANDSCAPE_PRIMARY = "landscape-primary"
PORTRAIT_SECONDARY = "portrait-secondary"
LANDSCAPE_SECONDARY = "landscape-secondary"
)
const (
// window types
FirefoxWindow = "navigator:browser"
GeckoViewWindow = "navigator:geckoview"
ThunderbirdWindow = "mail:3pane"
)
const (
// quit flags, see
// https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIAppStartup
QuitConsider = "eConsiderQuit"
QuitAttempt = "eAttemptQuit"
QuitForce = "eForceQuit"
QuitRestart = "eRestart"
QuitRestartNotSameProfile = "eRestartNotSameProfile"
)