Skip to content

[🐛 Bug]: IWebElement passed to ExecuteJavaScript() is undefined #14817

@Tomahawk-IT

Description

@Tomahawk-IT

What happened?

IWebDriver.ExecuteJavaScript throws exception when passing IWebElement as argument

driver.ExecuteJavaScript($"arguments[0].value = '{value}'", element);
 System.InvalidOperationException : javascript error: Cannot set properties of undefined (setting 'value')
  (Session info: chrome=131.0.6778.70)
  (Driver info: chromedriver=131.0.6778.69 (77e2244bbcda3ab9362d5b8aeeb006a86a6d4832-refs/branch-heads/6778@{#2141}),platform=Windows NT 10.0.19045 x86_64) (UnexpectedJavaScriptError)

How can we reproduce the issue?

    var driver = new ChromeDriver();
    string value = "testValue";

    driver.Navigate().GoToUrl("http://uitestingplayground.com/textinput");
    Thread.Sleep(1000);
    var element = driver.FindElementById("newButtonName");
    
    driver.ExecuteJavaScript($"arguments[0].value = '{value}'", element);

Relevant log output

(Session info: chrome=131.0.6778.70)
  (Driver info: chromedriver=131.0.6778.69 (77e2244bbcda3ab9362d5b8aeeb006a86a6d4832-refs/branch-heads/6778@{#2141}),platform=Windows NT 10.0.19045 x86_64) (UnexpectedJavaScriptError)

Operating System

Windows 11

Selenium version

dotnet 472

What are the browser(s) and version(s) where you see this issue?

131.0.6778.70

What are the browser driver(s) and version(s) where you see this issue?

131.0.6778.69

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-defectSomething is not working as intendedJ-issue-templateApplied to issues not following the template, or missing information.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions