Skip to content

Commit

Permalink
Adding W3C spec compliant element serialization to IE driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Mar 3, 2015
1 parent 17d4b0e commit 64efd11
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions cpp/iedriver/CommandHandlers/ExecuteScriptCommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ class ExecuteScriptCommandHandler : public IECommandHandler {
} else if (arg.isArray()) {
status_code = this->WalkArray(executor, script_wrapper, arg);
} else if (arg.isObject()) {
if (arg.isMember("ELEMENT")) {
std::string element_id = arg["ELEMENT"].asString();
// TODO: Remove the check for "ELEMENT" once all target bindings
// have been updated to use spec-compliant protocol.
std::string element_marker_property_name = "element-6066-11e4-a52e-4f735466cecf";
if (!arg.isMember(element_marker_property_name)) {
element_marker_property_name = "ELEMENT";
}
if (arg.isMember(element_marker_property_name)) {
std::string element_id = arg[element_marker_property_name].asString();

ElementHandle element_wrapper;
status_code = this->GetElement(executor, element_id, &element_wrapper);
Expand Down
8 changes: 7 additions & 1 deletion cpp/iedriver/CommandHandlers/SwitchToFrameCommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ class SwitchToFrameCommandHandler : public IECommandHandler {
if (frame_id.isNull()) {
status_code = browser_wrapper->SetFocusedFrameByElement(NULL);
} else if (frame_id.isObject()) {
Json::Value element_id = frame_id.get("ELEMENT", Json::Value::null);
// TODO: Remove the check for "ELEMENT" once all target bindings
// have been updated to use spec-compliant protocol.
Json::Value element_id = frame_id.get("element-6066-11e4-a52e-4f735466cecf", Json::Value::null);
if (element_id.isNull()) {
element_id = frame_id.get("ELEMENT", Json::Value::null);
}

if (element_id.isNull()) {
status_code = ENOSUCHFRAME;
} else {
Expand Down
3 changes: 3 additions & 0 deletions cpp/iedriver/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ Json::Value Element::ConvertToJson() {
LOG(TRACE) << "Entering Element::ConvertToJson";

Json::Value json_wrapper;
// TODO: Remove the "ELEMENT" property once all target bindings
// have been updated to use spec-compliant protocol.
json_wrapper["element-6066-11e4-a52e-4f735466cecf"] = this->element_id_;
json_wrapper["ELEMENT"] = this->element_id_;

return json_wrapper;
Expand Down

0 comments on commit 64efd11

Please sign in to comment.