XmlPath xp = response.xmlPath(XmlPath.CompatibilityMode.HTML);
String target = xp.getString( "html.body.form.@action");
System.out.println( target );
List<Map> fields = xp.getList("html.body.form.**.findAll { it.name == 'input' }.collect { [name: it.@name, value: it.@value] }", Map.class);
System.out.println( fields );
System.out.println( fields.size() );
The output looks like this:
/auth/logon
[]
0
So, I can confirm that I can find the form tag, but I can't find and collect any of the input tags from within it.
<form enctype="application/x-www-form-urlencoded" method="POST" class="form" name="authForm" action="/auth/logon" accept-charset="UTF-8">
<input type="hidden" name="_csrf" value="1967212d-c0cd-484a-8f2a-a61358d1f969"/>
<div class="formarea">
<h1>Welcome to User Account Management</h1>
<span>
<script>/* throw up warning if using old browser */</script>
</span>
<div class="oldBrwr"/>
<span>
<input type="hidden" id="view" name="view" value="username"/>
<input type="hidden" id="authId" name="authId" value="{value}"/>
<input type="hidden" id="goToUrl" name="goToUrl" value="http%3A%2F%2Fwww.example.com%2F"/> <script src="js/deviceprint.js" type="text/javascript" language="javascript"/>
<input type="hidden" id="deviceId" name="deviceId" value=""/>
<script>decorateWithDeviceId(document.getElementById('deviceId'));</script>
</span>
<label for="user">User ID</label>
<input tabindex="1" type="text" class="usernameicon" id="user" autofocus="" name="username" autocomplete="off" onkeyup="document.forms[0].user.value!=''?document.forms[0].user.value=document.forms[0].user.value.trim().toLowerCase():'';" value=""/>
<div id="forgotPassword">
<a shape="rect" tabindex="2" class="forgotPasswordLink" style="float:right; margin-top:-43px" href="/auth/forgot">
Forgot User ID or Password?
</a>
</div>
<div style="clear:both"/>
<div class="XD-CLASS-EULA">/* EULA */</div>
<div style="clear:both"/>
<button tabindex="3" type="submit" class="submitbutton"> Accept </button>
<button tabindex="4" type="button" class="cancelbutton" cancel="" onclick="alert('You will not be able to access the application without accepting the Terms and Conditions of Use.')"> Decline </button>
<div style="clear:both"/>
</div>
</form>
The only thing that I can see that might be throwing it off is that for some reason the HTML element contains two heads and two bodies. But since I can find the form tag, I wouldn't think that would be the problem.
Any thoughts?