Invoke-WebRequest response.forms.fields uses Id attribute as the key instead of Name - by Aaron Stringer

Status : 

 


3
0
Sign in
to vote
ID 775739 Comments
Status Active Workarounds
Type Bug Repros 2
Opened 1/3/2013 3:32:53 PM
Access Restriction Public

Description

When an <input> tag in an html form has an "id" attribute as well as "name" the "id" field is used as the key in the response.forms.fields collection.
When this collection is used in a POST as per the technet documentation the values are not recognised by the web server as the names are not correct. ("http://technet.microsoft.com/en-us/library/hh849901.aspx" Exampe 2)

HTML contains:
        <input type="text" name="username" id="login_username" class="field required" title="Please provide your username" />

$Response = Invoke-WebRequest http://fakeurl.com/login.aspx
$Response.Forms[0].Fields

Fields should contain the key "username" but instead contains the key "login_username"
Sign in to post a comment.
Posted by Ronald Rink on 5/10/2013 at 11:59 PM
I experience the same behaviour. You can however correlate the form names and ids via the InputFields collection as shown in the 'Workarounds' tab.
Posted by Chris Hunnewell on 2/28/2013 at 3:04 PM
I experienced this same issue on a site that contained the following form inputs:
<input id="username" type="text" name="__ac_name" class="inputbox" style="top:160px" />
<input type="password" name="__ac_password" class="inputbox" style="top:202px;" />

$Response.Forms[0].Fields contained the following two keys:
username
__ac_password