Skip to content

Setting type for HtmlInput does not work #658

@Deadc00l

Description

@Deadc00l

Setting a type by "setType("hidden", true)" or by "setAttribute("type", "hidden")" doesn't seem to work. I was not able to found out, where the bug is. I guess somewhere between: org.htmlunit.html.HtmlInput.setType(String, boolean) line 1222 - 1228.

I have modified an unittest in "/htmlunit/src/test/java/org/htmlunit/html/HtmlPageTest.java" to reproduce this issue:

    /**
     * @throws Exception if the test fails
     */
    @Test
    public void formSubmit() throws Exception {
        final String htmlContent = "<html>\n"
            + "<head><title>foo</title></head>\n"
            + "<body>\n"
            + "<p>hello world</p>\n"
            + "<form id='form1' action='/formSubmit' method='PoSt'>\n"
            + "<input type='text' NAME='textInput1' value='textInput1'/>\n"
            + "</form>\n"
            + "</body></html>";
        final HtmlPage page = loadPage(htmlContent);
        final MockWebConnection webConnection = getMockConnection(page);

        final HtmlForm form = page.getHtmlElementById("form1");
        final HtmlInput textInput = form.getInputByName("textInput1");
        textInput.setValue("foo");
        textInput.setType("hidden", true);
        
        assertEquals("hidden", textInput.getType());
    }

Metadata

Metadata

Assignees

No one assigned

    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