1 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
3 [GTK][WPE] Add API to provide browser information required by automation
4 https://bugs.webkit.org/show_bug.cgi?id=175130
6 Reviewed by Brian Burg.
9 (WebDriver::Session::createTopLevelBrowsingContext): Check if startAutomationSession and complete the command
10 with error in that case.
12 * glib/SessionHostGlib.cpp:
13 (WebDriver::SessionHost::matchCapabilities): Match the capabilities that are known only after the browser has
15 (WebDriver::SessionHost::startAutomationSession): Handle the StartAutomationSession response, extracting the
16 capabilities and calling matchCapabilities() to match them.
17 (WebDriver::SessionHost::setTargetList): Return early if the session was rejected before due to invalid
20 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
22 WebDriver: Implement page load strategy
23 https://bugs.webkit.org/show_bug.cgi?id=175183
25 Reviewed by Brian Burg.
27 Validate and parse page load strategy when processing capabilities.
31 (WebDriver::Session::pageLoadStrategyString const): Helper to get the page load strategy as a String to be
33 (WebDriver::Session::go): Pass page load strategy if present.
34 (WebDriver::Session::back): Ditto.
35 (WebDriver::Session::forward): Ditto.
36 (WebDriver::Session::refresh): Ditto.
37 (WebDriver::Session::waitForNavigationToComplete): Ditto.
39 * WebDriverService.cpp:
40 (WebDriver::deserializePageLoadStrategy):
41 (WebDriver::WebDriverService::parseCapabilities const):
42 (WebDriver::WebDriverService::validatedCapabilities const):
43 (WebDriver::WebDriverService::newSession):
45 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
47 Unreviewed. Try to fix build with clang after r220315.
49 * WebDriverService.cpp:
50 (WebDriver::WebDriverService::validatedCapabilities const):
51 (WebDriver::WebDriverService::mergeCapabilities const):
53 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
55 WebDriver: properly handle capabilities and process firstMatch too
56 https://bugs.webkit.org/show_bug.cgi?id=174618
58 Reviewed by Brian Burg.
60 Implement processing of capabilities following the spec. This patch adds validation, merging and matching of
63 7.2 Processing Capabilities.
64 https://w3c.github.io/webdriver/webdriver-spec.html#processing-capabilities
66 * Capabilities.h: Make all capabilities optional and move Timeouts struct here.
68 * WebDriverService.cpp:
69 (WebDriver::deserializeTimeouts): Helper to extract timeouts from JSON object.
70 (WebDriver::WebDriverService::parseCapabilities const): At this point capabilities have already been validated,
71 so we just need to get them without checking the value type.
72 (WebDriver::WebDriverService::validatedCapabilities const): Validate the given capabilities, ensuring types of
73 values are the expected one.
74 (WebDriver::WebDriverService::mergeCapabilities const): Merge the alwaysMatch and firstMatch capabilities into a
75 single object ensuring that the same capability is not in both.
76 (WebDriver::WebDriverService::matchCapabilities const): Try to match the merged capabilities againt the platform
77 expected capabilities.
78 (WebDriver::WebDriverService::processCapabilities const): Validate, merge and match the capabilities.
79 (WebDriver::WebDriverService::newSession): Use processCapabilities(). Also initialize the timeouts from
80 capabilities and add all capabilities to the command result.
81 (WebDriver::WebDriverService::setTimeouts): Use deserializeTimeouts().
83 * glib/SessionHostGlib.cpp:
84 (WebDriver::SessionHost::launchBrowser): Updated to properly access the capabilities that are now optional.
85 (WebDriver::SessionHost::startAutomationSession): Add FIXME.
86 * gtk/WebDriverServiceGtk.cpp:
87 (WebDriver::WebDriverService::platformCapabilities): Return the Capabilities with the known required ones filled.
88 (WebDriver::WebDriverService::platformValidateCapability const): Validate webkitgtk:browserOptions.
89 (WebDriver::WebDriverService::platformMatchCapability const): This does nothing for now.
90 (WebDriver::WebDriverService::platformCompareBrowserVersions): Compare the given browser versions.
91 (WebDriver::WebDriverService::platformParseCapabilities const): Updated now that capabilites have already been
94 2017-08-05 Carlos Garcia Campos <cgarcia@igalia.com>
96 WebDriver: use in-view center point for clicks instead of bounding box center point
97 https://bugs.webkit.org/show_bug.cgi?id=174863
99 Reviewed by Simon Fraser.
101 The center of the element bounding box is not always part of the element, like in multiline links, for example.
103 11.1 Element Interactability.
104 https://www.w3.org/TR/webdriver/#dfn-in-view-center-point
107 (WebDriver::CommandResult::httpStatusCode): Add ElementClickIntercepted and ElementNotInteractable errors.
108 (WebDriver::CommandResult::errorString): Ditto.
109 * CommandResult.h: Ditto.
111 (WebDriver::Session::computeElementLayout): Get the in-view center point and isObscured from the result too.
112 (WebDriver::Session::getElementRect): Ignore in-view center point and isObscured.
113 (WebDriver::Session::elementClick): Fail in case the element is not interactable or is obscured.
116 2017-08-01 Michael Catanzaro <mcatanzaro@igalia.com>
118 [CMake] WebKitFS.cmake depends on options set in Option cmake files that are included later
119 https://bugs.webkit.org/show_bug.cgi?id=174855
121 Reviewed by Carlos Garcia Campos.
123 Don't create derived sources directory here anymore.
127 2017-07-26 Carlos Garcia Campos <cgarcia@igalia.com>
129 Unreviewed. Fix GTK distcheck.
131 Ensure WebDriver derived sources directory is created, WebKitFS.cmake is useless for this.
135 2017-07-24 Carlos Garcia Campos <cgarcia@igalia.com>
137 WebDriver: rename m_browsingContext as m_currentBrowsingContext in Session
138 https://bugs.webkit.org/show_bug.cgi?id=174783
140 Reviewed by Brian Burg.
142 We have m_toplevelBrowsingContext and m_browsingContext, which is confusing. m_browsingContext is actually the
143 current browsing context, and the spec also refers to it as the current browsing context, so better use
144 m_currentBrowsingContext.
147 (WebDriver::Session::switchToTopLevelBrowsingContext):
148 (WebDriver::Session::switchToBrowsingContext):
149 (WebDriver::Session::switchToFrame):
150 (WebDriver::Session::switchToParentFrame):
151 (WebDriver::Session::computeElementLayout):
152 (WebDriver::Session::findElements):
153 (WebDriver::Session::isElementSelected):
154 (WebDriver::Session::getElementText):
155 (WebDriver::Session::getElementTagName):
156 (WebDriver::Session::isElementEnabled):
157 (WebDriver::Session::isElementDisplayed):
158 (WebDriver::Session::getElementAttribute):
159 (WebDriver::Session::waitForNavigationToComplete):
160 (WebDriver::Session::elementClear):
161 (WebDriver::Session::elementSendKeys):
162 (WebDriver::Session::elementSubmit):
163 (WebDriver::Session::executeScript):
166 2017-07-20 Carlos Garcia Campos <cgarcia@igalia.com>
168 WebDriver: implement page load timeout
169 https://bugs.webkit.org/show_bug.cgi?id=174672
171 Reviewed by Brian Burg.
173 Handle timeout errors and pass the page load timeout to waitForNavigationToComplete and all other navigation
174 commands. Also fix the setTimeouts command that was still using the legacy name of the page load timeout,
175 instead of the one in the spec.
178 https://www.w3.org/TR/webdriver/#dfn-session-page-load-timeout
181 (WebDriver::CommandResult::CommandResult):
182 (WebDriver::CommandResult::httpStatusCode):
183 (WebDriver::CommandResult::errorString):
186 (WebDriver::Session::go):
187 (WebDriver::Session::back):
188 (WebDriver::Session::forward):
189 (WebDriver::Session::refresh):
190 (WebDriver::Session::waitForNavigationToComplete):
191 * WebDriverService.cpp:
192 (WebDriver::WebDriverService::setTimeouts):
194 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
196 WebDriver: wait until navigation is complete before running new commands and after a click
197 https://bugs.webkit.org/show_bug.cgi?id=174670
199 Reviewed by Brian Burg.
201 We are already waiting for navigation to complete after navigation commands (go, back, forward, refresh), but
202 the spec says we should always wait before executing a new command and also after a click. This is causing test
203 testShouldBeAbleToNavigateBackInTheBrowserHistoryInPresenceOfIframes to sometimes fail, because it does .click()
204 + .title and expects the title to tbe the one of the page loaded by the click. Since the load happens very fast,
205 the test usually passes, but in a real case with a slower load, the title of the previous page will be returned
208 6.3 Processing Model. Step 7. Wait for navigation to complete. If this returns an error return its value and
209 jump to step 1 in this overall algorithm, otherwise continue.
210 https://www.w3.org/TR/webdriver/#processing-model
212 14.1 Element Click. Step 10. If the click causes navigation: 1. Run the post-navigation checks and return its
213 value if it is an error. 2. Try to wait for navigation to complete.
214 https://www.w3.org/TR/webdriver/#element-click
217 (WebDriver::Session::waitForNavigationToComplete): Send waitForNavigationToComplete message to the browser to
218 wait for any pending navigation of current browsing context to complete.
219 (WebDriver::Session::elementClick): Call waitForNavigationToComplete() after the click.
221 * WebDriverService.cpp:
222 (WebDriver::WebDriverService::go): Wait for navigations to complete before running the command.
223 (WebDriver::WebDriverService::getCurrentURL): Ditto.
224 (WebDriver::WebDriverService::back): Ditto.
225 (WebDriver::WebDriverService::forward): Ditto.
226 (WebDriver::WebDriverService::refresh): Ditto.
227 (WebDriver::WebDriverService::getTitle): Ditto.
228 (WebDriver::WebDriverService::switchToFrame): Ditto.
229 (WebDriver::WebDriverService::switchToParentFrame): Ditto.
230 (WebDriver::WebDriverService::findElement): Ditto.
231 (WebDriver::WebDriverService::findElements): Ditto.
232 (WebDriver::WebDriverService::executeScript): Ditto.
233 (WebDriver::WebDriverService::executeAsyncScript): Ditto.
235 2017-07-21 Carlos Garcia Campos <cgarcia@igalia.com>
237 WebDriver: correctly handle main frame handles
238 https://bugs.webkit.org/show_bug.cgi?id=174668
240 Reviewed by Brian Burg.
242 When I switched to use std::optional instead of empty strings for the browsing contexts in WebDriver, I forgot
243 that automation uses empty string for frames to refer to the main frame. We should handle that case, because we
244 are currently considering empty strings as valid browsing context. It's not a big deal because Automation
245 converts back the empty string received to the main frame, though. We should also ensure we close the current
246 browsing context when switching to a new top level browsing context. This patch adds to helper private methods
247 to switch browsing contexts that deal with the special cases.
250 (WebDriver::Session::close):
251 (WebDriver::Session::switchToTopLevelBrowsingContext):
252 (WebDriver::Session::switchToBrowsingContext):
253 (WebDriver::Session::createTopLevelBrowsingContext):
254 (WebDriver::Session::go):
255 (WebDriver::Session::back):
256 (WebDriver::Session::forward):
257 (WebDriver::Session::refresh):
258 (WebDriver::Session::switchToWindow):
259 (WebDriver::Session::switchToFrame):
260 (WebDriver::Session::switchToParentFrame):
263 2017-07-18 Carlos Garcia Campos <cgarcia@igalia.com>
265 WebDriver: handle invalid selector errors
266 https://bugs.webkit.org/show_bug.cgi?id=174619
268 Reviewed by Brian Burg.
270 Add InvalidSelector error and handle it in case of protocol server error.
273 (WebDriver::CommandResult::CommandResult):
274 (WebDriver::CommandResult::httpStatusCode):
275 (WebDriver::CommandResult::errorString):
278 2017-07-18 Carlos Alberto Lopez Perez <clopez@igalia.com>
280 [GTK] Fix build with Clang after r219605.
281 https://bugs.webkit.org/show_bug.cgi?id=166682
283 Unreviewed build fix.
285 Clang-3.8 complains with the following error:
286 non-constant-expression cannot be narrowed from type 'gboolean' (aka 'int') to 'bool' in initializer list [-Wc++11-narrowing]
288 * glib/SessionHostGlib.cpp: insert an explicit cast to silence this issue.
290 2017-07-13 Carlos Garcia Campos <cgarcia@igalia.com>
292 Add initial implementation of WebDriver process to run the HTTP server
293 https://bugs.webkit.org/show_bug.cgi?id=166682
295 Reviewed by Brian Burg.
297 Add WebDriver process that runs the HTTP server and implements an initial set of commands. Most of the code is
298 cross-platform, only the HTTP server implementation, the code to launch the browser and the communication with
299 the remote inspector requires platform specific code. This patch includes the GTK port implementation, using
300 libsoup for the HTTP server, and GLib for launching the browser and communicating with the remote
301 inspector. This implementation follows the w3c spec (https://www.w3.org/TR/webdriver) as close as possible, but
302 using the official selenium python tests as reference.
304 * CMakeLists.txt: Added.
305 * Capabilities.h: Added.
306 * CommandResult.cpp: Added.
307 * CommandResult.h: Added.
308 * HTTPServer.cpp: Added.
309 * HTTPServer.h: Added.
310 * PlatformGTK.cmake: Added.
311 * Session.cpp: Added.
313 * SessionHost.cpp: Added.
314 * SessionHost.h: Added.
315 * WebDriverMain.cpp: Added.
316 * WebDriverService.cpp: Added.
317 * WebDriverService.h: Added.
319 * glib/SessionHostGlib.cpp: Added.
320 * gtk/WebDriverServiceGtk.cpp: Added.
321 * soup/HTTPServerSoup.cpp: Added.