【问题标题】:I'm failing to select the check box from a table我未能从表格中选择复选框
【发布时间】:2016-01-27 00:56:42
【问题描述】:

我没有从表格中选择一个复选框;我有 32 个复选框,我想选中角色 2、角色 3

请帮助我了解如何选择角色 2、角色 3 复选框。 以下是我的源代码:

 <tr>
    <td class='first'>

        <input type='checkbox' onclick=CheckboxClick(this); name='Role2' value='Role2' />

    </td>
    <td>
        <b>Home View Search</b>
    </td>
    <td class='last'>
        View and perform search operations from Home page.
    </td>
</tr>

<tr>
    <td class='first'>

        <input type='checkbox' onclick=CheckboxClick(this); name='Role3' value='Role3' />

    </td>
    <td>
        <b>System Manage Admin</b>
    </td>
    <td class='last'>
        Create, update and delete administrators.
    </td>
</tr>

</select>

    </div>

</td>
<td valign='top'>
    <div style='height: 200px; overflow-y: auto; overflow-x: hidden; border: 1px solid #ccc;'>
        <table width='100%' class='checkbox' id='functionTable'>
            <thead>
                <tr>
                    <td colspan='2' width='560'>
                        TM Functions
                    </td>
                    <td>
                        TM Administration Functions
                    </td>
                </tr>
            </thead>
            <tbody>

                <tr>
                    <td class='first'>

                        <input type='checkbox' onclick=CheckboxClick(this); name='Role0' value='Role0' />

                    </td>
                    <td>
                        <b>Home Switch Owners</b>
                    </td>
                    <td class='last'>
                        Ability to switch owners clicking on owner name from Home screen.
                    </td>
                </tr>

                <tr>
                    <td class='first'>

                        <input type='checkbox' onclick=CheckboxClick(this); name='Role1' value='Role1' />

                    </td>
                    <td>
                        <b>Home Accept Decline Vendor Invite</b>
                    </td>
                    <td class='last'>
                        Accept or decline vendor invitations from Home page.
                    </td>
                </tr>

                <tr>
                    <td class='first'>

                        <input type='checkbox' onclick=CheckboxClick(this); name='Role2' value='Role2' />

                    </td>
                    <td>
                        <b>Home View Search</b>
                    </td>
                    <td class='last'>
                        View and perform search operations from Home page.
                    </td>
                </tr>

                <tr>
                    <td class='first'>

                        <input type='checkbox' onclick=CheckboxClick(this); name='Role3' value='Role3' />

                    </td>
                    <td>
                        <b>System Manage Admin</b>
                    </td>
                    <td class='last'>
                        Create, update and delete administrators.
                    </td>
                </tr>

【问题讨论】:

    标签: html ruby web automation capybara


    【解决方案1】:

    假设它们在页面上可见,则以下应检查 Role2 和 Role 3

    page.check('Role2')
    page.check('Role3')
    

    【讨论】:

      【解决方案2】:

      你可以这样做:

      webelement element = driver.findelement(by.xpath(//[@id='tablename'/tbody/tr/td[2])).click(); webelement element = driver.findelement(by.xpath(//[@id='tablename'/tbody/tr/td[3])).click();

      确保您的行号正确

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多