How to navigate to and enter input in nested frame/form with mechanize

I want to enter some text (login, password) inside a page with frames. The structure is something like:

<html xmlns="http://www.w3.org/1999/xhtml">
      <head>Whatever</head>
      <body id="Body">
            <form id="frmM" onsubmit="javascript:return whatever();" action="Login.aspx" method="post">
                  <div id="alldata">
                        <div id="header">
                              <iframe id="Login_SSL" scrolling="no" frameborder="1" src="https://www.whatever.com/User/LoginFrame.aspx?redir=/User/Login.aspx">
                                    <html xmlns="http://www.w3.org/1999/xhtml">
                                          <body onload="refreshParent()">
                                                <form id="form1" action="LoginFrame.aspx?redir=%2fUser%2fLogin.aspx" method="post">
                                                      <div id="loginRow" class="loginMenuRow" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'cmdLogin')">
                                                            <input id="cmdLogin" type="submit" tabindex="3" onclick="aspnetForm.target ='_top';" value="Login" name="cmdLogin">
                                                             <input id="Password" class="textbox" type="password" tabindex="2" name="Password">
                                                             <span id="lblPassword" class="loginMenu">Password:</span>
                                                       </div>
                                                </form>
                                            </body>
                                      </html>
                              </iframe>
                        </div>
                  </div>
            </form>
     </body>
</html>

If I try to find the form, I see that only the top level one is available.

>>br.select_form("form1")
FormNotFoundError: no form matching name 'form1'
>>[f.attrs['id'] for f in br.forms()]
['frmM']

How do I go about logging in to this site?

Answers


2 options:

  • Access the URL within the iframe directly and then do your form login

  • Login to the site from your browser and use an extension like Firebug to track the posted data. Then replicate this request to login automatically.


Need Your Help

Why Google Maps JavaScript API v3 returns different search result to search from maps.google.com

google-maps-api-3

I am using google map javascript API v3 in my application.It returns different results from maps.google.com

Forgetting to Close a ServerSocket

java linux sockets tcp

If my program does not execute a ServerSocket.close() and/or Socket.close() before it terminates, the next time I start the program, it will always throw an IOException when attempting to start lis...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.