Selenium复选框数据驱动-复选框只有目标但没有值

Selenium复选框数据驱动-复选框只有目标但没有值,selenium,checkbox,Selenium,Checkbox,我在使用Selenium IDE参数化(数据驱动)复选框时遇到困难。当我使用Selenium记录选择复选框时,我得到以下操作: <tr> <td>click</td> <td>id=_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_chkbxChannel</td> <td></td> 点击 id=

我在使用Selenium IDE参数化(数据驱动)复选框时遇到困难。当我使用Selenium记录选择复选框时,我得到以下操作:

<tr>
<td>click</td>
<td>id=_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_chkbxChannel</td>
<td></td>

点击
id=_ctl0_main content占位符_UseCaseBesturing_uuctl1_dgOndersteundeChannels_uuuctl2_chkbxChannel

为了参数化这个动作并指向我的测试数据(XML)文件,我需要一个可以设置为变量的值。但是在这个动作中没有值,只有一个ID为的目标

您知道如何参数化此操作,或者如何使用值而不是仅使用目标(ID)来选中复选框吗

通过在Selenium中的值字段中为操作添加“${Parametername}”,文本字段可以正常工作。参数名将成为我的测试数据文件中的列名

复选框的Html代码:

<table class="detailgrid" cellspacing="0" border="0" id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels" style="border-style:None;border-collapse:collapse;">
    <tbody><tr>
        <td style="width:20px;">
                            <span disabled="disabled"><input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_chkbxChannel" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl2:chkbxChannel" checked="checked" disabled="disabled"></span>
                        </td><td>
                            <span id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl2_lblChannelNaam">POS</span>
                        </td>
    </tr><tr>
        <td style="width:20px;">
                            <input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl3_chkbxChannel" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl3:chkbxChannel">
                        </td><td>
                            <span id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl3_lblChannelNaam">eCommerce</span>
                        </td>
    </tr><tr>
        <td>
                            <br>
                            <span type="checkbox"><input id="_ctl0_MainContentPlaceHolder_UseCaseBesturing__ctl1_dgOndersteundeChannels__ctl4_chkalles1" type="checkbox" name="_ctl0:MainContentPlaceHolder:UseCaseBesturing:_ctl1:dgOndersteundeChannels:_ctl4:chkalles1" onclick="CheckAll('chkbxChannel', this.checked);"></span>
                        </td><td>
                            <br>
                            Alles Aan
                        </td>
    </tr>
</tbody></table>

销售时点情报系统
电子商务


阿莱斯安
仍然使用单击,但通过使用xpath更改查找目标的方式

它看起来像这样:

目标:

xpath=//td/span[text()='POS']

希望这有帮助

看完这个问题后,我尝试在Selenium IDE的测试步骤中使用Target参数(因为在多次尝试后无法参数化操作(命令))

要选择复选框,
Xpath
应指向输入标记,并可使用
单击
命令进行检查

在我看来,根据HTML,检查与
电子商务
对应的复选框的正确
Xpath
应该是:


//span[text()='eCommerce']/祖先::td/previous sibling::td/input

考虑使用XPath。我尝试了XPath=///td/span[text()='POS'],但它不起作用。它在Selenium中没有给出任何错误,但它只是不检查任何复选框。我将复选框区域的整个html代码放在了复选框区域中,也许这有助于了解如何完成这项工作。有3个可能的复选框(POS、电子商务、Alles aan)。我想在selenium中创建这个变量,这样我就可以使用我的测试数据来定义应该选中哪个复选框。记住,
span
不是复选框,不管它在浏览器中是什么样子。您是否尝试过使用
click()
。你还试过什么?