Skip to content

Commit 64efd11

Browse files
committed
Adding W3C spec compliant element serialization to IE driver
1 parent 17d4b0e commit 64efd11

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

cpp/iedriver/CommandHandlers/ExecuteScriptCommandHandler.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,14 @@ class ExecuteScriptCommandHandler : public IECommandHandler {
118118
} else if (arg.isArray()) {
119119
status_code = this->WalkArray(executor, script_wrapper, arg);
120120
} else if (arg.isObject()) {
121-
if (arg.isMember("ELEMENT")) {
122-
std::string element_id = arg["ELEMENT"].asString();
121+
// TODO: Remove the check for "ELEMENT" once all target bindings
122+
// have been updated to use spec-compliant protocol.
123+
std::string element_marker_property_name = "element-6066-11e4-a52e-4f735466cecf";
124+
if (!arg.isMember(element_marker_property_name)) {
125+
element_marker_property_name = "ELEMENT";
126+
}
127+
if (arg.isMember(element_marker_property_name)) {
128+
std::string element_id = arg[element_marker_property_name].asString();
123129

124130
ElementHandle element_wrapper;
125131
status_code = this->GetElement(executor, element_id, &element_wrapper);

cpp/iedriver/CommandHandlers/SwitchToFrameCommandHandler.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ class SwitchToFrameCommandHandler : public IECommandHandler {
5050
if (frame_id.isNull()) {
5151
status_code = browser_wrapper->SetFocusedFrameByElement(NULL);
5252
} else if (frame_id.isObject()) {
53-
Json::Value element_id = frame_id.get("ELEMENT", Json::Value::null);
53+
// TODO: Remove the check for "ELEMENT" once all target bindings
54+
// have been updated to use spec-compliant protocol.
55+
Json::Value element_id = frame_id.get("element-6066-11e4-a52e-4f735466cecf", Json::Value::null);
56+
if (element_id.isNull()) {
57+
element_id = frame_id.get("ELEMENT", Json::Value::null);
58+
}
59+
5460
if (element_id.isNull()) {
5561
status_code = ENOSUCHFRAME;
5662
} else {

cpp/iedriver/Element.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ Json::Value Element::ConvertToJson() {
7272
LOG(TRACE) << "Entering Element::ConvertToJson";
7373

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

7780
return json_wrapper;

0 commit comments

Comments
 (0)