Skip to content

Commit 17d4b0e

Browse files
committed
Adding ability to handle W3C spec compliant element serialization in .NET
1 parent 3bef150 commit 17d4b0e

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

dotnet/src/webdriver/Remote/RemoteTargetLocator.cs

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public IWebDriver Frame(IWebElement frameElement)
9090

9191
Dictionary<string, object> elementDictionary = new Dictionary<string, object>();
9292
elementDictionary.Add("ELEMENT", convertedElement.InternalElementId);
93+
elementDictionary.Add("element-6066-11e4-a52e-4f735466cecf", convertedElement.InternalElementId);
9394

9495
Dictionary<string, object> parameters = new Dictionary<string, object>();
9596
parameters.Add("id", elementDictionary);

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

+13-14
Original file line numberDiff line numberDiff line change
@@ -800,13 +800,13 @@ internal IWebElement GetElementFromResponse(Response response)
800800
// TODO: Remove this "if" logic once the spec is properly updated
801801
// and remote-end implementations comply.
802802
string id = string.Empty;
803-
if (elementDictionary.ContainsKey("ELEMENT"))
803+
if (elementDictionary.ContainsKey("element-6066-11e4-a52e-4f735466cecf"))
804804
{
805-
id = (string)elementDictionary["ELEMENT"];
805+
id = (string)elementDictionary["element-6066-11e4-a52e-4f735466cecf"];
806806
}
807-
else if (elementDictionary.ContainsKey("id"))
807+
else if (elementDictionary.ContainsKey("ELEMENT"))
808808
{
809-
id = (string)elementDictionary["id"];
809+
id = (string)elementDictionary["ELEMENT"];
810810
}
811811

812812
element = this.CreateElement(id);
@@ -832,13 +832,13 @@ internal ReadOnlyCollection<IWebElement> GetElementsFromResponse(Response respon
832832
// TODO: Remove this "if" logic once the spec is properly updated
833833
// and remote-end implementations comply.
834834
string id = string.Empty;
835-
if (elementDictionary.ContainsKey("ELEMENT"))
835+
if (elementDictionary.ContainsKey("element-6066-11e4-a52e-4f735466cecf"))
836836
{
837-
id = (string)elementDictionary["ELEMENT"];
837+
id = (string)elementDictionary["element-6066-11e4-a52e-4f735466cecf"];
838838
}
839-
else if (elementDictionary.ContainsKey("id"))
839+
else if (elementDictionary.ContainsKey("ELEMENT"))
840840
{
841-
id = (string)elementDictionary["id"];
841+
id = (string)elementDictionary["ELEMENT"];
842842
}
843843

844844
RemoteWebElement element = this.CreateElement(id);
@@ -1036,7 +1036,7 @@ private static object ConvertObjectToJavaScriptObject(object arg)
10361036
// TODO: Remove addition of 'id' key when spec is changed.
10371037
Dictionary<string, object> elementDictionary = new Dictionary<string, object>();
10381038
elementDictionary.Add("ELEMENT", argAsElement.InternalElementId);
1039-
elementDictionary.Add("id", argAsElement.InternalElementId);
1039+
elementDictionary.Add("element-6066-11e4-a52e-4f735466cecf", argAsElement.InternalElementId);
10401040
converted = elementDictionary;
10411041
}
10421042
else if (argAsDictionary != null)
@@ -1183,16 +1183,15 @@ private object ParseJavaScriptReturnValue(object responseValue)
11831183

11841184
if (resultAsDictionary != null)
11851185
{
1186-
if (resultAsDictionary.ContainsKey("ELEMENT"))
1186+
if (resultAsDictionary.ContainsKey("element-6066-11e4-a52e-4f735466cecf"))
11871187
{
1188-
string id = (string)resultAsDictionary["ELEMENT"];
1188+
string id = (string)resultAsDictionary["element-6066-11e4-a52e-4f735466cecf"];
11891189
RemoteWebElement element = this.CreateElement(id);
11901190
returnValue = element;
11911191
}
1192-
else if (resultAsDictionary.ContainsKey("id"))
1192+
else if (resultAsDictionary.ContainsKey("ELEMENT"))
11931193
{
1194-
// TODO: Remove addition of 'id' key when spec is changed.
1195-
string id = (string)resultAsDictionary["id"];
1194+
string id = (string)resultAsDictionary["ELEMENT"];
11961195
RemoteWebElement element = this.CreateElement(id);
11971196
returnValue = element;
11981197
}

0 commit comments

Comments
 (0)