我没有从表格中选中复选框

时间:2015-10-27 14:41:58

标签: html ruby web automation capybara

我没有从表格中选中一个复选框;我有32个复选框,我想检查role2,role3

请帮我看看如何选择role2,role3复选框。 以下是我的源代码:

 <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>

2 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

you can do something like this:

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();

make sure your row numbers are correct

相关问题