2016-11-16 10 views
0

xpath selectで少し問題があります。Xpath生成されたテーブルのDivの先行兄弟チェックボックスの選択

私は現在、私は唯一の先行兄弟本部内のテキストの行を知りながら生成されたテーブル内のチェックボックスを選択する必要があることにより、この問題を克服しようとしているC#とセレン

を使用しています。すべてのIDはランダムに生成されるので変更できます。

私は=テキストのみ「テストデータ」

<div role="row" style="position: relative; height:28px;" id="row1jqxgrid"> 
    <div role="gridcell" style="left: 0px; z-index: 790; width:30px;" class="jqx-grid-cell jqx-item jqx-grid-cell-alt jqx-grid-cell-selected jqx-fill-state-pressed"> 
     <div style="position: absolute; top: 50%; left: 50%; margin-top: -7px; margin-left: -10px; overflow: visible; cursor: auto;" id="jqxWidget3af6ac8d" tabindex="0" class="jqx-widget jqx-checkbox"> 
      <div class="jqx-checkbox-default jqx-fill-state-normal jqx-rc-all"> 
       <div style="width: 13px; height: 13px;"><span style="width: 13px; height: 13px;" class="jqx-checkbox-check-checked"></span></div> 
      </div> 
      <div style="clear: both;"></div> 
     </div> 
    </div> 
    <div role="gridcell" style="left: 30px; z-index: 789; width:25px;display: none;" class="jqx-grid-cell"></div> 
    <div role="gridcell" style="left: 30px; z-index: 789; width:200px;" class="jqx-grid-cell jqx-item jqx-grid-cell-alt jqx-grid-cell-selected jqx-fill-state-pressed"> 
     <div class="jqx-grid-cell-left-align" style="margin-top: 6px;"><a id="id_01" href="/test/testing?id_01=199">testdata</a></div> 
    </div> 
</div> 
+0

試してみてください。// div [div [div [text()= "testdata"]]] // div/span' – Andersson

答えて

0

を知りながらあなたはどこにでも文字列testdataとその中に含まれているrowを選択しようとすることができ、「JQX-チェックボックスにチェック・確認」クラスを選択しますrow必要なクラスを使用してdivを選択します。

最初の試みは、次のようになります。これは、最も簡単な方法だろう

//div[@class='row'][.//div[text()='testdata']]//span[@class='jqx-checkbox-check-checked'] 

0

あなたは、testdataを持つ要素を選択し、祖先のdivに移動して、あなたが必要とすることをまたがって行くことができます:

//*[text()='testdata']/ancestor::div[@role='row']//span 

はまた、あなたが必要なスパンのクラスのcalssまたは一部を指定することができます

//*[text()='testdata']/ancestor::div[@role='row']//span[contains(@class,'checked')] 

//*[text()='testdata']/ancestor::div[@role='row']//span[@class = 'jqx-checkbox-check-checked'] 
関連する問題