如何使用 splinter 填充 table 内的输入框?

How to use splinter to fill up an input box inside a table?

我有一个 html 结构如下:

    <table id="Table1" style="Z-INDEX: 101; LEFT: 52px; WIDTH: 407px; POSITION: absolute; TOP: 53px" width="407" cellspacing="1" cellpadding="1" border="0">
                <tbody><tr>
                    <td style="WIDTH: 102px"></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td style="WIDTH: 102px">Email</td>
                    <td>
                        <input name="TextBox1" id="TextBox1" style="width:153px;" type="text"></td>
                    <td></td>
                </tr>
                <tr>
                    <td style="WIDTH: 102px">Password</td>
                    <td>
                        <input name="TextBox2" id="TextBox2" style="width:153px;" type="password"></td>
                    <td>
                        <input name="Button1" value="Login" id="Button1" style="width:68px;" type="submit"></td>
                </tr>
                <tr>
                    <td style="WIDTH: 102px"></td>
                    <td> </td>
                    <td></td>
                </tr>
                <tr>
                    <td style="WIDTH: 102px; height: 20px;"><a href="signinup.aspx">Sign up</a></td>
                    <td style="height: 20px">
                        <a href="changepassword.aspx">Change Password</a></td>
                    <td style="height: 20px"><a href="RetrievePassword.aspx">Retrieve Password</a></td>
                </tr>
                <tr>
                    <td style="WIDTH: 102px"></td>
                    <td> </td>
                    <td></td>
                </tr>
            </tbody>
         </table>

我想访问 ID 为 TextBox1 和 TextBox2 的输入框,并填写用户名和密码。

我正在做以下事情(例如):

browser.fill('TextBox1', 'John')

但是 returns 我有一个错误:

splinter.exceptions.ElementDoesNotExist: no elements could be found with name "TextBox1"

有人可以帮忙吗? (我是第一次使用splinter)

正如您在评论中提到的,问题出在包裹盒子的框架上。像这样绕过它:

browser.visit(browser.find_by_tag('frame')[0]['src'])
browser.fill('TextBox1', 'John')