質問

Hi, I want to b able to click on a check box based on a value. Below is the html of the same:

<tbody>
<tr>
    <th>Record Type</th>
    <th style="text-align:center">Has Access?</th>
    <th style="text-align:center">Can Create?</th>
    <th style="text-align:center">Can Read All Records?</th>
</tr>
<tr>
    <td>
        <input id="ORMW.S2.0.Object Type" class="readOnlyField" type="text"      value="Account" maxlength="255" size="25" name="ORMW.S2.0.Object Type" readonly="readonly"/>
    </td>
    <td align="center">
        <input id="ORMW.S2.0.Has Access_VP123456" type="checkbox" onclick="cbValue(this,'ORMW.S2.0.Has\x20Access');" style="margin-left:0px;margin-top:1px;height:10px;width:10px;vertical-align:middle"/>
        <input id="ORMW.S2.0.Has Access" type="hidden" value="Y" tabindex="-1"   name="ORMW.S2.0.Has Access"/>
    </td>
    <td align="center">
    <td align="center">

I want to click on checkbox based on the value account here.

役に立ちましたか?

解決

Next query will search element by @value='Account' then traverse up to the first tr and then search your checkbox:

//input[@type='text' and @value='Account']/ancestor::tr[1]//input[@type='checkbox']

他のヒント

you can also try this:

//input[@type='checkbox' and preceding-sibling::input[@type='text' and @value='Account']]
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top