selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[🐛 Bug]: IWebElement.Displayed throws 'HTMLFormElement' is undefined error in Selenium 4.25

Open mannaci opened this issue 1 year ago • 14 comments

What happened?

After upgrading from Selenium 4.23 to 4.25, the IWebElement.Displayed property is throwing a JavaScriptException with the message "'HTMLFormElement' is undefined" when used on certain elements. This behavior was not observed in the previous version. The element in question is not located within a

tag.

How can we reproduce the issue?


using OpenQA.Selenium;

string driverPath = Environment.GetEnvironmentVariable("RPA_DRIVER", EnvironmentVariableTarget.User);

var ieOptions = new InternetExplorerOptions()
{
    EdgeExecutablePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
    AttachToEdgeChrome = true,
    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
    IgnoreZoomLevel = true,
};

InternetExplorerDriverService ieDriver = InternetExplorerDriverService.CreateDefaultService(driverPath);


ieDriver.LogFile = Path.Combine(@"C:\log\", "logs", "driver.log");

ieDriver.LoggingLevel = InternetExplorerDriverLogLevel.Trace;

ieDriver.SuppressInitialDiagnosticInformation = true;

var driver = new InternetExplorerDriver(ieDriver, ieOptions);
driver.Navigate().GoToUrl("xxxxxxx");
IWebElement d = driver.FindElement(By.XPath("/html/body/div[2]/div/div/div/div/div/div[2]/div/div[2]/div/div/div/div[4]/div/div/div[2]/div/div/div/div/div/div/div[2]/div[2]/span[4]/div/span[2]"));
Console.WriteLine(d.Displayed);

Relevant log output

KO
D 2024-09-26 14:15:53:972 C:\code\selenium\cpp\iedriver\Script.cpp(285) 067C559C
T 2024-09-26 14:15:53:977 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(734) Entering IECommandExecutor::OnScriptWait
T 2024-09-26 14:15:53:977 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1315) Entering IECommandExecutor::GetCurrentBrowser
T 2024-09-26 14:15:53:977 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1321) Entering IECommandExecutor::GetManagedBrowser
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1210) Entering IECommandExecutor::IsAlertActive
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\Browser.cpp(868) Entering Browser::GetActiveDialogWindowHandle
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\Browser.cpp(315) Entering Browser::GetContentWindowHandle
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\Script.cpp(132) Entering Script::ResultIsString
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\Script.cpp(582) Entering Script::ConvertResultToJsonValue
D 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1227) No alert handle is found
T 2024-09-26 14:15:53:978 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(901) Entering IECommandExecutor::ScriptWaitThreadProc
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(734) Entering IECommandExecutor::OnScriptWait
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1315) Entering IECommandExecutor::GetCurrentBrowser
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1321) Entering IECommandExecutor::GetManagedBrowser
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1210) Entering IECommandExecutor::IsAlertActive
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\Browser.cpp(868) Entering Browser::GetActiveDialogWindowHandle
T 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\Browser.cpp(315) Entering Browser::GetContentWindowHandle
D 2024-09-26 14:15:54:004 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(1227) No alert handle is found
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\iedriver\AsyncScriptExecutor.cpp(230) Entering AsyncScriptExecutor::OnDetachListener
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\iedriver\AsyncScriptExecutor.cpp(246) Entering AsyncScriptExecutor::OnGetResult
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\webdriver-server\response.cc(100) Entering Response::SetErrorResponse
W 2024-09-26 14:15:54:005 C:\code\selenium\cpp\webdriver-server\response.cc(101) Error response has status code 17 and message 'Error from JavaScript: 'HTMLFormElement' is undefined' message
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\webdriver-server\response.cc(94) Entering Response::SetErrorResponse
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\webdriver-server\response.cc(87) Entering Response::SetResponse
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\iedriver\AsyncScriptExecutor.cpp(88) Entering AsyncScriptExecutor::OnClose
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\iedriver\AsyncScriptExecutor.cpp(97) Entering AsyncAtomExecutor::OnDestroy
T 2024-09-26 14:15:54:005 C:\code\selenium\cpp\webdriver-server\response.cc(60) Entering Response::Serialize
T 2024-09-26 14:15:54:020 C:\code\selenium\cpp\iedriver\IESession.cpp(235) Found non-zero response length
T 2024-09-26 14:15:54:020 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(201) Entering IECommandExecutor::OnGetResponse
T 2024-09-26 14:15:54:020 C:\code\selenium\cpp\iedriver\IECommandExecutor.cpp(641) Entering IECommandExecutor::OnIsSessionValid
D 2024-09-26 14:15:54:020 C:\code\selenium\cpp\webdriver-server\server.cc(426) Response: {
	"value" : 
	{
		"error" : "javascript error",
		"message" : "Error from JavaScript: 'HTMLFormElement' is undefined",
		"stacktrace" : ""
	}

Operating System

Windows10

Selenium version

4.25 in c# net8.0

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

EDGE in ieMode

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

IEDriverServer.exe 4.14.0.0 (32-bit), Microsoft Edge WebDriver 129.0.2792.52

Are you using Selenium Grid?

No response

mannaci avatar Sep 26 '24 12:09 mannaci

@mannaci, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

github-actions[bot] avatar Sep 26 '24 12:09 github-actions[bot]

hi, is there an update?

mannaci avatar Oct 08 '24 19:10 mannaci

Unfortunately, as of June 2022 Selenium no longer supports Internet Explorer.

shbenzer avatar Oct 14 '24 22:10 shbenzer

Since IE is deprecated, you may encounter issues with compatibility specially in newer framework like .NET8

ankitwits avatar Oct 22 '24 10:10 ankitwits

Can we have a deprecation warning for this then?

Delta456 avatar Oct 22 '24 11:10 Delta456

IE is deprecated but I see the code example is using IE mode in Edge. Is the issue related to that?

diemol avatar Oct 22 '24 16:10 diemol

Hi diemol, yes of course I'm using edge in iemode. unfortunately I still have interactions with systems that don't work otherwise. The same code with new version (also 4.24) don’t work with error in preview post.

mannaci avatar Oct 22 '24 18:10 mannaci

The same code with new version (also 4.24) don’t work with error in preview post.

What does this mean? When did it stop working? Was it a specific MS Edge version or an specific Selenium version?

diemol avatar Oct 23 '24 19:10 diemol

We wrote a program with version 4.23 and it works perfectly. If I try to upgrade to version 4.24 or 4.25, the 'displayed' property launches the exception "Error from JavaScript: 'HTMLFormElement' is undefined"

Driver version IEDriverServer.exe 4.14.0.0 (32-bit) Microsoft Edge WebDriver 129.0.2792.59 The edge version is the same of the driver

mannaci avatar Oct 24 '24 18:10 mannaci

Is it due to https://github.com/SeleniumHQ/selenium/pull/14389 ? I see a new reference to "HTMLFormElement" in atoms/domcore.js

bhecquet avatar Nov 05 '24 14:11 bhecquet

Is it due to #14389 ? I see a new reference to "HTMLFormElement" in atoms/domcore.js

It’s possible, I’m not sure why only IE Mode would be having difficulties though

shbenzer avatar Nov 05 '24 14:11 shbenzer

Hello,

I found an explanation about the problem I've had about "'HTMLFormElement' is undefined" The website I'm testing is forced in "IE5 compatibility mode". In that mode, HTMLFormElement does not exist image

That said, I think there are 2 solutions

  • consider that no one should ever test so old applications, so Selenium should not care about this error
  • consider it's a regression and test if HtmlFormElement exist before using it

bhecquet avatar Nov 27 '24 14:11 bhecquet

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar May 26 '25 20:05 github-actions[bot]

Is this fixable? I still need to test on legacy systems.

kemielis3456 avatar May 28 '25 08:05 kemielis3456

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Nov 24 '25 10:11 github-actions[bot]