Skip to content

[dotnet] store the mutated element for the user not just the target id - #12948

Merged
titusfortner merged 2 commits into
trunkfrom
mutate_element
Oct 16, 2023
Merged

[dotnet] store the mutated element for the user not just the target id#12948
titusfortner merged 2 commits into
trunkfrom
mutate_element

Conversation

@titusfortner

@titusfortner titusfortner commented Oct 13, 2023

Copy link
Copy Markdown
Member

Description

When an element is mutated it returns the ID of the element, this stores that element in the representative Data class instead of just the target ID.

Motivation and Context

  • The other languages do it.
  • It's not obvious to the user how to get the information

Required now:

            var mutations = new List<IWebElement>();
            using IJavaScriptEngine monitor = new JavaScriptEngine(driver);
            monitor.DomMutated += (sender, e) =>
            {
                var locator = By.CssSelector($"*[data-__webdriver_id='{e.AttributeData.TargetId}']");
                mutations.Add(driver.FindElement(locator));
            };

Desired:

            var mutations = new List<IWebElement>();
            using IJavaScriptEngine monitor = new JavaScriptEngine(driver);
            monitor.DomMutated += (sender, e) =>
            {
                mutations.Add(e.Element);
            };

Java:

    CopyOnWriteArrayList<WebElement> mutations = new CopyOnWriteArrayList<>();
    ((HasLogEvents) driver).onLogEvent(domMutation(e -> mutations.add(e.getElement())));

Ruby:

    mutations = []
    driver.on_log_event(:mutation) { |mutation| mutations << mutation.element }

@titusfortner titusfortner added the C-dotnet .NET Bindings label Oct 13, 2023
Comment thread dotnet/src/webdriver/JavaScriptEngine.cs Outdated
@titusfortner

Copy link
Copy Markdown
Member Author

There are a few places where the Args template isn't storing the useful information but I do not want to spend time on any of this if we can start pushing the actual BiDi spec. Actually, it probably is forward compatible the way it is written. We can add the more useful things with the correct classes in the next implementation. Just frustrating right now. :)

@titusfortner
titusfortner merged commit ae0d894 into trunk Oct 16, 2023
@titusfortner
titusfortner deleted the mutate_element branch October 16, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-dotnet .NET Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants