1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | 'use strict'
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | class Command {
|
29 |
|
30 | constructor(name) {
|
31 |
|
32 | this.name_ = name
|
33 |
|
34 |
|
35 | this.parameters_ = {}
|
36 | }
|
37 |
|
38 |
|
39 | getName() {
|
40 | return this.name_
|
41 | }
|
42 |
|
43 | |
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | setParameter(name, value) {
|
50 | this.parameters_[name] = value
|
51 | return this
|
52 | }
|
53 |
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 | setParameters(parameters) {
|
60 | this.parameters_ = parameters
|
61 | return this
|
62 | }
|
63 |
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 | getParameter(key) {
|
70 | return this.parameters_[key]
|
71 | }
|
72 |
|
73 | |
74 |
|
75 |
|
76 | getParameters() {
|
77 | return this.parameters_
|
78 | }
|
79 | }
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | const Name = {
|
88 | GET_SERVER_STATUS: 'getStatus',
|
89 |
|
90 | NEW_SESSION: 'newSession',
|
91 | GET_SESSIONS: 'getSessions',
|
92 |
|
93 | CLOSE: 'close',
|
94 | QUIT: 'quit',
|
95 |
|
96 | GET_CURRENT_URL: 'getCurrentUrl',
|
97 | GET: 'get',
|
98 | GO_BACK: 'goBack',
|
99 | GO_FORWARD: 'goForward',
|
100 | REFRESH: 'refresh',
|
101 |
|
102 | ADD_COOKIE: 'addCookie',
|
103 | GET_COOKIE: 'getCookie',
|
104 | GET_ALL_COOKIES: 'getCookies',
|
105 | DELETE_COOKIE: 'deleteCookie',
|
106 | DELETE_ALL_COOKIES: 'deleteAllCookies',
|
107 |
|
108 | GET_ACTIVE_ELEMENT: 'getActiveElement',
|
109 | FIND_ELEMENT: 'findElement',
|
110 | FIND_ELEMENTS: 'findElements',
|
111 | FIND_ELEMENTS_RELATIVE: 'findElementsRelative',
|
112 | FIND_CHILD_ELEMENT: 'findChildElement',
|
113 | FIND_CHILD_ELEMENTS: 'findChildElements',
|
114 |
|
115 | CLEAR_ELEMENT: 'clearElement',
|
116 | CLICK_ELEMENT: 'clickElement',
|
117 | SEND_KEYS_TO_ELEMENT: 'sendKeysToElement',
|
118 | SUBMIT_ELEMENT: 'submitElement',
|
119 |
|
120 | GET_CURRENT_WINDOW_HANDLE: 'getCurrentWindowHandle',
|
121 | GET_WINDOW_HANDLES: 'getWindowHandles',
|
122 | GET_WINDOW_POSITION: 'getWindowPosition',
|
123 | SET_WINDOW_POSITION: 'setWindowPosition',
|
124 | GET_WINDOW_SIZE: 'getWindowSize',
|
125 | SET_WINDOW_SIZE: 'setWindowSize',
|
126 | GET_WINDOW_RECT: 'getWindowRect',
|
127 | SET_WINDOW_RECT: 'setWindowRect',
|
128 | MAXIMIZE_WINDOW: 'maximizeWindow',
|
129 | MINIMIZE_WINDOW: 'minimizeWindow',
|
130 | FULLSCREEN_WINDOW: 'fullscreenWindow',
|
131 |
|
132 | SWITCH_TO_WINDOW: 'switchToWindow',
|
133 | SWITCH_TO_NEW_WINDOW: 'newWindow',
|
134 | SWITCH_TO_FRAME: 'switchToFrame',
|
135 | SWITCH_TO_FRAME_PARENT: 'switchToFrameParent',
|
136 | GET_PAGE_SOURCE: 'getPageSource',
|
137 | GET_TITLE: 'getTitle',
|
138 |
|
139 | EXECUTE_SCRIPT: 'executeScript',
|
140 | EXECUTE_ASYNC_SCRIPT: 'executeAsyncScript',
|
141 |
|
142 | GET_ELEMENT_TEXT: 'getElementText',
|
143 | GET_COMPUTED_ROLE: 'getAriaRole',
|
144 | GET_COMPUTED_LABEL: 'getAccessibleName',
|
145 | GET_ELEMENT_TAG_NAME: 'getElementTagName',
|
146 | IS_ELEMENT_SELECTED: 'isElementSelected',
|
147 | IS_ELEMENT_ENABLED: 'isElementEnabled',
|
148 | IS_ELEMENT_DISPLAYED: 'isElementDisplayed',
|
149 | GET_ELEMENT_LOCATION: 'getElementLocation',
|
150 | GET_ELEMENT_LOCATION_IN_VIEW: 'getElementLocationOnceScrolledIntoView',
|
151 | GET_ELEMENT_RECT: 'getElementRect',
|
152 | GET_ELEMENT_SIZE: 'getElementSize',
|
153 | GET_ELEMENT_ATTRIBUTE: 'getElementAttribute',
|
154 | GET_ELEMENT_VALUE_OF_CSS_PROPERTY: 'getElementValueOfCssProperty',
|
155 | GET_ELEMENT_PROPERTY: 'getElementProperty',
|
156 |
|
157 | SCREENSHOT: 'screenshot',
|
158 | TAKE_ELEMENT_SCREENSHOT: 'takeElementScreenshot',
|
159 | SET_SCRIPT_TIMEOUT: 'setScriptTimeout',
|
160 |
|
161 | PRINT_PAGE: 'printPage',
|
162 |
|
163 | GET_TIMEOUT: 'getTimeout',
|
164 | SET_TIMEOUT: 'setTimeout',
|
165 |
|
166 | ACCEPT_ALERT: 'acceptAlert',
|
167 | DISMISS_ALERT: 'dismissAlert',
|
168 | GET_ALERT_TEXT: 'getAlertText',
|
169 | SET_ALERT_TEXT: 'setAlertValue',
|
170 |
|
171 | GET_AVAILABLE_LOG_TYPES: 'getAvailableLogTypes',
|
172 | GET_LOG: 'getLog',
|
173 | GET_SESSION_LOGS: 'getSessionLogs',
|
174 |
|
175 |
|
176 | UPLOAD_FILE: 'uploadFile',
|
177 |
|
178 | ACTIONS: 'actions',
|
179 | CLEAR_ACTIONS: 'clearActions',
|
180 | }
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | class Executor {
|
187 | |
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | execute(command) {}
|
198 | }
|
199 |
|
200 |
|
201 |
|
202 | module.exports = {
|
203 | Command: Command,
|
204 | Name: Name,
|
205 | Executor: Executor,
|
206 | }
|