Search code examples
javahtmljsoupjaunt-api

Filling out a HTML-form with complex name (dot-notation in input-tag) with Java and Jaunt API


- hey folks,

i am building a Java-tool, trying to automatically fill out some form input elements in an HTML-Page using Java and Jaunt API.

the HTML-Code is like:

<fieldset class = "fieldsetlong">
<legend>searchprofile</legend>
<label for="reference">reference:</label>
<input maxlength="50" name="reference" id="reference" type="text" />
</fieldset>

<fieldset class = "fieldsetlong">
<legend>searchcriteria</legend>
<label for="surname">surname:</label>
<input name="searchprofile.surname" id="surname" type="text" />
</fieldset>

The Java-Code for filling in the "normal" Input-field reference (it works) looks like:

form.set("reference", "123Test");

Unfortunately, I am not able to fill out the fields that use the dot-notation searchprofile.surname in the name

Here's a sample of what i've tried (without success):

form.set("surname", "TestPerson");
form.set("searchprofile.surname", "TestPerson");
form.set("name=\"searchprofile.surname\"", pers.getSurname());
form.set("id=\"surname\"", pers.getSurname());

For each of these commands I get a NotFoundException and don't know whether I can do this with Jaunt.

It would appreciate any kind of help in this regard.

Thanks in advance

Edit - is there a way to reach the dot-notated input-field searchprofile.surname with JSoup?

HTML allows dots in the name-Attribute, but does Jaunt accept this abc.name?


Solution

  • Today, at work the Jaunt solution with

    form.set("searchprofile.surname", "TestPerson");
    

    worked like a charm.

    I don't know what the problem was earlier but I am glad that it worked.

    The HTML allows to use dots and minus, etc. which I misinterpreted as some kind of nested forms or hierarchies but the dot-notation is just a valid name-attribute in HTML.