質問

Ok, First the code:

<tr class="tableControlDataRow evenRow twTableTR">
<td class="twTableTD details" align="center" rowspan="2">
<td class="twTableTD details" align="center" rowspan="2">
    <p>
    <br>
    **<p>**
        <b>Model Number:</b>
        QA GM 05132014 1038 Item 1 Model Number
    </p>
    <p>
    <p>
    <p>
    <p>
</td>
<td class="twTableTD" align="center" rowspan="2">May-27-2014</td>
<td class="twTableTD" align="center">France</td>
<td class="twTableTD" align="center">Yes</td>
<td class="twTableTD" align="center">
    <input id="hiddenCountryAuthorizationField0_0" type="hidden" name="tw#local#quoteComparison#0#country#0#authorizationStatusId#" value="0">
    <input id="CountryAuthorizationYES0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'Yes','1')">
    Yes
    <br>
    <input id="CountryAuthorizationNO0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'No','2')">
    No
    <br>
</td>

Now the question... I have found the correct starting spot by doing a

//p[contains(., "QA GM 05132014 1038 Item 1 Model Number")]

This gets me to the ** portion of the code. Now I need to traverse up to the <tr class="tableControlDataRow evenRow twTableTR"> at the top, then travel back down the chain to click the

<input id="CountryAuthorizationYES0_0" class="qclCheckbox" type="checkbox" onclick="chooseAuthorization(0,0,'Yes','1')">

text box. Any suggestions?

役に立ちましたか?

解決

First find the tr, that has p tag with the appropriate text, and then go down to the desired input:

//tr[.//p[contains(., "QA GM 05132014 1038 Item 1 Model Number")]]/td/input[@id="CountryAuthorizationYES0_0"]

Just note that there are certainly multiple ways to write the xpath here. Hope this one works for you.

他のヒント

I would also suggest //p[contains(text(),'QA GM 05132014 1038 Item 1 Model Number')]/ancestor::tbody[1]//input[@id='CountryAuthorizationYES0_0']. It will search element which contains 'QA GM 05132014 1038 Item 1 Model Number' text, then search first parent element tbody and then desired input starting from first (parent) tbody

It ain't pretty, but this code might help you:

//p[contains(., "QA GM 05132014 1038 Item 1 Model Number")]//parent::br/parent::td/parent::tr//input[@id='CountryAuthorizationYES0_0']
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top