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 |
|
88 | const Name = {
|
89 | GET_SERVER_STATUS: 'getStatus',
|
90 |
|
91 | NEW_SESSION: 'newSession',
|
92 | GET_SESSIONS: 'getSessions',
|
93 | DESCRIBE_SESSION: 'getSessionCapabilities',
|
94 |
|
95 | CLOSE: 'close',
|
96 | QUIT: 'quit',
|
97 |
|
98 | GET_CURRENT_URL: 'getCurrentUrl',
|
99 | GET: 'get',
|
100 | GO_BACK: 'goBack',
|
101 | GO_FORWARD: 'goForward',
|
102 | REFRESH: 'refresh',
|
103 |
|
104 | ADD_COOKIE: 'addCookie',
|
105 | GET_COOKIE: 'getCookie',
|
106 | GET_ALL_COOKIES: 'getCookies',
|
107 | DELETE_COOKIE: 'deleteCookie',
|
108 | DELETE_ALL_COOKIES: 'deleteAllCookies',
|
109 |
|
110 | GET_ACTIVE_ELEMENT: 'getActiveElement',
|
111 | FIND_ELEMENT: 'findElement',
|
112 | FIND_ELEMENTS: 'findElements',
|
113 | FIND_CHILD_ELEMENT: 'findChildElement',
|
114 | FIND_CHILD_ELEMENTS: 'findChildElements',
|
115 |
|
116 | CLEAR_ELEMENT: 'clearElement',
|
117 | CLICK_ELEMENT: 'clickElement',
|
118 | SEND_KEYS_TO_ELEMENT: 'sendKeysToElement',
|
119 | SUBMIT_ELEMENT: 'submitElement',
|
120 |
|
121 | GET_CURRENT_WINDOW_HANDLE: 'getCurrentWindowHandle',
|
122 | GET_WINDOW_HANDLES: 'getWindowHandles',
|
123 | GET_WINDOW_POSITION: 'getWindowPosition',
|
124 | SET_WINDOW_POSITION: 'setWindowPosition',
|
125 | GET_WINDOW_SIZE: 'getWindowSize',
|
126 | SET_WINDOW_SIZE: 'setWindowSize',
|
127 | MAXIMIZE_WINDOW: 'maximizeWindow',
|
128 |
|
129 | SWITCH_TO_WINDOW: 'switchToWindow',
|
130 | SWITCH_TO_FRAME: 'switchToFrame',
|
131 | GET_PAGE_SOURCE: 'getPageSource',
|
132 | GET_TITLE: 'getTitle',
|
133 |
|
134 | EXECUTE_SCRIPT: 'executeScript',
|
135 | EXECUTE_ASYNC_SCRIPT: 'executeAsyncScript',
|
136 |
|
137 | GET_ELEMENT_TEXT: 'getElementText',
|
138 | GET_ELEMENT_TAG_NAME: 'getElementTagName',
|
139 | IS_ELEMENT_SELECTED: 'isElementSelected',
|
140 | IS_ELEMENT_ENABLED: 'isElementEnabled',
|
141 | IS_ELEMENT_DISPLAYED: 'isElementDisplayed',
|
142 | GET_ELEMENT_LOCATION: 'getElementLocation',
|
143 | GET_ELEMENT_LOCATION_IN_VIEW: 'getElementLocationOnceScrolledIntoView',
|
144 | GET_ELEMENT_SIZE: 'getElementSize',
|
145 | GET_ELEMENT_ATTRIBUTE: 'getElementAttribute',
|
146 | GET_ELEMENT_VALUE_OF_CSS_PROPERTY: 'getElementValueOfCssProperty',
|
147 | ELEMENT_EQUALS: 'elementEquals',
|
148 |
|
149 | SCREENSHOT: 'screenshot',
|
150 | TAKE_ELEMENT_SCREENSHOT: 'takeElementScreenshot',
|
151 | IMPLICITLY_WAIT: 'implicitlyWait',
|
152 | SET_SCRIPT_TIMEOUT: 'setScriptTimeout',
|
153 | SET_TIMEOUT: 'setTimeout',
|
154 |
|
155 | ACCEPT_ALERT: 'acceptAlert',
|
156 | DISMISS_ALERT: 'dismissAlert',
|
157 | GET_ALERT_TEXT: 'getAlertText',
|
158 | SET_ALERT_TEXT: 'setAlertValue',
|
159 | SET_ALERT_CREDENTIALS: 'setAlertCredentials',
|
160 |
|
161 | EXECUTE_SQL: 'executeSQL',
|
162 | GET_LOCATION: 'getLocation',
|
163 | SET_LOCATION: 'setLocation',
|
164 | GET_APP_CACHE: 'getAppCache',
|
165 | GET_APP_CACHE_STATUS: 'getStatus',
|
166 | CLEAR_APP_CACHE: 'clearAppCache',
|
167 | IS_BROWSER_ONLINE: 'isBrowserOnline',
|
168 | SET_BROWSER_ONLINE: 'setBrowserOnline',
|
169 |
|
170 | GET_LOCAL_STORAGE_ITEM: 'getLocalStorageItem',
|
171 | GET_LOCAL_STORAGE_KEYS: 'getLocalStorageKeys',
|
172 | SET_LOCAL_STORAGE_ITEM: 'setLocalStorageItem',
|
173 | REMOVE_LOCAL_STORAGE_ITEM: 'removeLocalStorageItem',
|
174 | CLEAR_LOCAL_STORAGE: 'clearLocalStorage',
|
175 | GET_LOCAL_STORAGE_SIZE: 'getLocalStorageSize',
|
176 |
|
177 | GET_SESSION_STORAGE_ITEM: 'getSessionStorageItem',
|
178 | GET_SESSION_STORAGE_KEYS: 'getSessionStorageKey',
|
179 | SET_SESSION_STORAGE_ITEM: 'setSessionStorageItem',
|
180 | REMOVE_SESSION_STORAGE_ITEM: 'removeSessionStorageItem',
|
181 | CLEAR_SESSION_STORAGE: 'clearSessionStorage',
|
182 | GET_SESSION_STORAGE_SIZE: 'getSessionStorageSize',
|
183 |
|
184 | SET_SCREEN_ORIENTATION: 'setScreenOrientation',
|
185 | GET_SCREEN_ORIENTATION: 'getScreenOrientation',
|
186 |
|
187 |
|
188 |
|
189 | CLICK: 'mouseClick',
|
190 | DOUBLE_CLICK: 'mouseDoubleClick',
|
191 | MOUSE_DOWN: 'mouseButtonDown',
|
192 | MOUSE_UP: 'mouseButtonUp',
|
193 | MOVE_TO: 'mouseMoveTo',
|
194 | SEND_KEYS_TO_ACTIVE_ELEMENT: 'sendKeysToActiveElement',
|
195 |
|
196 |
|
197 | TOUCH_SINGLE_TAP: 'touchSingleTap',
|
198 | TOUCH_DOWN: 'touchDown',
|
199 | TOUCH_UP: 'touchUp',
|
200 | TOUCH_MOVE: 'touchMove',
|
201 | TOUCH_SCROLL: 'touchScroll',
|
202 | TOUCH_DOUBLE_TAP: 'touchDoubleTap',
|
203 | TOUCH_LONG_PRESS: 'touchLongPress',
|
204 | TOUCH_FLICK: 'touchFlick',
|
205 |
|
206 | GET_AVAILABLE_LOG_TYPES: 'getAvailableLogTypes',
|
207 | GET_LOG: 'getLog',
|
208 | GET_SESSION_LOGS: 'getSessionLogs',
|
209 |
|
210 |
|
211 | UPLOAD_FILE: 'uploadFile'
|
212 | };
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 | class Executor {
|
221 | |
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | execute(command) {}
|
232 | }
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 | module.exports = {
|
240 | Command: Command,
|
241 | Name: Name,
|
242 | Executor: Executor
|
243 | };
|