1 2017-08-07 Carlos Garcia Campos <cgarcia@igalia.com>
3 WebDriver: implement user prompt commands
4 https://bugs.webkit.org/show_bug.cgi?id=174614
6 Reviewed by Brian Burg.
9 (WebDriver::CommandResult::CommandResult): Handle NoJavaScriptDialog protocol error.
10 (WebDriver::CommandResult::httpStatusCode const): Add NoSuchAlert.
11 (WebDriver::CommandResult::errorString const): Ditto.
14 (WebDriver::Session::dismissAlert):
15 (WebDriver::Session::acceptAlert):
16 (WebDriver::Session::getAlertText):
17 (WebDriver::Session::sendAlertText):
19 * WebDriverService.cpp:
20 (WebDriver::WebDriverService::dismissAlert):
21 (WebDriver::WebDriverService::acceptAlert):
22 (WebDriver::WebDriverService::getAlertText):
23 (WebDriver::WebDriverService::sendAlertText):
26 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
28 [GTK][WPE] Add API to provide browser information required by automation
29 https://bugs.webkit.org/show_bug.cgi?id=175130
31 Reviewed by Brian Burg.
34 (WebDriver::Session::createTopLevelBrowsingContext): Check if startAutomationSession and complete the command
35 with error in that case.
37 * glib/SessionHostGlib.cpp:
38 (WebDriver::SessionHost::matchCapabilities): Match the capabilities that are known only after the browser has
40 (WebDriver::SessionHost::startAutomationSession): Handle the StartAutomationSession response, extracting the
41 capabilities and calling matchCapabilities() to match them.
42 (WebDriver::SessionHost::setTargetList): Return early if the session was rejected before due to invalid
45 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
47 WebDriver: Implement page load strategy
48 https://bugs.webkit.org/show_bug.cgi?id=175183
50 Reviewed by Brian Burg.
52 Validate and parse page load strategy when processing capabilities.
56 (WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
58 (WebDriver::Session::go): Pass page load strategy if present.
59 (WebDriver::Session::back): Ditto.
60 (WebDriver::Session::forward): Ditto.
61 (WebDriver::Session::refresh): Ditto.
62 (WebDriver::Session::waitForNavigationToComplete): Ditto.
64 * WebDriverService.cpp:
65 (WebDriver::deserializePageLoadStrategy):
66 (WebDriver::WebDriverService::parseCapabilities const):
67 (WebDriver::WebDriverService::validatedCapabilities const):
68 (WebDriver::WebDriverService::newSession):
70 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
72 Unreviewed. Try to fix build with clang after r220315.
74 * WebDriverService.cpp:
75 (WebDriver::WebDriverService::validatedCapabilities const):
76 (WebDriver::WebDriverService::mergeCapabilities const):
78 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
80 WebDriver: properly handle capabilities and process firstMatch too
81 https://bugs.webkit.org/show_bug.cgi?id=174618
83 Reviewed by Brian Burg.
85 Implement processing of capabilities following the spec. This patch adds validation, merging and matching of
88 7.2 Processing Capabilities.
89 https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
91 * Capabilities.h: Make all capabilities optional and move Timeouts struct here.
93 * WebDriverService.cpp:
94 (WebDriver::deserializeTimeouts): Helper to extract timeouts from JSON object.
95 (WebDriver::WebDriverService::parseCapabilities const): At this point capabilities have already been validated,
96 so we just need to get them without checking the value type.
97 (WebDriver::WebDriverService::validatedCapabilities const): Validate the given capabilities, ensuring types of
98 values are the expected one.
99 (WebDriver::WebDriverService::mergeCapabilities const): Merge the alwaysMatch and firstMatch capabilities into a
100 single object ensuring that the same capability is not in both.
101 (WebDriver::WebDriverService::matchCapabilities const): Try to match the merged capabilities againt the platform
102 expected capabilities.
103 (WebDriver::WebDriverService::processCapabilities const): Validate, merge and match the capabilities.
104 (WebDriver::WebDriverService::newSession): Use processCapabilities(). Also initialize the timeouts from
105 capabilities and add all capabilities to the command result.
106 (WebDriver::WebDriverService::setTimeouts): Use deserializeTimeouts().
107 * WebDriverService.h:
108 * glib/SessionHostGlib.cpp:
109 (WebDriver::SessionHost::launchBrowser): Updated to properly access the capabilities that are now optional.
110 (WebDriver::SessionHost::startAutomationSession): Add FIXME.
111 * gtk/WebDriverServiceGtk.cpp:
112 (WebDriver::WebDriverService::platformCapabilities): Return the Capabilities with the known required ones filled.
113 (WebDriver::WebDriverService::platformValidateCapability const): Validate webkitgtk:browserOptions.
114 (WebDriver::WebDriverService::platformMatchCapability const): This does nothing for now.
115 (WebDriver::WebDriverService::platformCompareBrowserVersions): Compare the given browser versions.
116 (WebDriver::WebDriverService::platformParseCapabilities const): Updated now that capabilites have already been
119 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
121 WebDriver: use in-view center point for clicks instead of bounding box center point
122 https://bugs.webkit.org/show_bug.cgi?id=174863
124 Reviewed by Simon Fraser.
126 The center of the element bounding box is not always part of the element, like in multiline links, for example.
128 11.1 Element Interactability.
129 https://www.w3.org/TR/webdriver/#dfn-in-view-center-point
132 (WebDriver::CommandResult::httpStatusCode): Add ElementClickIntercepted and ElementNotInteractable errors.
133 (WebDriver::CommandResult::errorString): Ditto.
134 * CommandResult.h: Ditto.
136 (WebDriver::Session::computeElementLayout): Get the in-view center point and isObscured from the result too.
137 (WebDriver::Session::getElementRect): Ignore in-view center point and isObscured.
138 (WebDriver::Session::elementClick): Fail in case the element is not interactable or is obscured.
141 2017-08-01 Michael Catanzaro <mcatanzaro@igalia.com>
143 [CMake] WebKitFS.cmake depends on options set in Option cmake files that are included later
144 https://bugs.webkit.org/show_bug.cgi?id=174855
146 Reviewed by Carlos Garcia Campos.
148 Don't create derived sources directory here anymore.
152 2017-07-26 Carlos Garcia Campos <cgarcia@igalia.com>
154 Unreviewed. Fix GTK distcheck.
156 Ensure WebDriver derived sources directory is created, WebKitFS.cmake is useless for this.
160 2017-07-24 Carlos Garcia Campos <cgarcia@igalia.com>
162 WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
163 https://bugs.webkit.org/show_bug.cgi?id=174783
165 Reviewed by Brian Burg.
167 We have m_toplevelBrowsingContext and m_browsingContext, which is confusing. m_browsingContext is actually the
168 current browsing context, and the spec also refers to it as the current browsing context, so better use
169 m_currentBrowsingContext.
172 (WebDriver::Session::switchToTopLevelBrowsingContext):
173 (WebDriver::Session::switchToBrowsingContext):
174 (WebDriver::Session::switchToFrame):
175 (WebDriver::Session::switchToParentFrame):
176 (WebDriver::Session::computeElementLayout):
177 (WebDriver::Session::findElements):
178 (WebDriver::Session::isElementSelected):
179 (WebDriver::Session::getElementText):
180 (WebDriver::Session::getElementTagName):
181 (WebDriver::Session::isElementEnabled):
182 (WebDriver::Session::isElementDisplayed):
183 (WebDriver::Session::getElementAttribute):
184 (WebDriver::Session::waitForNavigationToComplete):
185 (WebDriver::Session::elementClear):
186 (WebDriver::Session::elementSendKeys):
187 (WebDriver::Session::elementSubmit):
188 (WebDriver::Session::executeScript):
191 2017-07-20 Carlos Garcia Campos <cgarcia@igalia.com>
193 WebDriver: implement page load timeout
194 https://bugs.webkit.org/show_bug.cgi?id=174672
196 Reviewed by Brian Burg.
198 Handle timeout errors and pass the page load timeout to waitForNavigationToComplete and all other navigation
199 commands. Also fix the setTimeouts command that was still using the legacy name of the page load timeout,
200 instead of the one in the spec.
203 https://www.w3.org/TR/webdriver/#dfn-session-page-load-timeout
206 (WebDriver::CommandResult::CommandResult):
207 (WebDriver::CommandResult::httpStatusCode):
208 (WebDriver::CommandResult::errorString):
211 (WebDriver::Session::go):
212 (WebDriver::Session::back):
213 (WebDriver::Session::forward):
214 (WebDriver::Session::refresh):
215 (WebDriver::Session::waitForNavigationToComplete):
216 * WebDriverService.cpp:
217 (WebDriver::WebDriverService::setTimeouts):
219 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
221 WebDriver: wait until navigation is complete before running new commands and after a click
222 https://bugs.webkit.org/show_bug.cgi?id=174670
224 Reviewed by Brian Burg.
226 We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
227 the spec says we should always wait before executing a new command and also after a click. This is causing test
228 testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
229 + .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
230 the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
233 6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
234 jump to step 1 in this overall algorithm, otherwise continue.
235 https://www.w3.org/TR/webdriver/#processing-model
237 14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
238 value if it is an error. 2. Try to wait for navigation to complete.
239 https://www.w3.org/TR/webdriver/#element-click
242 (WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
243 wait for any pending navigation of current browsing context to complete.
244 (WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
246 * WebDriverService.cpp:
247 (WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
248 (WebDriver::WebDriverService::getCurrentURL): Ditto.
249 (WebDriver::WebDriverService::back): Ditto.
250 (WebDriver::WebDriverService::forward): Ditto.
251 (WebDriver::WebDriverService::refresh): Ditto.
252 (WebDriver::WebDriverService::getTitle): Ditto.
253 (WebDriver::WebDriverService::switchToFrame): Ditto.
254 (WebDriver::WebDriverService::switchToParentFrame): Ditto.
255 (WebDriver::WebDriverService::findElement): Ditto.
256 (WebDriver::WebDriverService::findElements): Ditto.
257 (WebDriver::WebDriverService::executeScript): Ditto.
258 (WebDriver::WebDriverService::executeAsyncScript): Ditto.
260 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
262 WebDriver: correctly handle main frame handles
263 https://bugs.webkit.org/show_bug.cgi?id=174668
265 Reviewed by Brian Burg.
267 When I switched to use std::optional instead of empty strings for the browsing contexts in WebDriver, I forgot
268 that automation uses empty string for frames to refer to the main frame. We should handle that case, because we
269 are currently considering empty strings as valid browsing context. It's not a big deal because Automation
270 converts back the empty string received to the main frame, though. We should also ensure we close the current
271 browsing context when switching to a new top level browsing context. This patch adds to helper private methods
272 to switch browsing contexts that deal with the special cases.
275 (WebDriver::Session::close):
276 (WebDriver::Session::switchToTopLevelBrowsingContext):
277 (WebDriver::Session::switchToBrowsingContext):
278 (WebDriver::Session::createTopLevelBrowsingContext):
279 (WebDriver::Session::go):
280 (WebDriver::Session::back):
281 (WebDriver::Session::forward):
282 (WebDriver::Session::refresh):
283 (WebDriver::Session::switchToWindow):
284 (WebDriver::Session::switchToFrame):
285 (WebDriver::Session::switchToParentFrame):
288 2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
290 WebDriver: handle invalid selector errors
291 https://bugs.webkit.org/show_bug.cgi?id=174619
293 Reviewed by Brian Burg.
295 Add InvalidSelector error and handle it in case of protocol server error.
298 (WebDriver::CommandResult::CommandResult):
299 (WebDriver::CommandResult::httpStatusCode):
300 (WebDriver::CommandResult::errorString):
303 2017-07-18 Carlos Alberto Lopez Perez <clopez@igalia.com>
305 [GTK] Fix build with Clang after r219605.
306 https://bugs.webkit.org/show_bug.cgi?id=166682
308 Unreviewed build fix.
310 Clang-3.8 complains with the following error:
311 non-constant-expression cannot be narrowed from type 'gboolean' (aka 'int') to 'bool' in initializer list [-Wc++11-narrowing]
313 * glib/SessionHostGlib.cpp: insert an explicit cast to silence this issue.
315 2017-07-13 Carlos Garcia Campos <cgarcia@igalia.com>
317 Add initial implementation of WebDriver process to run the HTTP server
318 https://bugs.webkit.org/show_bug.cgi?id=166682
320 Reviewed by Brian Burg.
322 Add WebDriver process that runs the HTTP server and implements an initial set of commands. Most of the code is
323 cross-platform, only the HTTP server implementation, the code to launch the browser and the communication with
324 the remote inspector requires platform specific code. This patch includes the GTK port implementation, using
325 libsoup for the HTTP server, and GLib for launching the browser and communicating with the remote
326 inspector. This implementation follows the w3c spec (https://www.w3.org/TR/webdriver) as close as possible, but
327 using the official selenium python tests as reference.
329 * CMakeLists.txt: Added.
330 * Capabilities.h: Added.
331 * CommandResult.cpp: Added.
332 * CommandResult.h: Added.
333 * HTTPServer.cpp: Added.
334 * HTTPServer.h: Added.
335 * PlatformGTK.cmake: Added.
336 * Session.cpp: Added.
338 * SessionHost.cpp: Added.
339 * SessionHost.h: Added.
340 * WebDriverMain.cpp: Added.
341 * WebDriverService.cpp: Added.
342 * WebDriverService.h: Added.
344 * glib/SessionHostGlib.cpp: Added.
345 * gtk/WebDriverServiceGtk.cpp: Added.
346 * soup/HTTPServerSoup.cpp: Added.