Skip to content

TypeError: [object HTMLCollection] is not iterable  #576

Description

@vplemyannik

Hi, could someone to help me ?
I have faced with an exception when HtmlUnit (WebDriver) parse HTML page that contains such code

<script>
    const forms = document.getElementsByTagName('form');

    for (const form of forms) {
        form.addEventListener('submit', preventDoubleClick);
    }

    function preventDoubleClick({ submitter }) {
        if (submitter) {
            submitter.disabled = true;
        }
    }
</script>

Stacktrace

Caused by: net.sourceforge.htmlunit.corejs.javascript.EcmaError: TypeError: [object HTMLCollection] is not iterable (script in https://localhost:8543/auth/realms/authz-test/super-random-page from (49, 9) to (61, 10)#52)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4635)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:4616)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeError(ScriptRuntime.java:4648)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.typeErrorById(ScriptRuntime.java:4653)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.enumInitInOrder(ScriptRuntime.java:2275)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.enumInit(ScriptRuntime.java:2244)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:2125)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:1053)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:89)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:392)
	at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:335)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3916)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:102)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$2.doRun(JavaScriptEngine.java:870)
	at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:984)
	... 39 more

htmlunit-driver v4.8.1.1
htmlunit v2.7.0

Does it because Rhino do not support for...of loop ?
Is there any way to fix it (without rewriting loop 😄 )?

Thanks

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions