Skip to content

Commit ae0d894

Browse files
authored
[dotnet] store the mutated element for the user not just the target id (#12948)
1 parent 4c7b83f commit ae0d894

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

dotnet/src/webdriver/DomMutationData.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public string AttributeOriginalValue
7070
internal set { this.attributeOriginalValue = value; }
7171
}
7272

73+
/// <summary>
74+
/// Stores the element associated with the target ID
75+
/// </summary>
76+
public IWebElement Element { get; internal set; }
77+
7378
/// <summary>
7479
/// Returns a string that represents the current object.
7580
/// </summary>

dotnet/src/webdriver/JavaScriptEngine.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Collections.Generic;
2121
using System.Globalization;
2222
using System.IO;
23+
using System.Linq;
2324
using System.Threading.Tasks;
2425
using Newtonsoft.Json;
2526
using OpenQA.Selenium.DevTools;
@@ -75,7 +76,7 @@ public JavaScriptEngine(IWebDriver driver)
7576
public event EventHandler<JavaScriptExceptionThrownEventArgs> JavaScriptExceptionThrown;
7677

7778
/// <summary>
78-
/// Occurs when methods on the JavaScript console are called.
79+
/// Occurs when methods on the JavaScript console are called.
7980
/// </summary>
8081
public event EventHandler<JavaScriptConsoleApiCalledEventArgs> JavaScriptConsoleApiCalled;
8182

@@ -380,6 +381,9 @@ private void OnScriptBindingCalled(object sender, BindingCalledEventArgs e)
380381
if (e.Name == MonitorBindingName)
381382
{
382383
DomMutationData valueChangeData = JsonConvert.DeserializeObject<DomMutationData>(e.Payload);
384+
var locator = By.CssSelector($"*[data-__webdriver_id='{valueChangeData.TargetId}']");
385+
valueChangeData.Element = driver.FindElements(locator).FirstOrDefault();
386+
383387
if (this.DomMutated != null)
384388
{
385389
this.DomMutated(this, new DomMutatedEventArgs()

0 commit comments

Comments
 (0)