Changeset 226052 in webkit
- Timestamp:
- Dec 18, 2017 9:34:53 AM (6 years ago)
- Location:
- releases/WebKitGTK/webkit-2.18/Source/WebDriver
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.18/Source/WebDriver/ChangeLog
r226051 r226052 1 2017-12-04 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 WebDriver: implement element property command 4 https://bugs.webkit.org/show_bug.cgi?id=180244 5 6 Reviewed by Brian Burg. 7 8 13.3 Get Element Property 9 https://w3c.github.io/webdriver/webdriver-spec.html#get-element-property 10 11 Fixes: imported/w3c/webdriver/tests/state/get_element_property.py::test_no_browsing_context 12 imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_dismiss 13 imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_accept 14 imported/w3c/webdriver/tests/state/get_element_property.py::test_handle_prompt_missing_value 15 imported/w3c/webdriver/tests/state/get_element_property.py::test_element_stale 16 17 * Session.cpp: 18 (WebDriver::Session::getElementAttribute): 19 (WebDriver::Session::getElementProperty): 20 * Session.h: 21 * WebDriverService.cpp: 22 (WebDriver::WebDriverService::getElementProperty): 23 * WebDriverService.h: 24 1 25 2017-12-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 26 -
releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.cpp
r226051 r226052 1269 1269 parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value()); 1270 1270 parameters->setString(ASCIILiteral("function"), ElementAttributeJavaScript); 1271 parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments)); 1272 m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) { 1273 if (response.isError || !response.responseObject) { 1274 completionHandler(CommandResult::fail(WTFMove(response.responseObject))); 1275 return; 1276 } 1277 String valueString; 1278 if (!response.responseObject->getString(ASCIILiteral("result"), valueString)) { 1279 completionHandler(CommandResult::fail(CommandResult::ErrorCode::UnknownError)); 1280 return; 1281 } 1282 RefPtr<JSON::Value> resultValue; 1283 if (!JSON::Value::parseJSON(valueString, resultValue)) { 1284 completionHandler(CommandResult::fail(CommandResult::ErrorCode::UnknownError)); 1285 return; 1286 } 1287 completionHandler(CommandResult::success(WTFMove(resultValue))); 1288 }); 1289 }); 1290 } 1291 1292 void Session::getElementProperty(const String& elementID, const String& property, Function<void (CommandResult&&)>&& completionHandler) 1293 { 1294 if (!m_toplevelBrowsingContext) { 1295 completionHandler(CommandResult::fail(CommandResult::ErrorCode::NoSuchWindow)); 1296 return; 1297 } 1298 1299 handleUserPrompts([this, elementID, property, completionHandler = WTFMove(completionHandler)](CommandResult&& result) mutable { 1300 if (result.isError()) { 1301 completionHandler(WTFMove(result)); 1302 return; 1303 } 1304 RefPtr<JSON::Array> arguments = JSON::Array::create(); 1305 arguments->pushString(createElement(elementID)->toJSONString()); 1306 1307 RefPtr<JSON::Object> parameters = JSON::Object::create(); 1308 parameters->setString(ASCIILiteral("browsingContextHandle"), m_toplevelBrowsingContext.value()); 1309 if (m_currentBrowsingContext) 1310 parameters->setString(ASCIILiteral("frameHandle"), m_currentBrowsingContext.value()); 1311 parameters->setString(ASCIILiteral("function"), makeString("function(element) { return element.", property, "; }")); 1271 1312 parameters->setArray(ASCIILiteral("arguments"), WTFMove(arguments)); 1272 1313 m_host->sendCommandToBackend(ASCIILiteral("evaluateJavaScriptFunction"), WTFMove(parameters), [this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)](SessionHost::CommandResponse&& response) { -
releases/WebKitGTK/webkit-2.18/Source/WebDriver/Session.h
r226051 r226052 88 88 void getActiveElement(Function<void (CommandResult&&)>&&); 89 89 void isElementSelected(const String& elementID, Function<void (CommandResult&&)>&&); 90 void getElementAttribute(const String& elementID, const String& attribute, Function<void (CommandResult&&)>&&); 91 void getElementProperty(const String& elementID, const String& attribute, Function<void (CommandResult&&)>&&); 90 92 void getElementText(const String& elementID, Function<void (CommandResult&&)>&&); 91 93 void getElementTagName(const String& elementID, Function<void (CommandResult&&)>&&); … … 93 95 void isElementEnabled(const String& elementID, Function<void (CommandResult&&)>&&); 94 96 void isElementDisplayed(const String& elementID, Function<void (CommandResult&&)>&&); 95 void getElementAttribute(const String& elementID, const String& attribute, Function<void (CommandResult&&)>&&);96 97 void elementClick(const String& elementID, Function<void (CommandResult&&)>&&); 97 98 void elementClear(const String& elementID, Function<void (CommandResult&&)>&&); -
releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.cpp
r226046 r226052 128 128 { HTTPMethod::Get, "/session/$sessionId/element/$elementId/selected", &WebDriverService::isElementSelected }, 129 129 { HTTPMethod::Get, "/session/$sessionId/element/$elementId/attribute/$name", &WebDriverService::getElementAttribute }, 130 { HTTPMethod::Get, "/session/$sessionId/element/$elementId/property/$name", &WebDriverService::getElementProperty }, 130 131 { HTTPMethod::Get, "/session/$sessionId/element/$elementId/text", &WebDriverService::getElementText }, 131 132 { HTTPMethod::Get, "/session/$sessionId/element/$elementId/name", &WebDriverService::getElementTagName }, … … 1134 1135 } 1135 1136 1137 void WebDriverService::getElementProperty(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler) 1138 { 1139 // §13.3 Get Element Property 1140 // https://w3c.github.io/webdriver/webdriver-spec.html#get-element-property 1141 if (!findSessionOrCompleteWithError(*parameters, completionHandler)) 1142 return; 1143 1144 auto elementID = findElementOrCompleteWithError(*parameters, completionHandler); 1145 if (!elementID) 1146 return; 1147 1148 String attribute; 1149 if (!parameters->getString(ASCIILiteral("name"), attribute)) { 1150 completionHandler(CommandResult::fail(CommandResult::ErrorCode::InvalidArgument)); 1151 return; 1152 } 1153 1154 m_session->getElementProperty(elementID.value(), attribute, WTFMove(completionHandler)); 1155 } 1156 1136 1157 void WebDriverService::getElementText(RefPtr<JSON::Object>&& parameters, Function<void (CommandResult&&)>&& completionHandler) 1137 1158 { -
releases/WebKitGTK/webkit-2.18/Source/WebDriver/WebDriverService.h
r226046 r226052 85 85 void getActiveElement(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 86 86 void isElementSelected(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 87 void getElementAttribute(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 88 void getElementProperty(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 87 89 void getElementText(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 88 90 void getElementTagName(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); … … 90 92 void isElementEnabled(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 91 93 void isElementDisplayed(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 92 void getElementAttribute(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);93 94 void elementClick(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&); 94 95 void elementClear(RefPtr<JSON::Object>&&, Function<void (CommandResult&&)>&&);
Note: See TracChangeset
for help on using the changeset viewer.